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 is dependent on how the page is rendered. If the page is rendered as a PDF, it returns the PDF. If the page is not rendered as a PDF, it returns the 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, a blank PDF is generated when used with a Visualforce page that is supposed to render as PDF.

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

If there’s an error on the Visualforce page, an ExecutionException is thrown.

Previous
Next