You need to sign in to do that
Don't have an account?
geniousxu
generate mutiple pages in one PDF file
Hello, I am an amateur about the PDF generation.
What I am doing now is that I want to render a page into PDF file and save it in database when I click a botton.
Source like this:
// botton action
public void pdfOutPut() { document dc = new document(); String pdfPageURL = '/apex/PdfOutputLayout?id=' + pageId; PageReference pageRef = new PageReference(pdfPageURL); dc.body = pageRef.getContent(); dc.name = 'pdftest' + System.DateTime.now() + '.pdf'; dc.folderid = folderId; insert dc; }
Now the problem is when I want to render mutiple pages into one PDF, how can I do?
My consideration likes this:
public void pdfOutPut() { document dc = new document(); for(int i = 0; i < list.size(); i++){
String pdfPageURL = '/apex/PdfOutputLayout?id=' + pageId; PageReference pageRef = new PageReference(pdfPageURL); dc.body += pageRef.getContent(); }
dc.name = 'pdftest' + System.DateTime.now() + '.pdf'; dc.folderid = folderId; insert dc; }
I use "pageRef.getContent()" to get the PDF's binary data so I guess I could add each PDF's binary data into one. But there is error seems like "+=" is not supported.
Does anyone could help me?
Or maybe there is another way to achieve it?
Thank you.