Skip to content

Saving form fields with non-embedded TrueType DR font (/Name set) throws "The character is not supported by the font" for Latin-1 characters (ä, ö, ü, é …) #2571

Open

Description

@stephankopp-axians

Bug description

Package / version

  • syncfusion_flutter_pdf 35.1.37 and 35.1.43 (latest); also reproducible via syncfusion_flutter_pdfviewer saveDocument()
  • Platform independent (seen on Windows, reproduced in flutter test)

Description

Forms edited with Adobe Acrobat often contain a non-embedded TrueType font in AcroForm/DR, e.g.

/Arial << /Type /Font /Subtype /TrueType /BaseFont /Arial /Name /Arial
          /Encoding /WinAnsiEncoding /FontDescriptor ... (no FontFile2) >>

and text fields with /DA (/Arial 0 Tf 0 g).

Filling such a field with characters that are part of WinAnsiEncoding (e.g. German umlauts ä = 228, ö = 246, é, à, ç) and calling document.save() throws:

Invalid argument (The character is not supported by the font.): 228
#0  StandardWidthTable._returnValue
#1  PdfStandardFontHelper.getCharWidthInternal
...
#n  PdfTextBoxField._applyAppearance
#n  PdfDocument.save

Uppercase umlauts (Ä = 196) and ß (223) work; every character code >= 224 fails.

Root cause (analysis)

In forms/pdf_field.dart → _getFont (TrueType branch) the font is created as a Helvetica standard-font prototype. Because the font dictionary contains a /Name that differs from the standard font name, the metrics are replaced via _createFont(...) (font name becomes e.g. "Arial"), but the Helvetica width table (224 entries, starting at char code 32) is kept.

PdfStandardFontHelper.getCharWidthInternal (graphics/fonts/pdf_standard_font.dart) only subtracts the _charOffset (32) when the font name is one of the standardFontNames. For "Arial" the offset is not subtracted, so the index is the raw char code → codes >= 224 are out of range → ArgumentError. (Codes 32–223 do not throw but use widths shifted by 32 positions, i.e. wrong widths.)

Expected

Either keep the offset consistent with the width table that is actually used (subtract _charOffset whenever a standard-font width table is used), or build the width table for the replaced metrics.

Follow-up problem in SfPdfViewer

When this exception happens inside SfPdfViewerController.saveDocument(), _updateSignatureFormFields has already drawn the signatures and removed the signature fields from the live document. Every further save attempt then fails with Null check operator used on a null value in SfPdfViewerState._updateSignatureFormFields (page!). The viewer state is corrupted until the document is reloaded. Ideally the save should be transactional (work on a copy, or restore on failure).

Workaround

Before editing, replace the field font if field.font!.measureString('äöüàéç') throws:

field.font = PdfStandardFont(PdfFontFamily.helvetica, size > 0 ? size : 8);

Steps to reproduce

Minimal reproduction

  1. Create a PDF form with a text field whose /DA references a DR font /Arial of subtype /TrueType with /Name /Arial, WinAnsiEncoding, no embedded font file (Acrobat produces this when the field font is set to "Arial").
  2. final doc = PdfDocument(inputBytes: bytes);
    (doc.form.fields[0] as PdfTextBoxField).text = 'Prüfung äöü';
    await doc.save(); // throws ArgumentError: 228

Code sample

Code sample
[Add your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Stack Traces

Stack Traces
[Add the Stack Traces here]

On which target platforms have you observed this bug?

Windows

Flutter Doctor output

Doctor output
[Add your output here]

Activity

  1. added
    pdf
    pdf viewer
    open
    on Nov 10, 2026
  2. lingeshwaran-sf4984 commented on Nov 11, 2026

    @lingeshwaran-sf4984

    Hi @stephankopp-axians ,
    We were able to reproduce the reported issue where saving form fields that use a non-embedded TrueType DR font throws an "Invalid Argument" exception in Syncfusion Flutter PDF library. We are currently validating this issue and will provide updates on November 13, 2026.

    Regards,
    Lingeshwaran S

  3. lingeshwaran-sf4984 commented on Nov 13, 2026

    @lingeshwaran-sf4984

    Hi @stephankopp-axians ,
    We have confirmed that the issue where Saving form fields with non-embedded TrueType DR font (/Name set) throws The character is not supported using Syncfusion Flutter PDF is a defect in our product and logged a bug report for the same. The fix for this issue will be included in the weekly release scheduled for November 24, 2026.
    Please use the feedback link to track the status of the bug, Saving form fields with non-embedded TrueType DR font (/Name set) throws The character is not supported

    Disclaimer: "Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization."

    Regards,
    Lingeshwaran S

  4. lingeshwaran-sf4984 commented on Nov 24, 2026

    @lingeshwaran-sf4984

    Hi @stephankopp-axians ,
    We have resolved an issue where Saving form fields with non-embedded TrueType DR font (/Name set) throws The character is not supported, and the fix has been included in the latest weekly release.
    Package link: syncfusion_flutter_pdfviewer v35.2.13

    Root cause:
    For non-embedded TrueType form fonts such as Arial, the font metrics were recreated even after text modification, causing an inconsistency between the font metrics and retained width table. This led to invalid width-table indexing for extended WinAnsi characters (ä, ö, ü, etc.) and triggered an exception during document save.

    We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you require any further assistance.

    Regards,
    Lingeshwaran S

  5. stephankopp-axians commented on Nov 24, 2026

    @stephankopp-axians
    Author

    Hi @lingeshwaran-sf4984 ,

    thank you for the quick response and fix.

    Regards,
    Stephan

  6. lingeshwaran-sf4984 commented on Nov 25, 2026

    @lingeshwaran-sf4984

    Hi @stephankopp-axians ,

    Thank you for your response. Please get in touch with us if you would require any further assistance.

    Regards,
    Lingeshwaran S

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

    openpdfpdf viewer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions