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
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();