Bug 694734 - Font emebedding in PDF annotation
Summary: Font emebedding in PDF annotation
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Font API (show other bugs)
Version: 9.07
Hardware: PC Linux
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-23 05:34 UTC by andrusha
Modified: 2013-10-23 07:04 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Example bogus file. (634.11 KB, application/pdf)
2013-10-23 05:36 UTC, andrusha
Details
Form filled in Adobe PRO (2.16 MB, application/pdf)
2013-10-23 05:57 UTC, andrusha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description andrusha 2013-10-23 05:34:37 UTC
I have PDF file.
Actually it is a PDF file with PDF-Form.
I use Poppler and "cups-filters/fontembed" libruary to embeded entire font-file into this PDF file.
The main idea is to fill form's fields on fly in UTF16BE.
Form filed specified to use embeded font.
I can see my font:

# pdffonts Micha.pdf
name                                 type encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
...
DejaVuSansMono                       CID TrueType Identity-H       yes no  no      65  0

But I receive next error message:

gs -dFirstPage=1  -q -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -dNOINTERPOLATE -sDEVICE=samsunggdi -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 -r600x600 -sOutputFile=- -dDEBUG -dPDFDEBUG -f 9.pdf   > /dev/null
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.
   **** Error reading a content stream. The page may be incomplete.

I can see next objects in PDF file:

63 0 obj <</Type /FontDescriptor /FontName /DejaVuSansMono /Flags 7 /ItalicAngle 0 /Ascent 759 /Descent -240 /CapHeight 759 /StemV 87 /FontBBox [-557 -374 717 1041 ] /AvgWidth 602 /Style <</Panose (^@^@^B^K^F        ^C^H^D^B^B^D) >> /FontFile2 62 0 R >> endobj^M
64 0 obj <</Type /Font /Subtype /CIDFontType2 /BaseFont /DejaVuSansMono /FontDescriptor 63 0 R /CIDSystemInfo <</Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /DW 602 >> endobj^M
65 0 obj <</Type /Font /Subtype /Type0 /BaseFont /DejaVuSansMono /Encoding /Identity-H /DescendantFonts [64 0 R ] >> endobj^M



# gs -dPDFSTOPONERROR -dNODISPLAY  Micha.pdf

Error: /undefined in --.execform1--
Operand stack:
   --dict:16/23(L)--   1   1   --dict:16/23(L)--   1   1   --dict:16/23(L)--   0   (\376\377\0001)   4096   0   237.8   25.4016   14.0   --dict:13/20(ro)(L)--   FontBBox
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1900   1   3   %oparray_pop   1899   1   3   %oparray_pop   1883   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   false   1   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   10   1   1842   8   11   %oparray_pop   --nostringval--   false   1   %stopped_push   1841   8   11   %oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--   --nostringval--   --nostringval--   %loop_continue   --nostringval--
Dictionary stack:
   --dict:1164/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:109/127(ro)(G)--   --dict:292/300(ro)(G)--   --dict:27/32(L)--   --dict:6/8(L)--   --dict:22/40(L)--   --dict:20/25(L)--   --dict:8/15(L)--
Current allocation mode is local
GPL Ghostscript 9.07: Unrecoverable error, exit code 1




%Resolving: [62 0]
<<
/Type /Font /Length 333636 /Length1 333636 >>
stream
%FilePosition: 313661
endobj
FFTM 300 28
GDEF 328 176
GPOS 504 14732
GSUB 15236 1152
OS/2 16388 86
cmap 16476 5678
cvt  22156 560
fpgm 22716 172
gasp 22888 12
glyf 22900 249308
head 272208 54
hhea 272264 36
hmtx 272300 6586
loca 278888 13160
maxp 292048 32
name 292080 8469
post 300552 31263
prep 331816 1819
findname: 6 = (DejaVuSansMono)
findname: 0 = (Copyright \(c\) 2003 by Bitstream, Inc. All Rights Reserved.\nDejaVu changes are in public domain\n)
findname: 1 = (DejaVu Sans Mono)
findname: 4 = (DejaVu Sans Mono)
findname: 5 = (Version 2.33)
GSUB 236 1152
OS/2 1388 86
cmap 1474 5678
cvt  7152 560
fpgm 7712 172
glyf 7884 249308
head 257192 54
hhea 257246 36
hmtx 257282 6586
loca 263868 13160
maxp 277028 32
name 277060 8469
post 285530 31263
prep 316794 1819
[236 1152 86 5678 560 172 32764 32764 32764 32764 32764 32764 32764 19960 54 36 6586 13160 32 8470 31264 1820]
/FontMatrix
[1.0 0.0 0.0 1.0 0.0 0.0]
/FontBBox
[-0.557617188 -0.374511719 0.717773438 1.04150391]
/FontName
(DejaVuSansMono)
/FontInfo
-dict-
/XUID
[107 42 -2147483644]
FAPIhook DejaVuSansMono
Trying to render the font Font DejaVuSansMono with FAPI...
Font DejaVuSansMono is being rendered with FAPI=FreeType
FAPIhook DejaVuSansMono
Font DejaVuSansMono is mapped to FAPI=FreeType
0 (\376\377\0001) 4096 0 Tform
   **** Error reading a content stream. The page may be incomplete.




I received a answer from "fontembed" libruary:

I've looked at your file. It looks quite ok, and xpdf renders it without spitting out errors.
You are using the embedded font only in "Annotations", i.e. as part of the PDF-Form.
When I modify your pdf to use the font only for regular content instead, the errors seem to disappear. I.e. your font embedding seems to work.

I suspect that the font embedding, maybe the encoding as "multibyte font", is somehow incompatible with pdf forms. I wrote libfontembedd originally for the texttopdf filter, where exactly this encoding is needed.
I currently don't know enough about pdf forms to give a better answer. I might find some time next week to look up the relevant chapters in the pdf reference ...

I would guess that /filling out/ the form requires a (implicit or explicit) /ToUnicode mapping. This is currently not created by libfontembedd, and adding it would be quite a bit of work. But you are (currently) only reading/printing the file, and this is /probably/ possible without the mapping....

Hope that helps,

  Tobias



Please help me to do embedding font.
Comment 1 andrusha 2013-10-23 05:36:06 UTC
Created attachment 10348 [details]
Example bogus file.
Comment 2 andrusha 2013-10-23 05:57:24 UTC
Created attachment 10349 [details]
Form filled in Adobe PRO
Comment 3 Chris Liddell (chrisl) 2013-10-23 07:04:50 UTC
Error resolved in:

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=ad3e3ed7