Visualforce PDF 表示の使用時に使用可能なフォント
Visualforce PDF 表示でサポートされるフォントのセットは限られています。PDF 出力を期待どおりに表示するには、サポートされているフォント名を使用してください。
各書体で最初に記載されている font-family 名が推奨値です。
| 書体 | font-family の値 |
|---|---|
| Arial Unicode MS |
|
| Helvetica |
|
| Times |
|
| Courier |
|
フォント表示のテスト
次のページを使用して、Visualforce PDF 表示エンジンでフォント表示をテストできます。
1<apex:page showHeader="false" standardStylesheets="false"
2 controller="SaveToPDF" renderAs="{! renderAs }">
3
4<apex:form rendered="{! renderAs != 'PDF' }" style="text-align: right; margin: 10px;">
5 <div><apex:commandLink action="{! print }" value="Save to PDF"/></div>
6 <hr/>
7</apex:form>
8
9<h1>PDF Fonts Test Page</h1>
10
11<p>This text, which has no styles applied, is styled in the default font for the
12 Visualforce PDF rendering engine.</p>
13
14<p>The fonts available when rendering a page as a PDF are as follows. The first
15listed <code>font-family</code> value for each typeface is the recommended choice.</p>
16
17<table border="1" cellpadding="6">
18<tr><th>Font Name</th><th>Style <code>font-family</code> Value to Use (Synonyms)</th></tr>
19<tr><td><span style="font-family: Arial Unicode MS; font-size: 14pt; ">Arial
20 Unicode MS</span></td><td><ul>
21 <li><span style="font-family: Arial Unicode MS; font-size: 14pt;">Arial Unicode MS</span></li>
22 </ul></td></tr>
23<tr><td><span style="font-family: Helvetica; font-size: 14pt;">Helvetica</span></td>
24 <td><ul>
25 <li><span style="font-family: sans-serif; font-size: 14pt;">sans-serif</span></li>
26 <li><span style="font-family: SansSerif; font-size: 14pt;">SansSerif</span></li>
27 <li><span style="font-family: Dialog; font-size: 14pt;">Dialog</span></li>
28 </ul></td></tr>
29<tr><td><span style="font-family: Times; font-size: 14pt;">Times</span></td><td><ul>
30 <li><span style="font-family: serif; font-size: 14pt;">serif</span></li>
31 <li><span style="font-family: Times; font-size: 14pt;">Times</span></li>
32</ul></td></tr>
33<tr><td><span style="font-family: Courier; font-size: 14pt;">Courier</span></td>
34 <td><ul>
35 <li><span style="font-family: monospace; font-size: 14pt;">monospace</span></li>
36 <li><span style="font-family: Courier; font-size: 14pt;">Courier</span></li>
37 <li><span style="font-family: Monospaced; font-size: 14pt;">Monospaced</span></li>
38 <li><span style="font-family: DialogInput; font-size: 14pt;">DialogInput</span></li>
39</ul></td></tr>
40</table>
41
42<p><strong>Notes:</strong>
43<ul>
44<li>These rules apply to server-side PDF rendering. You might see different results
45 when viewing this page in a web browser.</li>
46<li>Text styled with any value besides those listed above receives the default font
47 style, Times. This means that, ironically, while Helvetica's synonyms render as
48 Helvetica, using "Helvetica" for the font-family style renders as Times.
49 We recommend using "sans-serif".</li>
50<li>Arial Unicode MS is the only multibyte font available, providing support for the
51 extended character sets of languages that don't use the Latin character set.</li>
52</ul>
53</p>
54
55</apex:page>上述のページでは、単純な「PDF に保存」機能を提供する次のコントローラーを使用します。
1public with sharing class SaveToPDF {
2
3 // Determines whether page is rendered as a PDF or just displayed as HTML
4 public String renderAs { get; set; }
5
6
7 // Action method to "print" to PDF
8 public PageReference print() {
9 renderAs = 'PDF';
10 return null;
11 }
12
13}