You need to sign in to do that
Don't have an account?
cmark
apex to pdf - page headers
Hello. I am currently doing pdf generation using an external web service that i wrote - but i'm looking to move the functionality into sfdc using the new apex to pdf. The pdf that i generate has multiple pages - all with a common header (with images). I've seen from other threads that this isn't quite supported in any automated fashion (http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=3205). So I guess the alternative is to foce page breaks and re-draw the header.
My pdf will have either one or two dynamic pages (based on the number of line items), and 4 static pages (terms of sale, etc). So the static pages are easy, but my question is, can I conditionally draw the second dynamic page? That is, if I have more than 6 line items, draw the second dynamic page. Otherwise, go straight to the static pages. Is this possible using the VF markup? Are there any samples with forced page breaks? I found one thread where a page break is forced, but there's no conditional logic around it (http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=3880). Do I just throw all of the necessary logic into the apex:repeat block?
Thanks
Chris
My pdf will have either one or two dynamic pages (based on the number of line items), and 4 static pages (terms of sale, etc). So the static pages are easy, but my question is, can I conditionally draw the second dynamic page? That is, if I have more than 6 line items, draw the second dynamic page. Otherwise, go straight to the static pages. Is this possible using the VF markup? Are there any samples with forced page breaks? I found one thread where a page break is forced, but there's no conditional logic around it (http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=3880). Do I just throw all of the necessary logic into the apex:repeat block?
Thanks
Chris
I have a PDF which is built based on a StandardSetController from a list view, where the user is able to select any number of items to print.
Luckily, these items all render in about the same height, so just like you, we wanted to paginate for every 5 items, with a repeated header using standard pageBlock elements.
Steps to get your PDF to do this:
1. In your list which your page is looping through, you need to get each element in the list to know what rank it is in the list. The hacky part: for us, we just temporarily use a numeric field on the custom object we're looping through, and assign it its place in the loop. Controller code for this:
(Obviously you don't want to call an "update" on the list after doing this!!)
2. In your page code, have your <apex:repeat> tag iterate over header / item / footer for EVERY item. Put conditional "rendered" attributes on your header and footer. Unfortunately, since apex doesn't appear to support the modulo (%) operator, the only way I found to do this was to check for every possible iteration that the header and footer need to be rendered on:
I hope that helps someone else facing the same issue I was!
Austin, TX
All Answers
I have a PDF which is built based on a StandardSetController from a list view, where the user is able to select any number of items to print.
Luckily, these items all render in about the same height, so just like you, we wanted to paginate for every 5 items, with a repeated header using standard pageBlock elements.
Steps to get your PDF to do this:
1. In your list which your page is looping through, you need to get each element in the list to know what rank it is in the list. The hacky part: for us, we just temporarily use a numeric field on the custom object we're looping through, and assign it its place in the loop. Controller code for this:
(Obviously you don't want to call an "update" on the list after doing this!!)
2. In your page code, have your <apex:repeat> tag iterate over header / item / footer for EVERY item. Put conditional "rendered" attributes on your header and footer. Unfortunately, since apex doesn't appear to support the modulo (%) operator, the only way I found to do this was to check for every possible iteration that the header and footer need to be rendered on:
I hope that helps someone else facing the same issue I was!
Austin, TX
Hi Jeremy,
I had a similiar kind of requirement. Your post helped me to achieve the requirement.
Thanks a Lot.
Regards,
AJ
Hi,,,
Can u give me suggestions ,how to add the same header and footers in mutiple pages that is generated as a pdf.
Thanking you,
Vamsi Krishna
Hi Vamsi,
Create a temporary Integer variable in the List which you iterate and increment it for each record.
In the visualforce put the header content in the output panel and render it by using the count variable.
Check the above sample code which is posted.
Regards,
AJP
Use following style
<style>
@page
{ size:landscape;
@top-right { /* page numbers */
content: "Page " counter(page);
}
@top-left { /* Header contents*/
content: "Page Header";
}
@bottom-left { /* Footer contents*/
content: "Page Footer";
}
}
.bold{ font-weight: bold; }
</style>
Does this work for you when you add the style details into the VF page directly?
I can only get it to work if I put it into a css file as a Static Resource, however I want to include some dynamic data like record name in the header, so including it in the page itself would let me do that.
Hi, every one thanks for solution, but i have one problem, if we are displaying the quote line item values in table it has more values then the values will present next page right, but i want the table header for next page values also please help me urgent.