Development build 586e1bd4
Typst文档简体中文版v0.15.1 + dev 586e1bd4

pdf元素
Question mark
0.13.0起可用Go to source

Typst’s PDF export format.

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-specific functionality

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

This element 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.

参数
Question mark

pages
none or int or array or dictionary
可用set规则
Question mark
默认值:none

Specifies which ranges of pages should be included in the PDF. This can be:

A page range is one of:

Specifying a single page or page range:

#set pdf(pages: 3)
#set pdf(pages: (from: 3))
#set pdf(pages: (to: 5))
#set pdf(pages: (from: 3, to: 5))

Specifying multiple pages, page ranges, or a mix:

#set pdf(pages: (5, 7, 9))
#set pdf(pages: ((to: 3), 5, (from: 7, to: 8), (from: 10)))

standard
str or array
可用set规则
Question mark
默认值:("1.7",)

A list of PDF standards that Typst will enforce conformance with. This can be a single standard or an array of 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. You can combine compatible PDF/A and PDF/UA standards. Notably, PDF/UA-1 and PDF/A-4 are mutually incompatible since the former requires PDF 1.7 or earlier and the latter requires PDF 2.0.

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.

Expand展开可填值[⚠️]
VariantDetails
"1.4"PDF 1.4.
"1.5"PDF 1.5.
"1.6"PDF 1.6.
"1.7"PDF 1.7.
"2.0"PDF 2.0.
"a-1b"PDF/A-1b.
"a-1a"PDF/A-1a.
"a-2b"PDF/A-2b.
"a-2u"PDF/A-2u.
"a-2a"PDF/A-2a.
"a-3b"PDF/A-3b.
"a-3u"PDF/A-3u.
"a-3a"PDF/A-3a.
"a-4"PDF/A-4.
"a-4f"PDF/A-4f.
"a-4e"PDF/A-4e.
"ua-1"PDF/UA-1.

tagged
auto or bool
可用set规则
Question mark
默认值:auto

Whether to produce a tagged PDF document.

Tagging is enabled by default to provide a baseline of accessibility. It can be turned off manually, e.g. to reduce the size of the document, and will be disabled automatically when exporting a specific page range.

pretty
bool
可用set规则
Question mark
默认值:false

Whether to pretty-print the produced PDF document.

This formats the output in a more human-readable, but less space-efficient way.

定义