comparison mupdf-source/docs/tools/mutool-create.rst @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 mutool create
2 =============
3
4 The ``create`` command creates a new PDF file with the contents created from one or more input files containing graphics commands.
5
6 .. code-block:: bash
7
8 mutool create [-o output.pdf] [-O options] page.txt [page2.txt ...]
9
10 ``[-o output.pdf]``
11 The output filename. Defaults to "out.pdf" if not supplied.
12
13 ``[-O options]``
14 See :doc:`/reference/common/pdf-write-options`.
15
16 ``page.txt``
17 Files containing the contents of a page.
18
19 Content Streams
20 ---------------
21
22 A page is created for each input file, with the contents of the file copied into the content stream.
23
24 Special comments in the input files are parsed to define the page dimensions and to create font and image resources.
25
26 ``%%MediaBox LLX LLY URX URY``
27 Set the page size (default A4).
28
29 ``%%Rotate Angle``
30 Set the page rotation (default 90 degrees).
31
32 ``%%Font Name Filename Encoding``
33 - Create a simple font resource.
34 - The filename can be either a font file or one of the Base-14 font names (Times-Roman, etc).
35 - Encoding is one of Latin (for ISO-8859-1), Greek (for ISO-8859-7) or Cyrillic (for KOI-8).
36
37 ``%%CJKFont Name Language WMode Style Language``
38 - Create a CID font resource for CJK scripts.
39 - Language is one of zh-Hant, zh-Hans, ja, ko.
40 - Wmode is one of H or V.
41 - Style is serif or sans.
42
43 ``%%Image Name Filename``
44 Create an image resource.
45
46 Example #1
47 ~~~~~~~~~~
48
49 Define an image:
50
51 .. code-block::
52
53 %%MediaBox 0 0 500 800
54 %%Rotate 90
55 %%Image Im0 path/to/image.png
56
57 Example #2
58 ~~~~~~~~~~
59
60 Font resources can be created by either giving the name of a standard PDF font, or by giving the path to a font file. If a third argument is present and either "Greek" or "Cyrillic" the font will be encoded using ISO 8859-7 or KOI8-U, respectively:
61
62 .. code-block::
63
64 %%Font Tm Times-Roman
65 %%Font TmG Times-Roman Greek
66 %%Font TmC Times-Roman Cyrillic
67 %%Font Fn0 path/to/font/file.ttf
68 %%Font Fn1 path/to/font/file.ttf Cyrillic
69
70 Example #3
71 ~~~~~~~~~~
72
73 CJK fonts can be created by passing a language tag for one of the 4 CID orderings: zh-Hant, zh-Hans, ja, or ko (Traditional Chinese, Simplified Chinese, Japanese, Korean). The CJK font will use the UTF-16 encoding. A font file will not be embedded, so a PDF viewer will use a substitute font:
74
75 .. code-block::
76
77 %%CJKFont Batang ko
78 %%CJKFont Mincho ja
79 %%CJKFont Ming zh-Hant
80 %%CJKFont Song zh-Hans
81
82 Putting it all together
83 ~~~~~~~~~~~~~~~~~~~~~~~
84
85 An example input file, which adds an image, a triangle and some text:
86
87 .. code-block::
88
89 %%MediaBox 0 0 595 842
90 %%Font TmRm Times-Roman
91 %%Font Helv-C Helvetica Cyrillic
92 %%Font Helv-G Helvetica Greek
93 %%CJKFont Song zh-Hant
94 %%CJKFont Mincho ja
95 %%CJKFont Batang ko
96 %%Image I0 docs/examples/huntingofthesnark.png
97
98 % Draw an image.
99 q
100 480 0 0 480 50 250 cm
101 /I0 Do
102 Q
103
104 % Draw a triangle.
105 q
106 1 0 0 rg
107 50 50 m
108 100 200 l
109 200 50 l
110 f
111 Q
112
113 % Show some text.
114 q
115 0 0 1 rg
116 BT /TmRm 24 Tf 50 760 Td (Hello, world!) Tj ET
117 BT /Helv-C 24 Tf 50 730 Td <fac4d2c1d7d3d4d7d5cad4c521> Tj ET
118 BT /Helv-G 24 Tf 50 700 Td <eae1ebe7ecddf1e1> Tj ET
119 BT /Song 24 Tf 50 670 Td <4F60 597D> Tj ET
120 BT /Mincho 24 Tf 50 640 Td <3053 3093 306b 3061 306f> Tj ET
121 BT /Batang 24 Tf 50 610 Td <c548 b155 d558 c138 c694> Tj ET
122 Q