getContent()

Returns the output of the page, as displayed to a user in a web browser.

Signature

public Blob getContent()

Return Value

Type: Blob

Usage

The content of the returned Blob depends on how the page is rendered. If the page is rendered as a PDF file, it returns the PDF document. If the page is not rendered as PDF, it returns HTML. To access the content of the returned HTML as a string, use the toString Blob method.

Note

Note

If you use getContent in a test method, the test method fails. getContent is treated as a callout in API version 34.0 and later.

This method can’t be used in:
  • Triggers
  • Test methods
  • Apex email services

If the Visualforce page has an error, an ExecutionException is thrown.