<!DOCTYPE html>
<html>
<head>
<title>mutool create</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>

<header>
<h1>mutool create</h1>
</header>

<nav>
<a href="http://mupdf.com/index.html">About</a>
<a href="http://mupdf.com/news.html">News</a>
<a href="index.html">Documentation</a>
<a href="http://mupdf.com/downloads/">Downloads</a>
<a href="http://git.ghostscript.com/?p=mupdf.git;a=summary">Source</a>
<a href="https://bugs.ghostscript.com/">Bugs</a>
</nav>

<article>

<p>
The create command creates a new PDF file with the contents created
from one or more input files containing graphics commands.

<pre>
mutool create [-o output.pdf] [-O options] page1.txt [page2.txt ...]
</pre>

<p>
If no output file is specified, it will write the created PDF to "out.pdf" in the current directory.

<p>
The -O argument is a comma separated list of options for writing the PDF file:

<dl>
<dt> decompress
<dd> Decompress all object streams.

<dt> compress
<dd> Compress all object streams.

<dt> compress-fonts
<dd> Compress object streams for embedded fonts.

<dt> compress-images
<dd> Compress object streams for images.

<dt> ascii
<dd> Encode object streams using ASCII hex encoding.

<dt> pretty
<dd> Pretty-print objects with indentation.

<dt> linearize
<dd> Optimize document for progressive loading in viewers.

<dt> sanitize
<dd> Clean up graphics command in content streams.

<dt> garbage[=compact|deduplicate]
<dd> Garbage collect unused objects. With compact the cross-reference
table will also be compacted. With deduplicate duplicate objects
will also be recombined.
</dl>

<p>
A page is created for each input file, with the contents of the
file copied into the content stream. Special comments in the
input files are parsed to define the page dimensions and font
and image resources:

<pre>
%%MediaBox 0 0 500 800
%%Rotate 90
%%Image Im0 path/to/image.png
</pre>

<p>
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.

<pre>
%%Font Tm Times-Roman
%%Font TmG Times-Roman Greek
%%Font TmC Times-Roman Cyrillic
%%Font Fn0 path/to/font/file.ttf
%%Font Fn1 path/to/font/file.ttf Cyrillic
</pre>

<p>
CJK fonts can also be created by passing a code for one of the 4 CID orderings:
CN, TW, JP, or KR (Simplified Chinese, Traditional Chinese, Japanese, and Korean).
A font file will not be embedded, so a PDF viewer will use a substitute font.

<pre>
%%CJKFont Batang KR
%%CJKFont Mincho JP
%%CJKFont Ming TW
%%CJKFont Song CN
</pre>

<p>
An example input file:

<pre>
%%MediaBox 0 0 595 842
%%Font TmRm Times-Roman
%%Font Helv-C Helvetica Cyrillic
%%Font Helv-G Helvetica Greek
%%CJKFont Song CN
%%CJKFont Mincho JP
%%CJKFont Batang KR
%%Image I0 logo/mupdf-simplified-logo.png

% Draw an image.
q
480 0 0 480 50 250 cm
/I0 Do
Q

% Draw a triangle.
q
1 0 0 rg
50 50 m
100 200 l
200 50 l
f
Q

% Show some text.
q
0 0 1 rg
BT /TmRm 24 Tf 50 760 Td (Hello, world!) Tj ET
BT /Helv-C 24 Tf 50 730 Td <fac4d2c1d7d3d4d7d5cad4c521> Tj ET
BT /Helv-G 24 Tf 50 700 Td <eae1ebe7ecddf1e1> Tj ET
BT /Song 24 Tf 50 670 Td <4F60 597D> Tj ET
BT /Mincho 24 Tf 50 640 Td <3053 3093 306b 3061 306f> Tj ET
BT /Batang 24 Tf 50 610 Td <c548 b155 d558 c138 c694> Tj ET
Q
</pre>

</article>

<footer>
<a href="http://artifex.com"><img src="artifex-logo.png" align="right"></a>
Copyright &copy; 2006-2017 Artifex Software Inc.
</footer>

</body>
</html>
