Confluence 5.7 のサポートは終了しています。
ドキュメントの最新バージョンを確認してください。
This page provides information about 'advanced' PDF export customisations. These expand upon the regular customisations described in Customising Exports to PDF.
The information below is for advanced users. Customisations are not supported by Atlassian. Be aware that the advanced customisations described below require knowledge of certain parts of Confluence, and of CSS and HTML. This documentation is intended for advanced users. Some of the suggestions below are moderately complex, or irregular in nature. If you are having trouble understanding them we strongly suggest you ask an expert. We do not support any of the customisations described below. This means that the Atlassian support engineers will not be able to help you with these modifications.
単一ページをエクスポートする場合は、PDF レイアウト ページを使用した HTML ヘッダーとフッターの追加をサポートしていませんが、PDF スタイルシート ページ(スペースツール > ルックアンドフィール > PDFスタイルシート )の CSS ルールを使用すれば、単一ページをエクスポートする場合もヘッダーやフッターを作成できます。
カスタム ヘッダを作成するには、@page ルールに含まれる次のルールのいずれかを定義します: @top-left、@top-center,、@top-right。このルールを使用すると、ページのヘッダー領域の左側と中央、右側に表示する content をそれぞれ定義できます。
カスタム フッターについては、@page ルール内で @bottom-left、@bottom-center および @bottom-right ルールを定義します。
たとえば、次のルールは、ヘッダーの中央にドキュメントのタイトルを追加し、フッターの中央にページ番号を追加します。
@page
{
@top-center
{
content: "Document Title Goes Here"; /* This is the content that will appear in the header */
font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
font-size: 8pt;
}
@bottom-center
{
content: "Page " counter(page); /* This is the content that will appear in the footer */
font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
font-size: 8pt;
}
/* Any other page-specific rules */
}
font-family プロパティと font-size プロパティにより、初期設定の CSS ルールに基づいて、ヘッダーとフッターのテキストが本文と同じ初期設定のフォント スタイルでレンダリングされるようになります。ヘッダーまたはフッターに画像を挿入するには、PDF のレイアウト画面のヘッダーまたはフッターセクションに HTML を追加します。
次の例では、src 属性を持つ HTML img 要素を使用して、ヘッダーの左側に画像を追加します。src 属性は Confluence ページに添付された画像を指します。image 要素は、通常 div 要素のコンテナ内に配置されます。
<div style="margin-top: 10.0mm;">
<img src="https://confluence.atlassian.com/download/attachments/12346/header-image.png" />
</div>
src 属性の "12346" は、画像が添付されているページの ID 番号です。次の手順にしたがって、ページに画像を含めます。
src="" 属性へのリンクを PDF スタイルシートに貼り付けます。/download/... の前に来る最初の部分を除去し、相対 URL になるように編集します。メモ:
style 属性のインライン CSS プロパティである margin-top を使用して、画像がページの上部から 10 mm 離れるように設定しています。この設定は、ヘッダーの画像がページ上部に接したり、はみ出たりするほど大きい場合に便利です。margin-bottom:XXmm プロパティを使用して、画像がページ下部から "XX" mm 離れるように設定できます。@page CSS ルールの margin-top プロパティを設定します。style 属性に text-align:center または text-align:right プロパティのいずれかを追加することで、この画像をページの中央または右側に揃えることができます。たとえば、ヘッダー画像をページの右側に揃えるには、style 属性を次のように設定します: style="margin-top:10mm; text-align:right"。By default, Confluence provides Times New Roman, Helvetica or Courier fonts for use in PDF exports. You can use your own fonts for PDF exports by declaring them in a @font-face CSS rule in your PDF Stylesheet.
次の CSS ルールの例は、Consolas フォントを宣言して、PDF エクスポートの一部の要素に適用する方法を示しています。
@font-face { src: url(file:///usr/share/fonts/Consolas.ttf);-fs-pdf-font-embed: embed; } .codepre, .preformattedpre, tt, kbd, code, samp { font-family: Consolas, monospace; font-size: 9pt; }
Confluence から任意のページセットをエクスポートする場合、対応するタイトルを表紙(またはタイトル)ページに自動的に追加したいと考えるかもしれません。これは、既定の目次から最上位の項目をタイトルとして使用することによって(若干変則的な方法で)実現できます。この方法の可否は、エクスポートされたページが最上位ページのサブページという構造になっているかによります。すなわち、エクスポートされるページは(最上位の)ページ 1 枚とあとはすべて子ページという構成でなければなりません。表紙ページに表示されるタイトルは、エクスポートに使用される最上位ページによって変わるということになります。
以下の CSS では、表紙のタイトルとして使用するために最上位の目次を移動して、スタイル設定し、通常この目次項目に関連付けられるリーダーとページ番号をオフにしています。
.fsTitlePage { position:relative; left:0px; } /* この TOC アイテムの既定のセクションのナンバリングをオフにする */ .toclvl0:before { content: " "; counter-reset: chapter 0; } /* この TOC アイテムの既定のページのナンバリングを非表示にする */ .toclvl0 .tocnum { display: none; } /* この TOC アイテムの移動およびスタイル */ .toclvl0 { position:absolute; top:250px; font-size: 42px; font-weight: bold; margin: 72px 0 4px 0; text-align:center; }
このセクションでは、PDF エクスポートのテキストを非表示にする方法を説明します。すなわち、Confluence ページのテキストを PDFエクスポートでは非表示にできるということです。
手順は 3 つです。
指示にしたがって、NoPrint ユーザーマクロを定義します。
次の CSS を PDF スタイルシートに追加し、NoPrint マクロを PDF エクスポートに認識させます。
.noprint { display: none ; }
To obtain an index at the end of the exported PDF file, consider using the Scroll Wiki PDF Exporter plugin that is produced by K15t Software GmbH.
If styling is not working as expected, it is useful to look at the intermediary HTML source to which the CSS is applied. This intermediary HTML is created whenever you create an HTML export that contains multiple pages, and is stored in the temp directory in Confluence's home directory. For example:
/temp/htmlexport-20110308-154047-1/export-intermediate-154047-2.html