Documentation

PDF

PDF files focus on accurately describing documents visually, but also have facilities for annotating their structure. This hybrid approach makes them a good fit for document exchange: They render exactly the same on every device, but also support extraction of a document's content and structure (at least to an extent). Unlike PNG files, PDFs are not bound to a specific resolution. Hence, you can view them at any size without incurring a loss of quality.

Exporting as PDF

Command Line

PDF is Typst's default export format. Running the compile or watch subcommand without specifying a format will create a PDF. When exporting to PDF, you have the following configuration options:

Web App

Click the quick download button at the top right to export a PDF with default settings. For further configuration, click "File" > "Export as" > "PDF" or click the downwards-facing arrow next to the quick download button and select "Export as PDF". When exporting to PDF, you have the following configuration options:

PDF standards

The International Standards Organization (ISO) has published the base PDF standard and various standards that extend it to make PDFs more suitable for specific use-cases. By default, Typst exports PDF 1.7 files. Adobe Acrobat 8 and later as well as all other commonly used PDF viewers are compatible with this PDF version. Some features of Typst may not be available depending on the PDF standard you choose.

PDF versions

Typst supports five different PDF versions: 1.4, 1.5, 1.6, 1.7 (default), and 2.0. You can choose each of these versions for your document export. However, based on the features you used there may be a minimum version. Likewise, the standards you target can limit which versions you can choose (see below for more).

Here is a list on how each new version improves over PDF 1.4 for Typst documents:

The software used to read your file must support your PDF version. Under normal circumstances, this poses no problem, but it can be a source of errors when working with older hardware. For general exchange, we recommend keeping the default PDF 1.7 setting or choosing PDF 2.0.

When using PDF files as images in your document, the export PDF version must equal or exceed the image file versions.

PDF/UA

Typst supports writing PDF/UA-conformant files. PDF/UA files are designed for Universal Access. When you choose this PDF standard, Typst will run additional checks when exporting your document. These checks will make sure that you are following accessibility best practices. For example, it will make sure that all your images come with alternative descriptions.

Note that there are some rules in PDF/UA that are crucial for accessibility but cannot be automatically checked. Hence, when exporting a PDF/UA-1 document, make sure you did the following:

Typst currently only supports part one (PDF/UA-1) which is based on PDF 1.7 (2006). When exporting to PDF/UA-1, be aware that you will need to manually provide alternative descriptions of mathematics in natural language.

New accessibility features were added to PDF 2.0 (2017). When set to PDF 2.0 export, Typst will leverage some of these features. PDF 2.0 and PDF/UA-1, however, are mutually incompatible. For accessible documents, we currently recommend exporting to PDF/UA-1 instead of PDF 2.0 for the additional checks and greater compatibility. The second part of PDF/UA is designed for PDF 2.0, but not yet supported by Typst.

PDF/A

Typst optionally supports emitting PDF/A-conformant files. PDF/A files are geared towards maximum compatibility with current and future PDF tooling. They do not rely on difficult-to-implement or proprietary features and contain exhaustive metadata. This makes them suitable for long-term archival.

The PDF/A Standard has multiple versions (parts in ISO terminology) and most parts have multiple profiles that indicate the file's conformance level. You can target one part and conformance level at a time. Currently, Typst supports these PDF/A output profiles:

If you want to target PDF/A but are unsure about which particular setting to use, there are some good rules of thumb. First, you must determine your part, that's the "version number" of the standard. Ask yourself these questions:

  1. Does pre-2006 software or equipment need to be able to read my file? If so, choose part one (PDF/A-1).

  2. If not, does my file need attachments? If so, you must choose part three (PDF/A-3) or the embedded files level of part four (PDF/A-4f).

  3. Does your file need to use features introduced in PDF 2.0? Currently, use of PDF 2.0 features in Typst is limited to minor improvements in accessibility, e.g. for the title element. If you can do without these improvements, maximize compatibility by choosing part two (when you don't need attachments) or part three (when you do need attachments). If you rely on PDF 2.0 features, use part four.

Now, you only need to choose a conformance level (the lowercase letter at the end).

When choosing between exporting PDF/A and regular PDF, keep in mind that PDF/A files contain additional metadata, and that some readers will prevent the user from modifying a PDF/A file.

PDF-specific functionality

Typst exposes PDF-specific functionality in the global pdf module. See below for the definitions it contains.

This module contains some functions without a final API. They are designed to enhance accessibility for documents with complex tables. This includes table-summary, header-cell, and data-cell. All of these functions will be removed in a future Typst release, either through integration into table functions or through full removal. You can enable these functions by passing --features a11y-extras or setting the TYPST_FEATURES environment variable to a11y-extras. In the web app, these features are not available at this time.

Definitions