Skip to content

fill form using japanese font #779

@ka2n

Description

@ka2n

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 \.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions