Confluence 3.4 のサポートは終了しています。
ドキュメントの最新バージョンを確認してください。
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. 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, because even for them this kind of configuration can be tricky.
This topic provides information and details on popular PDF stylesheet customisations. These expand upon the basic customisations described in Editing the PDF Stylesheet.
On this page:
Page Customisations
Modifications to page and margin properties are made in the @page Cascading Style Sheet (CSS) rule. As described in Editing the PDF Stylesheet, all CSS rule customisations are implemented in the space's PDF stylesheet.
Changing the Page Orientation to Landscape or Portrait
To change the page orientation of your PDF document, reverse the order of the values declared in the @page rule's size property. The first and second values of this property represent the width and height of the page, respectively.
たとえば、スペースの PDF エクスポートを A4 横向きで生成する場合、@page ルールは次のようになります。
@page
{
/*A4-sized pages in landscape orientation are 297 mm wide by 210 mm high*/
size: 297mm 210mm;
}
Customising Page Margins Separately
To set the margins of each side of a page independently of the other, you can declare each margin size in the @page rule using the following properties:
Properties |
説明 |
|---|---|
|
Margin height at the top of the page. |
|
Margin height at the bottom of the page. |
|
Margin width on the left of the page. |
|
Margin width on the right of the page. |
For example, to generate PDF space exports with top and bottom margins of 1 inch and left and right margins of half an inch, your @page rule might look like this:
@page
{
margin-top: 2.54cm;
margin-bottom: 2.54cm;
margin-left: 1.27cm;
margin-right: 1.27cm;
}
Page Header and Footer Customisations
単一ページのエクスポートにヘッダーとフッターを追加する
As mentioned in Editing the PDF Stylesheet, custom headers and footers by default, only apply to space export' and not to exports of single pages. However, it is possible to add CSS rules to your PDF export stylesheet that allow custom headers and footers to appear in single page exports.
For custom headers, define @top-left, @top-center and @top-right rules within your @page rule. These rules apply respectively to content that appears on the left-hand side, centre and right-hand side of your page's header area.
カスタム フッターについては、@page ルール内で @bottom-left、@bottom-center および @bottom-right ルールを定義します。
Add the following rules to add a document title at the centre of the header and a page number at the centre of the footer:
@page
/* Any page-specific properties */
{
@top-center
{
content: "Document Title Goes Here";
font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
font-size: 8pt;
}
@bottom-center
{
content: "Page " counter(page);
font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
font-size: 8pt;
}
/* Any other page-specific rules */
}
メモ:
font-familyプロパティとfont-sizeプロパティにより、初期設定の CSS ルールに基づいて、ヘッダーとフッターのテキストが本文と同じ初期設定のフォント スタイルでレンダリングされるようになります。- 単一ページのエクスポートで、(Confluence インスタンス内の添付ファイルとして保存されている)画像をヘッダーとフッターに挿入するために、この方法を使用することはできません。
ヘッダーとフッターに画像を追加する
To insert an image into a header or footer, edit the header and footer sections of the PDF layout and use an HTML img element with src attribute. The src attribute refers to an image attached to a Confluence page. The image element is usually placed within a div element container.
For example, to add an image to the left of the header:
<div style="margin-top:10mm"> <img src="/download/attachments/12346/header-image.png"/> </div>
In the example above, the header includes an image called 'header-image.png'. The image is attached to a Confluence page and is referenced via its relative URL (that is, we use only the last part of the URL, excluding the Confluence site's base URL).
Follow these instructions to include an image on your PDF title page:
- 画像を Confluence ページに添付します。
- そのページの添付ファイルのリストが表示されます。
- 画像を右クリックし、その保存場所をコピーします。
- 上記の通り、PDF スタイルシート内の適切な
src=""属性にリンクを貼り付けます。 - Remove the first part of the URL before the
/download/...part.
To add an image to a footer, add similar HTML code consisting of an img element and src attribute. Incorporate the inline CSS property margin-bottom to separate the image from the bottom of the page if necessary.
メモ:
- This code uses an inline CSS property in the
styleattribute to set formatting properties specific to this header image. - The
margin-top:10mmproperty forces the image away from the top of the page by 10mm. This comes in handy when your header image is large enough to touch or spill over the top of the page. - 同様に、フッターでは、
margin-bottom:XXmmプロパティを使用して、画像がページ下部から "XX" mm 離れるように設定できます。 - Very large images can spill over into the body of a page or alter the position of text or other elements used within a header or footer. In such situations, it is recommended that you reduce the size of the image and then upload it to your Confluence site again. If you prefer to keep the image size and want to move the content lower instead, you can do so by configuring the
margin-topproperties in the@pageCSS rule. - 初期設定では、ヘッダーまたはフッターの画像はページの左側に揃えられます。ただし、
style属性にtext-align:centerまたはtext-align:rightプロパティのいずれかを追加することで、この画像をページの中央または右側に揃えることができます。たとえば、ヘッダー画像をページの右側に揃えるには、style属性を次のように設定します:style="margin-top:10mm; text-align:right"。
Page Selector Rules for Left- and Right-Hand Pages
If your PDF exports are destined for double-sided printed media (for example, books), you can define different customisations for left- or right-hand pages.
To do this, define two CSS pseudo-class page selectors as separate rules within the PDF stylesheet.
- Use the
:leftpsuedo-class with the@pageCSS rule to define customisations for left-hand pages - Use the
:rightpsuedo-class with@pageto define customisations for right-hand pages.
You can use these page selector CSS rules in your PDF stylesheet to define alternating left and right margins to allow room for binding a double-sided document. For example:
@page :left {
margin-left: 3cm;
margin-right: 1.27cm;
/* Any other left-hand page-specific properties and rules */
}
@page :right {
margin-left: 1.27cm;
margin-right: 3cm;
/* Any other right-hand page-specific properties and rules */
}
他のフォントを組み込む
Out of the box, Confluence provides Times New Roman, Helvetica or Courier fonts for use in PDF exports. You can incorporate your own fonts for use in PDF exports by declaring them within a @font-face CSS rule within your PDF export stylesheet.
The following CSS rule example shows how to embed the Consolas font into your PDF export:
@font-face {
src: url(file:///usr/share/fonts/Consolas.ttf);
-fs-pdf-font-embed: embed;
}
.code pre, .preformatted pre, tt, kbd, code, samp {
font-family: Consolas, monospace;
font-size: 9pt;
}
CSS で指定したフォント パスは、Confluence サーバー上のフォントへのパスでなければなりません。
PDF 出力からテキストを隠す
このセクションでは、PDF エクスポートのテキストを非表示にする方法を説明します。すなわち、Confluence ページのテキストを PDFエクスポートでは非表示にできるということです。
There are two stages:
- 指示にしたがって、NoPrint ユーザーマクロを定義します。
- 次の CSS を PDF スタイルシートに追加し、NoPrint マクロを PDF エクスポートに認識させます。
.noprint { display: none ; }
