PDI practice question 12 of 30

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

Full set: 201 questions
Answer options
A:

A. <apex:page contentTyp«-"applicaticn/pdf''>

B:

B. <apex:page contentType»"pdf">

C:

C. <apex:page renderAs-wpdf">

Correct answer
D:

D. <apex:page renderAs=''application/pdf''>

Correct Answer:
C. C. <apex:page renderAs-wpdf">
Explanation

The component's renderAs attribute is used to change the rendering service and output format of a Visualforce page. To generate a PDF document, the value of this attribute must be set to "pdf". This instructs the Salesforce platform to process the Visualforce markup and render it as a PDF file instead of the default HTML. The contentType attribute is used to specify the MIME type, but renderAs is the designated attribute for this transformation.

Why Incorrect

A. The contentType attribute specifies the MIME type, but renderAs is the correct attribute to invoke the PDF rendering service.
B. The contentType attribute requires a valid MIME type. "pdf" is not a valid MIME type; "application/pdf" is.
D. The renderAs attribute accepts specific keywords (like "pdf", "xls", "doc"), not full MIME type strings like "application/pdf".

References

1. Salesforce Visualforce Developer Guide: In the component reference, the renderAs attribute is described. It states, "The rendering service to use for the page... Possible values are: pdf, doc, xls, xml, csv." This directly supports the use of renderAs="pdf".

Source: Visualforce Developer Guide, Component Reference, , renderAs attribute description.

2. Salesforce Trailhead: The "Visualforce Basics" module explains how to create Visualforce pages. The specific unit on "Creating a PDF from a Visualforce Page" demonstrates the use of .

Source: Trailhead, Visualforce Basics, "Generate PDFs and Emails".

Scroll to Top