Created
November 23, 2015 11:35
-
-
Save RatanPaul/2c1e04b0f7846ca333bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class pdfGenerate | |
{ | |
public pdfGenerate() | |
{ | |
} | |
public void createAttachment() | |
{ | |
PageReference pref = Page.pdfpage; | |
blob b = pref.getContentAsPDF (); | |
Attachment a = new Attachment(); | |
a.body = b; | |
a.name = 'Sheet.pdf'; | |
a.parentid = '0019000001YABiE'; | |
insert a; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page showHeader="false" controller="pdfGenerate"> | |
<apex:form> | |
<style> | |
body { | |
background-color: #CCC; | |
margin:80px 80px 100px 100px; | |
} | |
div#fixedheader { | |
position:fixed; | |
top:0px; | |
left:0px; | |
width:100%; | |
color:#CCC; | |
background:#333; | |
padding:20px; | |
} | |
div#fixedfooter { | |
position:fixed; | |
bottom:0px; | |
left:0px; | |
width:100%; | |
color:#CCC; | |
background:#333; | |
padding:8px; | |
} | |
</style> | |
<body> | |
<div id="fixedheader"> | |
Account name is: ----------- and the date is {!TODAY()} | |
</div> | |
<apex:commandButton action="{!createAttachment}" value="createPDF"/> | |
<div class="content"> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
</div> | |
<div id="fixedfooter">Bottom div content</div> | |
</body> | |
</apex:form> | |
</apex:page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page renderAs="pdf" applyBodyTag="false" > | |
<head> | |
<style type="text/css" media="print"> | |
@page { | |
@top-center { | |
content: element(header); | |
} | |
@bottom-left { | |
content: element(footer); | |
} | |
} | |
div.header { | |
padding: 10px; | |
position: running(header); | |
} | |
div.footer { | |
display: block; | |
padding: 5px; | |
position: running(footer); | |
} | |
.pagenumber:before { | |
content: counter(page); | |
} | |
.pagecount:before { | |
content: counter(pages); | |
} | |
</style> | |
</head> | |
<div class="header"> | |
<div>Account name is: ----------- and the date is {!TODAY()}</div> | |
</div> | |
<div class="footer"> | |
<div>Page <span class="pagenumber"/> of <span class="pagecount"/></div> | |
hello | |
</div> | |
<div class="content"> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
<p>Actual page body information.</p> | |
</div> | |
</apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment