You need to sign in to do that
Don't have an account?
Liron Cohen
Open PDF & save it as attachment
Hi.
I want to generate PDF document & save it as attachment under the related record (at the same function).
Is that mean I need to generate the PDF twice?
e.g.:
public Pagereference openAndAttach(){
PageReference documentPage = new PageReference('apex/myDoc?id='+recId);
//Create Attachment
Blob b = documentPage.getContect();
Attachment attach = new Attachment();
attach.Body = b;
attach.ParentId = recId;
insert attach;
//Open PDF
return documentPage;
}
Is there a better way for doing this? It seems like wasting as the code generating the PDF.
I want to generate PDF document & save it as attachment under the related record (at the same function).
Is that mean I need to generate the PDF twice?
e.g.:
public Pagereference openAndAttach(){
PageReference documentPage = new PageReference('apex/myDoc?id='+recId);
//Create Attachment
Blob b = documentPage.getContect();
Attachment attach = new Attachment();
attach.Body = b;
attach.ParentId = recId;
insert attach;
//Open PDF
return documentPage;
}
Is there a better way for doing this? It seems like wasting as the code generating the PDF.