function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Valentina ErmilovaValentina 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).
 
// 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;