styles.txt 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. ====================
  2. PDF style directives
  3. ====================
  4. The PDF rendering of the document component supports a list of style
  5. directives to customize the output. Most style directives are equivalent to
  6. the CSS directives used for HTML and XML, but there are some additional
  7. directives and not all CSS directives are supported.
  8. The selectors, which can be used are documented in the tutorial__. Currently
  9. all values are required to be escaped inside quotes ("). The full grammar
  10. looks like::
  11. File ::= Directive+
  12. Directive ::= Address '{' Formatting* '}'
  13. Formatting ::= Name ':' '"' Value '"' ';'
  14. Name ::= [A-Za-z-]+
  15. Value ::= [^"]+
  16. Address ::= Element ( Rule )*
  17. Rule ::= '>'? Element
  18. Element ::= ElementName ( '.' ClassName | '#' ElementId )
  19. ClassName ::= [A-Za-z_-]+
  20. ElementName ::= XMLName | '*'
  21. ElementId ::= XMLName
  22. XMLName references to http://www.w3.org/TR/REC-xml/#NT-Name
  23. __ /docs/tutorials/Document#styling-the-pdf
  24. .. contents:: Table of Contents
  25. :depth: 2
  26. All values, given as "measure" accept different units, but always default to
  27. millimeters (mm). Possible units are:
  28. - "mm", Millimeters, the default measure, if none is specified
  29. - "pt", Points, 72 points per inch
  30. - "px", Pixel, depends on the set resolution, by default also 72 points per
  31. inch
  32. - "in", Inch
  33. The unit "Points" is most common for font sizes, while millimeters or inches
  34. will probably more useful for page margins and paddings. You are free to
  35. choose any of them and can even combine different units in one tuple, like::
  36. para {
  37. // Top margin: 12 mm; Right margin: .1 inch; Bottom margin: 10 points,
  38. // Left margin: 1 pixel
  39. margin: "12 .1in 10pt 1px";
  40. }
  41. Font style
  42. ==========
  43. font-size: <measure>
  44. --------------------
  45. Defines the font size of the text. Most common unit is points, so it can be
  46. used like::
  47. para {
  48. font-size: "12pt";
  49. }
  50. font-family: <name>
  51. -------------------
  52. Defines the font used to render the text. Currently only the default PDF fonts
  53. are supported, which are:
  54. - ``serif``
  55. - ``sans-serif``
  56. - ``monospace``
  57. - ``Symbol``
  58. - ``ZapfDingbats``
  59. The option can be used like::
  60. para {
  61. font-family: "sans-serif";
  62. }
  63. font-weight: <weight>
  64. ---------------------
  65. The font weight defines whether a font is printed bold or normal. Unlike CSS
  66. for now only two possible values are supported: ``bold`` and ``normal``.
  67. Some drivers might support additional values, though. Usage::
  68. emphasis {
  69. font-weight: "bold";
  70. }
  71. font-style: <style>
  72. -------------------
  73. The font style property defines the style of the printed text. The possible
  74. values are ``normal`` and ``italic``. Usage::
  75. emphasis {
  76. font-style: "italic";
  77. }
  78. Text style
  79. ==========
  80. text-align: <align>
  81. -------------------
  82. The text alignment defines the alignment of text inside a text block. The
  83. supported values are:
  84. - ``left``
  85. - ``right``
  86. - ``center``
  87. - ``justified``
  88. It can be used like::
  89. para {
  90. text-align: "justified";
  91. }
  92. If you are using justified text alignment you should also configure a
  93. meaningful hyphenator__.
  94. __ /docs/tutorials/Document#hyphenating
  95. line-height: <float>
  96. --------------------
  97. The line height configures the space between two lines in the rendered output.
  98. A line height of 1.4 is generally considered most readable. You can configure
  99. a different line height, like::
  100. para {
  101. line-height: "1.2";
  102. }
  103. Text rendering
  104. ==============
  105. text-columns: <int>
  106. -------------------
  107. Number of text columns printed on one page. Obviously not available in common
  108. CSS. Usage::
  109. article {
  110. text-columns: "2";
  111. }
  112. text-column-spacing: <measure>
  113. ------------------------------
  114. Spacing between text columns, defined as a common measure. Usage::
  115. article {
  116. text-column-spacing: "10mm";
  117. }
  118. orphans: <int>
  119. --------------
  120. Orphans__ are the dangling lines at the end of a page. This settings
  121. configures how many dangling lines are considered orphans and therefore moved
  122. to the next page. Set to 0 for no line moving. Usage::
  123. article {
  124. orphans: "3";
  125. }
  126. __ http://en.wikipedia.org/wiki/Widows_and_orphans
  127. widows: <int>
  128. -------------
  129. Widows__ are the dangling lines at the beginning of a page from a paragraph of
  130. the page before. This setting configures how many lines a page should at least
  131. contain, so that the lines are not considered widows any more and no
  132. additional lines are required to be shifted from the page before. Usage::
  133. article {
  134. widows: "3";
  135. }
  136. __ http://en.wikipedia.org/wiki/Widows_and_orphans
  137. Page style
  138. ==========
  139. page-size: <size>
  140. -----------------
  141. Defines the size of pages. Uses a number of common page size identifiers as
  142. valid values for size definitions, which are: A0, A1, A2, A3, A4, A5, A6, A7,
  143. A8, A9, A10, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, C0, C1, C2, C3, C4,
  144. C5, C6, C7, C8, C9, C10, RA0, RA1, RA2, RA3, RA4, SRA0, SRA1, SRA2, SRA3,
  145. SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO. This setting applies only to the
  146. virtual ``page`` element, like::
  147. page {
  148. page-size: "A4";
  149. }
  150. page-orientation: <orientation>
  151. -------------------------------
  152. Defines the orientation of a page. There are only two valid values for this
  153. setting: ``landscape`` and ``portrait``. This setting applies only to the
  154. virtual ``page`` element, like::
  155. page {
  156. page-orientation: "portrait";
  157. }
  158. Block level styles
  159. ==================
  160. There are some style options, which apply to all block level elements, like
  161. paragraphs, titles, pages, images, etc.
  162. margin: <measure> [<measure> [<measure> [<measure> ]]]
  163. ------------------------------------------------------
  164. Margin defines the outer space of some element. Like in CSS the number of
  165. values defines the meaning of the values. The meanings are:
  166. 1 value
  167. Used for top, right, bottom and left margin.
  168. 2 values
  169. First value is used for top and bottom margin, second is used for left and
  170. right margin.
  171. 3 values
  172. First value is used for top margin, second is used for left and right
  173. margin, the third is used for bottom margin.
  174. 4 values
  175. First value defines the top, second the right, third the bottom, and
  176. fourth the left margin.
  177. Different units may be combined, like::
  178. para {
  179. // Top margin: 12 mm; Right margin: .1 inch; Bottom margin: 10 points,
  180. // Left margin: 1 pixel
  181. margin: "12 .1in 10pt 1px";
  182. }
  183. padding: <measure> [<measure> [<measure> [<measure> ]]]
  184. -------------------------------------------------------
  185. Padding defines additional inner space inside of the borders of an element.
  186. The values are defined just like for margins. Usage::
  187. para {
  188. padding: "12 1px";
  189. }