Hi,
i want to list all the font included (by reference or embedded) in a pdf file. For
such thing, i used the example shown in the DumpFontNames class in turorial. My
function look like this :
...
PdfDictionary pages = (PdfDictionary)
PdfReader.getPdfObject(reader.getCatalog().get(PdfName.PAGES));
PdfArray kids = (PdfArray)
PdfReader.getPdfObject(pages.get(PdfName.KIDS));
PdfDictionary pageDictionary = (PdfDictionary)
PdfReader.getPdfObject((PdfObject) kids.getArrayList().get(pageNum - 1));
PdfDictionary pageResourcesDict = (PdfDictionary)
PdfReader.getPdfObject(pageDictionary.get(PdfName.RESOURCES));
PdfDictionary pageFontsDict = (PdfDictionary)
PdfReader.getPdfObject(pageResourcesDict.get(PdfName.FONT));
if (pageFontsDict != null)
{
Set pageFontNames = pageFontsDict.getKeys();
for (Iterator iter = pageFontNames.iterator(); iter.hasNext();)
{
PdfName internalFontName = (PdfName) iter.next();
PdfDictionary fontDict = (PdfDictionary)
PdfReader.getPdfObject(pageFontsDict.get(internalFontName));
PdfName baseFontName = (PdfName)
PdfReader.getPdfObject(fontDict.get(PdfName.BASEFONT));
PdfDictionary desc =
(PdfDictionary)PdfReader.getPdfObject(fontDict.get(PdfName.FONTDESCRIPTOR));
System.out.println("FONT:"+ baseFontName);
System.out.println(" :"+
desc.get((PdfName)PdfName.FONTFILE));
System.out.println(" :"+
desc.get((PdfName)PdfName.FONTFILE2));
System.out.println(" :"+
desc.get((PdfName)PdfName.FONTFILE3));
......
}
}
The problem is that program don't list ALL the fonts in the document. The listed fonts
for my document are the following :
Nb pages:1
FONT:/Arial
FONT:/Arial
FONT:/Arial
FONT:/Arial,Bold
FONT:/CenturyGothic,Bold
...
But when i edit the PDF file into a text editor for viewing the PDF structure, i find
others fonts into the file like this :
42 0 obj
<</FirstChar 0
/Type /Font
/FontDescriptor 62 0 R
/BaseFont /ArialBlack
/Name /ArialBlack
/Subtype /TrueType
/LastChar 255
/Encoding /WinAnsiEncoding
/Widths [...]
>>
endobj
62 0 obj
<</XHeight 519
/CapHeight 716
/Type /FontDescriptor
/Flags 32
/Descent -307
/FontBBox [-194 -307 1688 1083]
/FontFile2 63 0 R
/StemV 220
/Ascent 1083
/FontName /ArialBlack
/ItalicAngle 0
>>
endobj
I think that (preharps) represent an unused font into the document or wasted fonts.
How can i also list these fonts ?
Thanks.
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions