Skip to content

Setting font-family for AcroFrom not working properly #1096

Closed

Description

@r4tz52

Bug Report

Description of the problem

Setting custom font for text AcroForm has no effect if PDF file opened in Adobe Acrobat Reader, but works fine in Google Chrome:
aladin

PDF file example: aladin.pdf

Code sample

doc.font('aladin.regular.ttf');
doc.formText('InputField1', 10, 10, 200, 20, { value: 'Aladin' });

Your environment

  • pdfkit version: 0.11.0
  • Browser version: Google Chrome 80.0.3987.122
  • Operating System: Windows 10

Activity

  1. KaiPressmar commented on Apr 7, 2020

    @KaiPressmar
    Contributor

    Same issue for custom fonts

    Example code:

    const PDFDocument = require("pdfkit");
    const fs = require("fs");
    
    var doc = new PDFDocument();
    doc.pipe(fs.createWriteStream("out.pdf"));
    
    doc.font("./SourceCodePro-Regular.ttf");
    doc.initForm();
    
    // Dynamic fields do not work
    doc.formText("txt1", 20, 20, 100, 10, {
      value: "Test 01234",
    });
    
    // Normal text elements work
    doc.text("Test 01234", 20, 40, 100, 10);
    
    doc.end();
    

    Output:

    image

    Environment

    pdfkit version: 0.11.0
    Browser version: 80.0.3987.163 (Offizieller Build) (64-Bit)
    Operating System: Windows 10

  2. bowespublishing commented on Nov 20, 2022

    @bowespublishing

    Is there an update on this at all please?

  3. KaiPressmar commented on Aug 31, 2026

    @KaiPressmar
    Contributor

    @blikblum I investigated this issue and would be interested in contributing a fix.

    I also looked at #1335, which attempted to solve the problem by adding an option to disable font subsetting globally. I think the issue can be addressed more narrowly: keep the existing subset behavior for normal PDF text, but use a separate complete TrueType font resource for AcroForm "/DR" and "/DA" resources.

    The reason is that Acrobat regenerates editable form appearances and may need glyphs/tables that are not present in PDFKit's subset font. This appears to explain why the same form renders correctly in Chrome but falls back to another font in Acrobat.

    I have prepared an implementation with a regression test, documentation and changelog entry. Before opening a PR, would this form-specific approach be preferable to exposing a general "disable subsetting" option?

    If so, I can submit it as a PR against current master and reference both this issue and #1335.

  4. blikblum commented on Sep 3, 2026

    @blikblum
    Member

    Need to look at the PR but would be good to look at what other open source libraries do (iText, QuestPdf, ReportLab)

  5. added a commit that references this issue on Sep 5, 2026
    ee50422
  6. KaiPressmar commented on Sep 5, 2026

    @KaiPressmar
    Contributor

    Update: I opened a PR with the narrower, form-specific fix discussed above: #1789. It embeds a separate, complete, standard-encoding font for the AcroForm's /DR//DA resources instead of reusing the subsetted Identity-H font used in page content, since that font's subset intentionally has no cmap table and readers regenerating a field's appearance (via NeedAppearances) have no way to resolve field text to a glyph in it — which is why the same field renders fine in some viewers but falls back to a substitute font in others.

    @blikblum, flagging for whenever you have a chance to look.

  7. added 5 commits that reference this issue on Sep 11, 2026
    0ca02e5
    490720d
    de3c841
    cd32a19
    a2183fc
  8. added a commit that references this issue on Sep 14, 2026
    d05b18f
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions