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

fill form using japanese font #779

Open
ka2n opened this issue Jan 18, 2024 · 6 comments
Open

fill form using japanese font #779

ka2n opened this issue Jan 18, 2024 · 6 comments
Assignees

Comments

@ka2n
Copy link

ka2n commented Jan 18, 2024

I have set up a text field with a Japanese font. When I try to insert text here, the font is recognized, but I get the error pdfcpu: corrupt fontDic.

After some investigation, the code below cause this error.

font.W = df.IndirectRefEntry("W")
if font.W == nil {
return ErrCorruptFontDict
}

I'm not familiar with PDF specifications, but it seems like the problem is accessing 7 instead of 8.
Maybe there is a problem if the subsetted font for the embedded text and the font set on the form are the same?

162
    7:   offset=    1034 generation=0 types.Dict type=Font subType=Type0
<<
        <BaseFont, BAAAAA+IPAmjMincho>
        <DescendantFonts, [(8 0 R)]>
        <Encoding, Identity-H>
        <Subtype, Type0>
        <ToUnicode, (9 0 R)>
        <Type, Font>
>>
    8:   offset=    1179 generation=0 types.Dict type=Font subType=CIDFontType2
<<
        <BaseFont, BAAAAA+IPAmjMincho>
        <CIDSystemInfo, <<
                <Ordering, (Identity)>
                <Registry, (Adobe)>
                <Supplement, 0>
        >>>
        <CIDToGIDMap, (14 0 R)>
        <FontDescriptor, (11 0 R)>
        <Subtype, CIDFontType2>
        <Type, Font>
        <W, [0 [1000 1000 1000 1000 1000 1000 1000 1000 1000 290]]>
>>
$ pdfcpu font list
Corefonts:
  Courier
  Courier-Bold
  Courier-BoldOblique
  Courier-Oblique
  Helvetica
  Helvetica-Bold
  Helvetica-BoldOblique
  Helvetica-Oblique
  Symbol
  Times-Bold
  Times-BoldItalic
  Times-Italic
  Times-Roman
  ZapfDingbats

Userfonts(/home/k2/.config/pdfcpu/fonts):
  IPAmjMincho (61360 glyphs)
  • State your OS and OS version
Linux pc 6.7.0-zen3-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sat, 13 Jan 2024 14:36:54 +0000 x86_64 GNU/Linux

By the way,
I produce the PDF file with forms with ONLYOFFICE Desktop Editors.
The file contain DA parameter with the value like 0.000000 0.000000 0.000000 rg \057F2 20.000000 Tf, so I have to patch parsing code to convert \057 to \.

@ka2n
Copy link
Author

ka2n commented Jan 18, 2024

Update: By changing the body text font and form font, this error no longer occurs but filled form texts are garbled.

@hhrutter
Copy link
Collaborator

Hello!

Thanks for reporting this.

Do you think you can share a small sample PDF file and the font you are using?

This would really help.

Thank you for using pdfcpu 💚

@ka2n
Copy link
Author

ka2n commented Jan 20, 2024

Thank you!

and a patch for my generator issue.

@hhrutter
Copy link
Collaborator

Thanks!!

@hhrutter
Copy link
Collaborator

hhrutter commented Feb 6, 2024

Please describe your use case.

Also do you think you can share a conrete sample of what you are doing?

If not, what would really help is a short Japanese text for testing with this font.

@hhrutter hhrutter reopened this Feb 6, 2024
@hhrutter
Copy link
Collaborator

hhrutter commented Feb 6, 2024

The latest commit takes care of the DA string issue.

@hhrutter hhrutter changed the title corrupt fontDic fill form using japanese font Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants