---
schema_version: "1"
id: 1c058818f27f59bb87e3a77bd1634ce1a0acbf8d86faf450c2ef05d426687ab1
title: getContentAsPDF()
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_System_PageReference_getContentAsPDF.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getContentAsPDF.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 03e2042594db3c9d837f81deb80ac20dc699d7b09285d5758d81b6ab122bf6a7
description: Returns the page in PDF, regardless of the <apex:page> component’s renderAs attribute.
---
# getContentAsPDF()

Returns the page in PDF, regardless of the <apex:page\> component’s renderAs attribute.

## Signature

public Blob getContentAsPDF()

## Return Value

Type: [Blob](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_blob.htm#apex_methods_system_blob "Contains methods for the Blob primitive data type.")

## Usage

This method can’t be used in:

- Triggers
- Test methods. If you use getContentAsPDF in a test method, the test method fails. getContentAsPDF is 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.

new PageReference(Site.getBaseUrl() + '/apex/VisualforcePageName').getContentAsPDF();