-
-
Notifications
You must be signed in to change notification settings - Fork 579
Description
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.
pdfcpu/pkg/pdfcpu/font/fontDict.go
Lines 117 to 120 in b89d7b1
| 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 \.