0

I have a requirement of attaching the Printable View of a standard detail page to the Attachments of a salesforce object.I have written code in developer console but the PDF saved is not opening.

 PageReference newPage = new PageReference('/0019000000LAanJ/p');
  blob blobFormPDF = newPage.getContent(); 


  attachment attach = new attachment();
  attach.ParentId = '0019000000LAanJ';
  attach.Name = 'test';
  attach.Body = blobFormPDF;

  insert attach;
1

Printable View is just an HTML page, it is not PDF format. You would need to write a Visualforce page to display all the desired sections and fields and render this as a PDF. See documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.