I have a visualforce page that renders as a pdf. Is there any way in apex to get that page data as a blob? I've thought about doing an Http GET request, but I feel like there should be a more direct way to get the page's blob data in my apex class.

1 Answer 1


You can use any of the PageReference methods. The most straightforward would be:

Blob pdfData = Page.myPageName.getContent();

Note that this technically still counts as a callout (meaning, you cannot use DML before calling it), but is far shorter than any other solution.

If this should be dynamic:

Blob pdfData = new PageReference('/apex/myPageName').getContent();
  • Wonderful, thanks!
    – Tyler Zika
    Mar 28, 2019 at 7:25

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.