getContentAsPDF()
Returns the page in PDF, regardless of the <apex:page> component’s renderAs attribute.
public Blob getContentAsPDF()
Type: Blob
This method can’t be used in:
- Triggers
- Test methods. If you use
getContentAsPDFin a test method, the test method fails.getContentAsPDFis treated as a callout in API version 34.0 and later. - Apex email services
You also can’t use the method to retrieve the output of a different Visualforce page with the same controller and controller extensions. Instead, pass the base URL of the destination page. Here, VisualforcePageName is a placeholder value.