You need to sign in to do that
Don't have an account?
Valentina Ermilova
How to automatically save external pdf as attachment if getContentAsPDF don't see URL parameters
Hi,
I am trying to automatically save external pdf like this as attachment to object.
Code below solve this problem but pdf in attachment is not pdf by link. It render page without url parameters.
So instead pdf of this page (with parameters) I get pdf of this (without parameters).
I am trying to automatically save external pdf like this as attachment to object.
Code below solve this problem but pdf in attachment is not pdf by link. It render page without url parameters.
So instead pdf of this page (with parameters) I get pdf of this (without parameters).
// set URL PageReference pdf = new PageReference('http://api.pdflayer.com/api/convert'); // set parameters pdf.getParameters().put('access_key','5f9cb183f80d9d7a9b9fe3e848c06cf9'); pdf.getParameters().put('document_url','https%3A%2F%2Fgoogle.com'); // render PDF Blob b = pdf.getContentAsPDF(); // create object Test_object__c tst = new Test_object__c(Name='dTest'); insert tst; // create attachment for object Attachment att=new Attachment(); att.Body=b; att.Name='Report_' + System.now().format('dd.MM.yyyy') + '.pdf'; att.parentId=tst.id; insert att;