test for embedded fonts programmatically

  • Follow


hi, I'm using the pyPdf python module to get information from a set of
pdfs. I would like to figure out if all the fonts in the pdf are
embedded. Here's a an example of the data pyPdf gives me:

94: {'/Ascent': 712,
                              '/CapHeight': 712,
                              '/CharSet': u'/C/a/e/four/h/i/l/n/o/one/
p/r/t/z/zero',
                              '/Descent': -213,
                              '/Flags': 4,
                              '/FontBBox': [-174, -285, 1001, 953],
                              '/FontFile': IndirectObject(93, 0),
                              '/FontName': '/WCTVAJ+NimbusSanL-Regu',
                              '/ItalicAngle': 0,
                              '/StemV': 85,
                              '/Type': '/FontDescriptor',
                              '/XHeight': 523}

Is there a way to determine from this info whether the font is
embedded?
thanks,
--Tim Arnold
0
Reply jtim.arnold (25) 3/1/2011 6:06:06 PM

In article <29c68afa-66d8-49e0-8f12-
66b235931e2f@d23g2000prj.googlegroups.com>, jtim.arnold@gmail.com 
says...
> 
> hi, I'm using the pyPdf python module to get information from a set of
> pdfs. I would like to figure out if all the fonts in the pdf are
> embedded. Here's a an example of the data pyPdf gives me:
> 
> 94: {'/Ascent': 712,
>                               '/CapHeight': 712,
>                               '/CharSet': u'/C/a/e/four/h/i/l/n/o/one/
> p/r/t/z/zero',
>                               '/Descent': -213,
>                               '/Flags': 4,
>                               '/FontBBox': [-174, -285, 1001, 953],
>                               '/FontFile': IndirectObject(93, 0),
>                               '/FontName': '/WCTVAJ+NimbusSanL-Regu',
>                               '/ItalicAngle': 0,
>                               '/StemV': 85,
>                               '/Type': '/FontDescriptor',
>                               '/XHeight': 523}
> 
> Is there a way to determine from this info whether the font is
> embedded?

The FontFile entry tells you (in effect) that it is embedded. Its a 
pointer from the FontDescriptor (what you have decoded above, which is 
why it has hte /Type /FontDescriptor entry) to the actual font data.

			Ken
0
Reply ken 3/1/2011 7:07:57 PM


On Mar 1, 2:07=A0pm, ken <k...@spamcop.net> wrote:
> In article <29c68afa-66d8-49e0-8f12-
> 66b235931...@d23g2000prj.googlegroups.com>, jtim.arn...@gmail.com
> says...
>
>
>
>
>
>
>
>
>
>
>
> > hi, I'm using the pyPdf python module to get information from a set of
> > pdfs. I would like to figure out if all the fonts in the pdf are
> > embedded. Here's a an example of the data pyPdf gives me:
>
> > 94: {'/Ascent': 712,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/CapHeight=
': 712,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/CharSet':=
 u'/C/a/e/four/h/i/l/n/o/one/
> > p/r/t/z/zero',
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/Descent':=
 -213,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/Flags': 4=
,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/FontBBox'=
: [-174, -285, 1001, 953],
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/FontFile'=
: IndirectObject(93, 0),
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/FontName'=
: '/WCTVAJ+NimbusSanL-Regu',
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/ItalicAng=
le': 0,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/StemV': 8=
5,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/Type': '/=
FontDescriptor',
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '/XHeight':=
 523}
>
> > Is there a way to determine from this info whether the font is
> > embedded?
>
> The FontFile entry tells you (in effect) that it is embedded. Its a
> pointer from the FontDescriptor (what you have decoded above, which is
> why it has hte /Type /FontDescriptor entry) to the actual font data.
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Ken

Great! So if I understand correctly, as long as each entry that has a
FontName also has a non-null FontFile entry, the font is embedded.

I was just looking through some iText code here: http://itextpdf.com/exampl=
es/iia.php?id=3D287
and I think it's saying that a font is embedded if the FontName is
longer than 8 chars and the 8th character is '+'. Otherwise, check on
the value for FontFile/FontFile2/FontFile3. If both those checks are
false, the font is not embedded.


thanks for your quick response!
--Tim
0
Reply Tim 3/1/2011 7:20:11 PM

In article <63853e17-014e-4990-a7ca-2a16082ad804
@d12g2000prj.googlegroups.com>, jtim.arnold@gmail.com says...

> > The FontFile entry tells you (in effect) that it is embedded. Its a
> > pointer from the FontDescriptor (what you have decoded above, which is
> > why it has hte /Type /FontDescriptor entry) to the actual font data.
> >
> > � � � � � � � � � � � � Ken
> 
> Great! So if I understand correctly, as long as each entry that has a
> FontName also has a non-null FontFile entry, the font is embedded.

If its not embedded there should not be a FontFile entry at all, a null 
would be a Bad Thing.

 
> I was just looking through some iText code here: http://itextpdf.com/examples/iia.php?id=287
> and I think it's saying that a font is embedded if the FontName is
> longer than 8 chars and the 8th character is '+'. Otherwise, check on
> the value for FontFile/FontFile2/FontFile3. If both those checks are
> false, the font is not embedded.

If the Fontname contains a '+' in position 8, and contains more 
characters, then its (probably) a subset font. Its not a good test for 
embedded status as there is no reason why a subset font needs to be 
embedded (though it would be astonishing if it were not).


			Ken
0
Reply ken 3/2/2011 7:47:50 AM

3 Replies
652 Views

(page loaded in 0.044 seconds)

Similiar Articles:









7/24/2012 1:17:39 AM


Reply: