{"route":"/en-US-v0.14.1/reference/pdf/","title":"PDF","description":"Documentation for functions related to PDF in Typst.","part":"Export","outline":[{"id":"summary","name":"Summary","children":[]},{"id":"exporting-as-pdf","name":"Exporting as PDF","children":[{"id":"command-line","name":"Command Line","children":[]},{"id":"web-app","name":"Web App","children":[]}]},{"id":"pdf-standards","name":"PDF standards","children":[{"id":"pdf-versions","name":"PDF versions","children":[]},{"id":"pdf-ua","name":"PDF/UA","children":[]},{"id":"pdf-a","name":"PDF/A","children":[]}]},{"id":"pdf-specific-functionality","name":"PDF-specific functionality","children":[]},{"id":"definitions","name":"Definitions","children":[]}],"body":{"kind":"category","content":{"name":"pdf","title":"PDF","details":"<p>PDF files focus on accurately describing documents visually, but also have\nfacilities for annotating their structure. This hybrid approach makes\nthem a good fit for document exchange: They render exactly the same on every\ndevice, but also support extraction of a document's content and structure (at\nleast to an extent). Unlike PNG files, PDFs are not bound to a specific\nresolution. Hence, you can view them at any size without incurring a loss of\nquality.</p>\n<h2 id=\"exporting-as-pdf\">Exporting as PDF</h2>\n<h3 id=\"command-line\">Command Line</h3>\n<p>PDF is Typst's default export format. Running the <code>compile</code> or <code>watch</code>\nsubcommand without specifying a format will create a PDF. When exporting to PDF,\nyou have the following configuration options:</p>\n<ul>\n<li>\n<p>Which <a href=\"#pdf-standards\">PDF standards</a> Typst should enforce conformance with by\nspecifying <code>--pdf-standard</code> followed by one or multiple comma-separated\nstandards. Valid standards are <code>1.4</code>, <code>1.5</code>, <code>1.6</code>, <code>1.7</code>, <code>2.0</code>, <code>a-1b</code>,\n<code>a-1a</code>, <code>a-2b</code>, <code>a-2u</code>, <code>a-2a</code>, <code>a-3b</code>, <code>a-3u</code>, <code>a-3a</code>, <code>a-4</code>, <code>a-4f</code>, <code>a-4e</code>,\nand <code>ua-1</code>. By default, Typst outputs PDF-1.7-compliant files.</p>\n</li>\n<li>\n<p>You can disable PDF tagging completely with <code>--no-pdf-tags</code>. By default, Typst\nwill always write <em>Tagged PDF</em> to provide a baseline level of accessibility.\nUsing this flag, you can turn tags off. This will make your file inaccessible\nand prevent conformance with accessible conformance levels of PDF/A and all\nparts of PDF/UA.</p>\n</li>\n<li>\n<p>Which pages to export by specifying <code>--pages</code> followed by a comma-separated\nlist of numbers or dash-separated number ranges. Ranges can be half-open.\nExample: <code>2,3,7-9,11-</code>.</p>\n</li>\n</ul>\n<h3 id=\"web-app\">Web App</h3>\n<p>Click the quick download button at the top right to export a PDF with default\nsettings. For further configuration, click &quot;File&quot; &gt; &quot;Export as&quot; &gt; &quot;PDF&quot; or click\nthe downwards-facing arrow next to the quick download button and select &quot;Export\nas PDF&quot;. When exporting to PDF, you have the following configuration options:</p>\n<ul>\n<li>\n<p>Which PDF standards Typst should enforce conformance with. By default, Typst\noutputs PDF-1.7-compliant files. You can choose the PDF version freely between\n1.4 and 2.0. Valid additional standards are <code>A-1b</code>, <code>A-1a</code>, <code>A-2b</code>, <code>A-2u</code>,\n<code>A-2a</code>, <code>A-3b</code>. <code>A-3u</code>, <code>A-3a</code>, <code>A-4</code>, <code>A-4f</code>, <code>A-4e</code>, and <code>UA-1</code>.</p>\n</li>\n<li>\n<p>Which pages to export. Valid options are &quot;All pages&quot;, &quot;Current page&quot;, and\n&quot;Custom ranges&quot;. Custom ranges are a comma-separated list of numbers or\ndash-separated number ranges. Ranges can be half-open. Example: <code>2,3,7-9,11-</code>.</p>\n</li>\n</ul>\n<h2 id=\"pdf-standards\">PDF standards</h2>\n<p>The International Standards Organization (ISO) has published the base PDF\nstandard and various standards that extend it to make PDFs more suitable for\nspecific use-cases. By default, Typst exports PDF 1.7 files. Adobe Acrobat 8 and\nlater as well as all other commonly used PDF viewers are compatible with this\nPDF version.</p>\n<p>Some features of Typst may not be available depending on the PDF standard you\nchoose. You currently cannot choose both PDF/A and PDF/UA at the same time.</p>\n<h3 id=\"pdf-versions\">PDF versions</h3>\n<p>Typst supports five different PDF versions: 1.4, 1.5, 1.6, 1.7 (default), and\n2.0. You can choose each of these versions for your document export. However,\nbased on the features you used there may be a minimum version. Likewise, the\nstandards you target can limit which versions you can choose (see below for\nmore).</p>\n<p>Here is a list on how each new version improves over PDF 1.4 for Typst\ndocuments:</p>\n<ul>\n<li><strong>PDF 1.5</strong> (2003): Improved color management, text extraction, table\naccessibility, reflow, and emoji fonts</li>\n<li><strong>PDF 1.6</strong> (2004): More flexible links</li>\n<li><strong>PDF 1.7</strong> (2006): Allows <a href=\"/en-US-v0.14.1/reference/pdf/attach/\">attachments</a>, improved reflow</li>\n<li><strong>PDF 2.0</strong> (2017): Improved both metadata and tag semantics for accessibility</li>\n</ul>\n<p>The software used to read your file must support your PDF version. Under normal\ncircumstances, this poses no problem, but it can be a source of errors when\nworking with older hardware. For general exchange, we recommend keeping the\ndefault PDF 1.7 setting or choosing PDF 2.0.</p>\n<p>When using PDF files as <a href=\"/en-US-v0.14.1/reference/visualize/image/\">images</a> in your document, the export PDF\nversion must equal or exceed the image file versions.</p>\n<h3 id=\"pdf-ua\">PDF/UA</h3>\n<p>Typst supports writing PDF/UA-conformant files. PDF/UA files are designed\nfor <em><a href=\"/en-US-v0.14.1/guides/accessibility/#basics\">Universal Access</a>.</em> When you choose this PDF\nstandard, Typst will run additional checks when exporting your document. These\nchecks will make sure that you are following accessibility best practices. For\nexample, it will make sure that all your images come with alternative\ndescriptions.</p>\n<p>Note that there are some rules in PDF/UA that are crucial for accessibility but\ncannot be automatically checked. Hence, when exporting a PDF/UA-1 document, make\nsure you did the following:</p>\n<ul>\n<li>If your document is written in a different language than English, make sure\n<a href=\"/en-US-v0.14.1/reference/text/text/#parameters-lang\">set the text language</a> before any content.</li>\n<li>Make sure to use Typst's semantic elements (like <a href=\"/en-US-v0.14.1/reference/model/heading/\">headings</a>,\n<a href=\"/en-US-v0.14.1/reference/model/figure/\">figures</a>, and <a href=\"/en-US-v0.14.1/reference/model/list/\">lists</a>) when appropriate instead of defining\ncustom constructs. This lets Typst know (and export) the role a construct\nplays in the document. See <a href=\"/en-US-v0.14.1/guides/accessibility/\">the Accessibility guide</a>\nfor more details.</li>\n<li>Do not exclusively use contrast, color, format, or layout to communicate an\nidea. Use text or alternative descriptions instead of or in addition to these\nelements.</li>\n<li>Wrap all decorative elements without a semantic meaning in <a href=\"/en-US-v0.14.1/reference/pdf/artifact/\" title=\"`pdf.artifact`\"><code>pdf.artifact</code></a>.</li>\n<li>Do not use images of text. Instead, insert the text directly into your markup.</li>\n</ul>\n<p>Typst currently only supports part one (PDF/UA-1) which is based on PDF 1.7\n(2006). When exporting to PDF/UA-1, be aware that you will need to manually\nprovide <a href=\"/en-US-v0.14.1/reference/math/#accessibility\">alternative descriptions of mathematics</a>\nin natural language.</p>\n<p>New accessibility features were added to PDF 2.0 (2017). When set to PDF 2.0\nexport, Typst will leverage some of these features. PDF 2.0 and PDF/UA-1,\nhowever, are mutually incompatible. For accessible documents, we currently\nrecommend exporting to PDF/UA-1 instead of PDF 2.0 for the additional checks and\ngreater compatibility. The second part of PDF/UA is designed for PDF 2.0, but\nnot yet supported by Typst.</p>\n<h3 id=\"pdf-a\">PDF/A</h3>\n<p>Typst optionally supports emitting PDF/A-conformant files. PDF/A files are\ngeared towards maximum compatibility with current and future PDF tooling. They\ndo not rely on difficult-to-implement or proprietary features and contain\nexhaustive metadata. This makes them suitable for long-term archival.</p>\n<p>The PDF/A Standard has multiple versions (<em>parts</em> in ISO terminology) and most\nparts have multiple profiles that indicate the file's conformance level. You can\ntarget one part and conformance level at a time. Currently, Typst supports these\nPDF/A output profiles:</p>\n<ul>\n<li>\n<p><strong>PDF/A-1b:</strong> The <em>basic</em> conformance level of ISO 19005-1. This version of\nPDF/A is based on PDF 1.4 (2001) and results in self-contained, archivable PDF\nfiles. As opposed to later parts of the PDF/A standard, transparency is not\nallowed in PDF/A-1 files.</p>\n</li>\n<li>\n<p><strong>PDF/A-1a:</strong> This is the <em>accessible</em> conformance level that builds on the\nbasic level PDF/A-1b. To conform to this level, your file must be an\naccessible <em>Tagged PDF</em> file. Note that accessibility is improved with later\nparts as not all PDF accessibility features are available for PDF 1.4 files.\nFurthermore, all text in the file must consist of known Unicode code points.</p>\n</li>\n<li>\n<p><strong>PDF/A-2b:</strong> The <em>basic</em> conformance level of ISO 19005-2. This version of\nPDF/A is based on PDF 1.7 (2006) and results in self-contained, archivable PDF\nfiles.</p>\n</li>\n<li>\n<p><strong>PDF/A-2u:</strong> This is the <em>Unicode-mappable</em> conformance level that builds on\nthe basic level A-2b. It also adds rules that all text in the document must\nconsist of known Unicode code points. If possible, always prefer this standard\nover PDF/A-2b.</p>\n</li>\n<li>\n<p><strong>PDF/A-2a:</strong> This is the <em>accessible</em> conformance level that builds on the\nUnicode-mappable level A-2u. This conformance level also adds two\nrequirements: Your file must be an accessible <em>Tagged PDF</em> file. Typst\nautomatically adds tags to help you reach this conformance level. Also pay\nattention to the Accessibility Sections throughout the reference and the\n<a href=\"/en-US-v0.14.1/guides/accessibility/\">Accessibility Guide</a> when targeting this conformance\nlevel. Finally, PDF/A-2a forbids you from using code points in the <a href=\"https://en.wikipedia.org/wiki/Private_Use_Areas\">Unicode\nPrivate Use area</a>. If you\nwant to build an accessible file, also consider additionally targeting\nPDF/UA-1, which enables more automatic accessibility checks.</p>\n</li>\n<li>\n<p><strong>PDF/A-3b:</strong> The <em>basic</em> conformance level of ISO 19005-3. This version of\nPDF/A is based on PDF 1.7 (2006) and results in archivable PDF files that can\ncontain arbitrary other related files as <a href=\"/en-US-v0.14.1/reference/pdf/attach/\">attachments</a>. The only\ndifference between it and PDF/A-2b is the capability to attach\nnon-PDF/A-conformant files.</p>\n</li>\n<li>\n<p><strong>PDF/A-3u:</strong> This is the <em>Unicode-mappable</em> conformance level that builds on\nthe basic level A-3b. Just like PDF/A-2b, this requires all text to consist\nof known Unicode code points. These rules do not apply to attachments. If\npossible, always prefer this standard over PDF/A-3b.</p>\n</li>\n<li>\n<p><strong>PDF/A-3a:</strong> This is the <em>accessible</em> conformance level that builds on the\nUnicode-mappable level A-3u. Just like PDF/A-2a, this requires files to be\naccessible <em>Tagged PDF</em> and to not use characters from the Unicode Private Use\narea. Just like before, these rules do not apply to attachments.</p>\n</li>\n<li>\n<p><strong>PDF/A-4:</strong> The basic conformance level of ISO 19005-4. This version of PDF/A\nis based on PDF 2.0 (2017) and results in self-contained, archivable PDF\nfiles. PDF/A-4 has no parts relating to accessibility. Instead, the topic has\nbeen elaborated on more in the dedicated PDF/UA standard. PDF/A-4 files can\nconform to PDF/UA-2 (currently not supported in Typst).</p>\n</li>\n<li>\n<p><strong>PDF/A-4f:</strong> The <em>embedded files</em> conformance level that builds on the basic\nlevel A-4. Files conforming to this level can contain arbitrary other related\nfiles as <a href=\"/en-US-v0.14.1/reference/pdf/attach/\">attachments</a>, just as files conforming to part 3 of ISO\n19005. The only difference between it and PDF/A-4 is the capability to attach\nnon-PDF/A-conformant files.</p>\n</li>\n<li>\n<p><strong>PDF/A-4e:</strong> The <em>engineering</em> conformance level that builds on the embedded\nfiles level A-4f. Files conforming to this level can contain 3D objects. Typst\ndoes not support 3D content, so this is functionally equivalent to PDF/A-4f\nfrom a Typst perspective.</p>\n</li>\n</ul>\n<p>If you want to target PDF/A but are unsure about which particular setting to\nuse, there are some good rules of thumb. First, you must determine your\n<strong>part,</strong> that's the &quot;version number&quot; of the standard. Ask yourself these\nquestions:</p>\n<ol>\n<li>\n<p><strong>Does pre-2006 software or equipment need to be able to read my file?</strong> If\nso, choose part one (PDF/A-1).</p>\n</li>\n<li>\n<p><strong>If not, does my file need <a href=\"/en-US-v0.14.1/reference/pdf/attach/\">attachments</a>?</strong> If so, you must\nchoose part three (PDF/A-3) or the embedded files level of part four\n(PDF/A-4f).</p>\n</li>\n<li>\n<p><strong>Does your file need to use features introduced in PDF 2.0?</strong> Currently, use\nof PDF 2.0 features in Typst is limited to minor improvements in\naccessibility, e.g. for the <a href=\"/en-US-v0.14.1/reference/model/title/\">title element</a>. If you can do without\nthese improvements, maximize compatibility by choosing part two (when you\ndon't need attachments) or part three (when you do need attachments). If you\nrely on PDF 2.0 features, use part four.</p>\n</li>\n</ol>\n<p>Now, you only need to choose a <strong>conformance level</strong> (the lowercase letter at\nthe end).</p>\n<ul>\n<li>\n<p><strong>If you decided on part one, two, or three,</strong> you should typically choose the\naccessible conformance level of your part, indicated by a lowercase <code>a</code> at the\nend. If your document is inherently inaccessible, e.g. an artist's portfolio\nthat cannot be boiled down to alternative descriptions, choose conformance\nlevel <code>u</code> instead. Only if this results in a compiler error, e.g. because you\nused code points from the Unicode Private Use Area, use the basic level <code>b</code>.</p>\n</li>\n<li>\n<p><strong>If you have chosen part four,</strong> you should choose the basic conformance\nlevel (PDF/A-4) except when needing to embed files.</p>\n</li>\n</ul>\n<p>When choosing between exporting PDF/A and regular PDF, keep in mind that PDF/A\nfiles contain additional metadata, and that some readers will prevent the user\nfrom modifying a PDF/A file.</p>\n<h2 id=\"pdf-specific-functionality\">PDF-specific functionality</h2>\n<p>Typst exposes PDF-specific functionality in the global <code>pdf</code> module. See below\nfor the definitions it contains.</p>\n<p>This module contains some functions without a final API. They are designed to\nenhance accessibility for documents with complex tables. This includes\n<a href=\"/en-US-v0.14.1/reference/pdf/table-summary/\"><code>table-summary</code></a>, <a href=\"/en-US-v0.14.1/reference/pdf/header-cell/\"><code>header-cell</code></a>, and\n<a href=\"/en-US-v0.14.1/reference/pdf/data-cell/\"><code>data-cell</code></a>. All of these functions will be removed in a\nfuture Typst release, either through integration into table functions or through\nfull removal. You can enable these functions by passing <code>--features a11y-extras</code>\nor setting the <code>TYPST_FEATURES</code> environment variable to <code>a11y-extras</code>. In the\nweb app, these features are not available at this time.</p>","items":[{"name":"artifact","route":"/en-US-v0.14.1/reference/pdf/artifact/","oneliner":"Marks content as a PDF artifact.","code":true},{"name":"attach","route":"/en-US-v0.14.1/reference/pdf/attach/","oneliner":"A file that will be attached to the output PDF.","code":true},{"name":"data-cell","route":"/en-US-v0.14.1/reference/pdf/data-cell/","oneliner":"Explicitly defines this cell as a data cell.","code":true},{"name":"header-cell","route":"/en-US-v0.14.1/reference/pdf/header-cell/","oneliner":"Explicitly defines a cell as a header cell.","code":true},{"name":"table-summary","route":"/en-US-v0.14.1/reference/pdf/table-summary/","oneliner":"A summary of the purpose and structure of a complex table.","code":true}],"shorthands":null}}}