Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[syncfusion_flutter_pdfviewer] Filling unicode character in PDF viewer occur Invalid argument (The character is not supported by the font.) Error #1741

Open
aungzwin10 opened this issue Mar 18, 2024 · 13 comments
Labels
pdf viewer PDF viewer component waiting for customer response Cannot make further progress until the customer responds.

Comments

@aungzwin10
Copy link

In syncfusion_flutter_pdfviewer version 25.1.35,

When filling unicode character in PDF viewer form filling, Invalid argument (The character is not supported by the font.) error is shown and cannot save the document.
Unicode character means all language unicode character(Not only Chinese).

See the example error screenshot below.
Screenshot 2024-03-18 at 4 33 33 PM

@sAw-hTet-nAing
Copy link

I facing the same issue with this problem. Please help.

@phyueimon162
Copy link

Any solution? Same to me.

@VijayakumarMariappan VijayakumarMariappan added pdf viewer PDF viewer component open Open labels Mar 19, 2024
@immankumarsync
Copy link
Contributor

We have analyzed your query, and we are able to reproduce the reported issue and currently, we are investigating the root cause of this issue at the source level at our end.

@ramkumarsync ramkumarsync added follow-up scheduled Follow-up scheduled and removed open Open labels Mar 19, 2024
@immankumarsync
Copy link
Contributor

In the document, the font assigned for the text field is 'Helvetica'. Helvetica font doesn't support Unicode characters, hence on saving the document, 'The character is not supported by the font' exception occurs. This is an expected behavior.

@aungzwin10
Copy link
Author

@immankumarsync What is your suggested font for unicode?

@immankumarsync
Copy link
Contributor

@aungzwin10, Arial Unicode MS font supports most Unicode characters.

Please refer to the following on how to use custom font with syncfusion_flutter_pdf library.
PdfTrueTypeFont

@ramkumarsync ramkumarsync added waiting for customer response Cannot make further progress until the customer responds. and removed follow-up scheduled Follow-up scheduled labels Mar 22, 2024
@aungzwin10
Copy link
Author

@immankumarsync Although I created a fillable form PDF with Arial Unicode MS font on Text field, the error still happen.
Please see screenshots below for your reference.
Screenshot 2024-03-26 at 9 17 19 AM

I will attach the PDF for you to test too.
Arial Unicode Form.pdf

@immankumarsync
Copy link
Contributor

@aungzwin10, we are able to replicate the issue, that the font is not retrieved properly when using a custom font. Currently, we are analyzing the root cause of this issue, and we will update further details upon finding the root cause.

@sAw-hTet-nAing
Copy link

@immankumarsync Any Updates?Currently I'm facing a big trouble in my project with this error.

@immankumarsync
Copy link
Contributor

Sorry for any inconvenience that may have caused.

syncfusion_flutter_pdf supports only the below font families for drawing the text on the PDF page and for the Textbox form fields.

  1. Standard font family:

    • Helvetica
    • Courier
    • Times Roman
    • Symbol
    • ZapfDingbats
  2. CJK font family:

    • Hanyang Systems Gothic Medium
    • Hanyang Systems Shin Myeong Jo Medium
    • Heisei kaku GothicW5
    • Heisei MinchoW3
    • Monotype Hei Medium
    • Monotype sung Light
    • Sinotype song light
  3. Other than this, we can have custom fonts using the PdfTrueTypeFont class.

The limitation of using a font with a large number of glyphs in it is that only a subset of the font will be embedded in the PDF document.

For example, when using the Arial Unicode MS font, if we use characters like 'a', 'b', and 'c', only these three characters will be embedded in the PDF document upon saving the PDF document.

If you load the saved document again the syncfusion_flutter_pdf library, you need to assign the font for the particular field again to use the characters in that font.

//Loads an existing PDF document.
final PdfDocument document =
    PdfDocument(inputBytes: File('input.pdf').readAsBytesSync());

//Get the loaded form field and update the font.
(document.form.fields[0] as PdfTextBoxField).font = PdfTrueTypeFont(fontBytes, 12);

To know more about the base fonts that are supported by the PDF, kindly refer to the link below. PDF - Wikipedia

At present, the syncfusion_flutter_pdf library doesn't have the support to embed all the characters in the font into the PDF document upon saving.

Please note that embedding all the characters in the font file into the PDF document will increase its size.

We do not have any immediate plans to implement this support. At the planning stage of every release cycle, we review all open features and identify features for implementation based on specific parameters, including product vision, technological feasibility, and customer interest.

Please use the below feedback to track the status of this feature.
Support to complete embed font in a PDF document using PDF Flutter

@sAw-hTet-nAing
Copy link

sAw-hTet-nAing commented Apr 4, 2024

@immankumarsync
Thank you for responding.
With the information you provided, I'm now able to make progress but I have another issue. Currently, I'm using Pyidaungsu.font, which is the Unicode font for the Myanmar(Burmese)Language. I can type perfectly in form fields and can also save, but when I save document some characters are not correct, which are used with 'ေ', ' ြ'.

For Example,
Expected Result =>နေကောင်းလား
result before save
Screenshot 2024-04-04 at 11 54 08 AM

results after save
Screenshot 2024-04-04 at 11 52 52 AM

Expected Result=>မြန်မြန်
result before save
Screenshot 2024-04-04 at 11 55 55 AM
result after save
Screenshot 2024-04-04 at 11 56 08 AM

To reproduce this issue, please use the font attached. If you have any ideas about the problem’s cause or how to fix it, please let me know.
Pyidaungsu.ttf.zip

Regards,

@immankumarsync
Copy link
Contributor

@sAw-hTet-nAing,
While saving the document two things will happens,

  1. Text value will be added to the text box form field dictionary,
  2. The appearance for that glyph will be added to the form field.

At present, syncfusion_flutter_pdf library doesn't support for complex script of Myanmar(Burmese) Language. At the planning stage of every release cycle, we review all open features and identify features for implementation based on specific parameters, including product vision, technological feasibility, and customer interest.

Please follow the feedback link to track the status of the feature, Complex script text drawing support in Flutter PDF

@sAw-hTet-nAing
Copy link

@immankumarsync
Thank you for your response. I managed to resolve the issue by handling the glyph, although it's not a perfect solution, it's workable for now. Hopefully, in the future, there will be improvements in Unicode font rendering for every language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pdf viewer PDF viewer component waiting for customer response Cannot make further progress until the customer responds.
Projects
None yet
Development

No branches or pull requests

6 participants