nerdexam
Salesforce

PDI · Question #224

Which code displays the contents of a Visualforce page as a PDF?

The correct answer is C. <apexipage renderAs="pdf">. To display the contents of a Visualforce page as a PDF document, the renderAs="pdf" attribute must be set on the <apex:page> tag.

Submitted by tyler.j· Apr 18, 2026User Interface

Question

Which code displays the contents of a Visualforce page as a PDF?

Options

  • A<apenipage contentType="pdf">
  • B<apex:page contentType="application/pd ">
  • C<apexipage renderAs="pdf">
  • D<apex:page renderAs="application/pdf">

How the community answered

(35 responses)
  • A
    6% (2)
  • B
    3% (1)
  • C
    89% (31)
  • D
    3% (1)

Why each option

To display the contents of a Visualforce page as a PDF document, the `renderAs="pdf"` attribute must be set on the `<apex:page>` tag.

A<apenipage contentType="pdf">

The `contentType` attribute is used to specify the MIME type of the page's response, not to trigger PDF rendering, and 'pdf' is not a valid MIME type for this attribute.

B<apex:page contentType="application/pd ">

While `application/pdf` is the correct MIME type for PDF, the `contentType` attribute alone does not convert the Visualforce page content into a PDF; it merely sets the HTTP header.

C<apexipage renderAs="pdf">Correct

The `renderAs` attribute on the `<apex:page>` component is specifically designed to control the output format of the Visualforce page, and setting `renderAs='pdf'` instructs Salesforce to render the page content as a PDF document.

D<apex:page renderAs="application/pdf">

The `renderAs` attribute expects a keyword like 'pdf', not a full MIME type; using `renderAs="application/pdf"` is incorrect syntax for this attribute.

Concept tested: Visualforce page rendering as PDF

Source: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_page.htm#pages_compref_page_attributes

Topics

#Visualforce#PDF Rendering#Page Attributes#UI Development

Community Discussion

No community discussion yet for this question.

Full PDI Practice