Skip to content

PDF/A-2 support #2942

Closed
5 of 5 issues completed
Closed

Description

@reknih

Here is what's missing in Typst for each of the PDF/A-2 compliance levels.

PDF/A-2b (done in #5075)

  • 6.1.13 Implementation limits: Fail export for ... (PDF/A: 6.1.13 Implementation limits #2995)
    • Strings longer than 32767 bytes
    • Names longer than 127 bytes (e.g. when containing font name)
    • More than 8388607 indirect objects
    • More than 28 q/Q nesting level
  • 6.2.3 Output Intent: Write an appropriate output intent. Potentially user-configurable. (PDF/A: 6.2.3 Output Intent #3002)
  • 6.2.4.1 Device color spaces: Do not write DeviceCMYK without defining the DefaultCMYK color space or a CMYK rendering intent. Possibilities include failing export, a default ICC profile, and user-supplied ICC profiles. (PDF/A: 6.2.3 Output Intent #3002)
  • 6.2.4.4 Separations and DeviceN color spaces: Oklab, HSL, and HSV colors produce a DeviceN color space without constituent separations in a Colorant dict entry. They are not expressible as such and shall hence either fail export, be implemented as ICC profiles, or rendered to another space. (PDF/A: 6.2.4.4 Separations and DeviceN color spaces #3003)
  • 6.2.4.5 Indexed and Pattern color spaces: Due to violation of the color subclauses above (PDF/A: 6.2.3 Output Intent #3002, PDF/A: 6.2.4.4 Separations and DeviceN color spaces #3003)
  • 6.2.11.8 .notdef glyph: Fail export to PDF/A if the document contains a .notdef glyph. Typst will output these if the font does not contain the glyph and if either font fallback is disabled or no other fallback font has the glyph either. (PDF/A: 6.2.11.8 .notdef glyph #3004)
  • 6.3.2 Annotation dictionaries: Add annotation flags to the link annotations
  • 6.6.2.3.2 Metadata extension schemas: Describe the xmpMM, xmpTPg, pdf, and pdfaid schemas using the pdfaSchema extension schema description schema
  • 6.6.2.3.3 Extension Schema Container: See above
  • 6.6.4 Version and conformance levels: Write an PDF/A ID entry in the XMP metadata for conforming files
  • 6.6.6 File provenance information: Write an xmpMM:History bag in the metadata

Feature Requests in violation of PDF/A-2a: #1400, #955 (may be supported in some PDF/A-4 sub-standards)

The PDF/A spec imposes additional requirements touching the following issues: #895, #2499 (only other compliant PDFs may be embedded, also concerns #1465), #2421 / #1765,

PDF/A-2u

  • All of the above tasks
  • 6.2.11.7.2 Level U Conformance: Ensure that every glyph in the ToUnicode mapping maps to a codepoint that is neither 0, U+FEFF, or U+FFFE. All characters used in the document must appear in the mapping. This may currently not be the case in complex shaping scenarios.

PDF/A-2a

  • All of the above tasks
  • 6.2.11.7.3 Level A Conformance: Write a structure element with ActualText for any character sequence that maps to the Unicode private use area. Fail export if this information is not available.
  • 6.7 Logical Structure: Write a Tagged PDF file. This includes enforcing human-readable replacement text for images and equations and tagging the content stream with the appropriate roles and attributes. (PDF Accessibility (tags, alt text, ...) #133)

Compliance at this level should solve #671, #526

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    pdf
    tracking-issue
    on Dec 13, 2023
  2. reknih commented on Dec 13, 2023

    @reknih
    MemberAuthor

    Fixing the following would be easy:

    • 6.3.2
    • 6.6.6

    Following issues would be easy to fix if the export could fail and emit diagnostics, which it cannot at the moment (#2943):

    • 6.1.13
    • 6.2.11.8
  3. Heinenen commented on Dec 17, 2023

    @Heinenen
    Contributor

    @reknih Would you think a separate issue for each of the points above is beneficial (for more focussed discussion)?
    If you think so, I can create them so you can edit your message to link to them.

    An issue would then look like this (I'm open to change, just an example):
    Title: PDF/A: 6.x.x.x name_of_feature
    Content: Feature issue to #2942 + the rest of the bullet point in your list above

    As for implementing 6.3.2 (spec, annotation flags):
    It seems that all flags should be unset except for maybe the "print" flag. For the print flag I don't know if it should be set or not. Do you have any input on this?
    Other than deciding which flag to use, it should probably be a one-liner here:

    let mut annotations = page_writer.annotations();
    for (dest, rect) in &page.links {
    let mut annotation = annotations.push();
    annotation.subtype(AnnotationType::Link).rect(*rect);
    annotation.border(0.0, 0.0, 0.0, None);

    let flags = AnnotationFlags::empty(); // or set flags in some other way
    annotation.flags(flags);
  4. reknih commented on Dec 18, 2023

    @reknih
    MemberAuthor

    I can create sub-issues for the clauses.

    On 6.3.2, the PDF/A-2 spec says the following:

    Except for annotation dictionaries whose Subtype value is Popup, all annotation dictionaries shall contain the
    F key. If present, the F key’s Print flag bit shall be set to 1 and its Hidden, Invisible, ToggleNoView, and
    NoView flag bits shall be set to 0.

    Text annotations should set the NoZoom and NoRotate flag bits of the F key to 1.

    NOTE The restrictions on annotation flags prevent the use of annotations that are hidden or that are viewable but not
    printable. The NoZoom and NoRotate flags are permitted, which allows the use of annotation types that have the same
    behaviour as the commonly used text annotation type. By definition, text annotations exhibit the NoZoom and NoRotate
    behaviour even if the flags are not set, as described in ISO 32000-1:2008, 12.5.3; explicitly setting these flags removes
    any potential ambiguity between the annotation dictionary settings and reader behaviour.

  5. LaurenzV commented on Dec 18, 2023

    @LaurenzV
    Collaborator

    Just a short note that when implementing PDF/A compliance, not only do we need to make sure that it's implemented on the Typst side, but also on the svg2pdf side.

  6. Heinenen commented on Dec 18, 2023

    @Heinenen
    Contributor

    That makes it clear, thank you.
    Sadly, I didn't find a free version of the PDF/A spec myself.

  7. NiklasEi commented on Aug 17, 2024

    @NiklasEi
    SponsorContributor

    Is there already a plan for the API on Typst side? Can users somehow decide if they want PDF/A or the "normal" PDF 1.7?

  8. LaurenzV commented on Aug 17, 2024

    @LaurenzV
    Collaborator

    Don't think there are conrete plans yet, but I'm pretty sure it will be configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pdftracking-issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions