Skip to content

Fonts with form fields cannot be subset even after after flatten #70

@jekh

Description

@jekh

For PDFs with form fields, _usedInForm on embedded fonts is set to true, which permanently blocks subsetting, causing flattened PDFs to embed full fonts. Since flattened PDFs don't have form fields anymore, I believe their embedded fonts should be subsettable.

I'm using this hacky work-around:

form.flatten()

for (const font of Object.values(embeddedFonts)) {
      if (font && (font as unknown as { _usedInForm: boolean })._usedInForm) {
        ;(font as unknown as { _usedInForm: boolean })._usedInForm = false
      }
    }

But I'm guessing the cleaner solution is to clear the _usedInForm field in flatten() itself.

I'm happy to put together a PR if this is the right approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions