You need to sign in to do that
Don't have an account?
PageReference getContent, Documents, Blob
Hi everyone, I am facing an issue related to Documents, Blobs, and EncodingUtils.
I have the following code :
public void print(set<Id> factureSet) { list<Facture__c> listFacturesToPrint = [SELECT Id FROM Facture__c WHERE Id IN : factureSet ORDER BY Name ]; PageReference pageRef; String stringToBlob = ''; for(Facture__c f : listFacturesToPrint) { pageRef = Page.VFP02Facture; pageRef.getParameters().put('id', f.Id); stringToBlob += EncodingUtil.base64Encode(pageRef.getContent()); } Document d = new Document(); d.Name = 'my text file'; d.ContentType = 'application/pdf'; d.Type = 'pdf'; d.FolderId = '005b0000000ctCCAAY'; d.Body = EncodingUtil.base64Decode(stringToBlob); insert d; }
A set of Facture__c Id is passed to that function.
The page VFP02Facture is a Visualforce page which generates a PDF file, and takes the Facture__c object as a standard controller.
The purpose of the function is to create only one document which contains all the PDF files generated by VFP02Facture ; that is why I made the for loop.
Problem is I only got 1 PDF file in the document, the one which corresponds to the first item of the listFacturesToPrint list.
What do I do wrong ?
Thanks ;)
Hi,
You cannot add blob like that in apex or any language. Instead you can try to accumulate all your records in the same page and render it as PDF as you wish.
Regards,
Arun.
As a result, my VFPage does not take a recordSetVar, but only a single record, and I do not want to have 2 almost identically pages to do almost the same thing.