Comprehensive and Detailed Explanation From Exact Extract: A (Correct):The renderAs="application/pdf" attribute in the <apex:page> tag instructs the Visualforce page to render the content as a PDF file when accessed. Example: <apex:page renderAs="application/pdf"> <h1>Invoice</h1> </apex:page> Incorrect options: B:renderAs="pdf" is incorrect; the correct MIME type is application/pdf. C/D:contentType controls headers but doesn't render the content as PDF. Reference:Visualforce Developer Guide - Generating PDFs This is part of theUser Interface (25%)section of the exam, especially aroundVisualforce rendering and presentation logic.
最新のコメント (最新のコメントはトップにあります。)
正:B、、
Salesforceの公式ドキュメント(Visualforce 開発者ガイド)と照合し、再確認いたしました。
結論から申し上げますと、やはり **正解は B** です。
Salesforce Help(公式開発者ガイド)の記述に基づき、なぜ B が正しく、他が間違いなのかを根拠付きで解説します。
### 公式ドキュメントによる裏付け
Salesforce 公式ドキュメント「[apex:page | Visualforce 開発者ガイド](https://developer.salesforce.com/docs/atlas.ja-jp.pages.meta/pages/pages_compref_page.htm)」には、`<apex:page>` コンポーネントの `renderAs` 属性について以下のように定義されています。
> **属性名**: `renderAs`
> **型**: String
> **説明**: サポートされるコンテンツコンバーターの名前。現在、サポートされているコンテンツコンバーターは PDF のみです。**この属性を "pdf" に設定すると、ページが PDF として表示されます**。
また、「[PDF ファイルへのページの変換](https://developer.salesforce.com/docs/atlas.ja-jp.pages.meta/pages/pages_quick_start_renderas_pdf.htm)」のセクションでも、以下のコード例が示されています。
```html
<apex:page renderAs="pdf">
```
-----
### 各選択肢の再検証
**A. `<apex:page renderAs="application/pdf">`**
* **不正解(根拠):** 公式ガイドには「属性を **"pdf"** に設定すると」と明記されています。`application/pdf` は MIME タイプと呼ばれる形式で、`renderAs` 属性の値としては無効です。
**B. `<apex:page renderAs="pdf">`**
* **正解(根拠):** 公式ガイドの仕様およびサンプルコードと完全に一致します。これ記述することで、Salesforce サーバー側の PDF レンダリングエンジンが起動し、HTML を PDF バイナリに変換して返します。
**C. `<apex:page contentType="application/pdf">`**
* **不正解(根拠):** `contentType` 属性は、生成されるファイルの MIME タイプ(ブラウザがどう扱うかの指示)を設定するものです。これを設定しても、サーバー側で **PDF への変換処理(レンダリング)は行われません**。結果として、中身が HTML ソースのままの、壊れた PDF ファイルがダウンロードされることになります。
**D. `<apex:page contentType="pdf">`**
* **不正解(根拠):** `contentType` に指定する値は MIME タイプ(例: `text/html`, `application/vnd.ms-ex...