pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Harrop <jhar...@gmail.com>
Subject IKVM'd TTFDataStream: Unexpected end of TTF stream
Date Fri, 11 Oct 2013 09:29:37 GMT
Hi

I'm using IKVM'd PDFBox 1.8.2 to convert the first page of a PDF to PNG.

My Java code to do this:

private byte[] getThumbnail(byte[] pdfBytes) throws IOException {
 PDDocument pdDoc = PDDocument.load(new ByteArrayInputStream(pdfBytes));
 PDPage page = (PDPage)pdDoc.getDocumentCatalog().getAllPages().get(0);
 BufferedImage image = page.convertToImage();

 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 ImageIO.write(image, "png", baos);
 baos.flush();
 byte[] bytes = baos.toByteArray();
 baos.close();

 return bytes;
}

That's IKVM'd as well.

It all works nicely in Java (eg run from Eclipse).

The .NET version, run from VS 2010, throws an exception:

java.io.IOException: Unexpected end of TTF stream reached
        at org.apache.fontbox.ttf.TTFDataStream.read(TTFDataStream.java:221)
        at
org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:69)
        at
org.apache.fontbox.ttf.TTFDataStream.readString(TTFDataStream.java:57)
        at
org.apache.fontbox.ttf.AbstractTTFParser.readTableDirectory(AbstractTTFParser.java:214)
        at
org.apache.fontbox.ttf.AbstractTTFParser.parseTTF(AbstractTTFParser.java:85)
        at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:26)
        at
org.apache.fontbox.ttf.AbstractTTFParser.parseTTF(AbstractTTFParser.java:66)
        at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:26)
        at
org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.rebuildTTF(PDTrueTypeFont.java:517)
        at
org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getawtFont(PDTrueTypeFont.java:456)
        at
org.apache.pdfbox.pdmodel.font.PDSimpleFont.drawString(PDSimpleFont.java:109)
        at
org.apache.pdfbox.pdfviewer.PageDrawer.processTextPosition(PageDrawer.java:235)
        at
org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:388)
        at
org.apache.pdfbox.util.operator.ShowTextGlyph.process(ShowTextGlyph.java:48)
        at
org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:554)
        at
org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:269)
        at
org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
        at
org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:216)
        at
org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:127)
        at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:783)
        at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:712)

Any thoughts on why this might be happening?

The PDF itself is very simple; it was created by saving as PDF from Word,
and contains a couple of images and a few words.  Reader tells me it
contains embedded subsets of Calibri and Cambria fonts.

thanks ... Jason

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message