pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Douglas" <edoug...@blockhouse.com>
Subject Create and Merge PDF What Am I Missing?
Date Tue, 07 Jun 2011 12:24:32 GMT
I used FOP to create a PDF in byte[] form.  Now I load the PDF into
pdfbox.  If I save it looks fine.
If I pass it into a viewer I get problems.

I generated an array of these PDFs and I need to combine them.
I start with just saving the first one.
ByteArrayInputStream myBAIS = new
PDDocument myPDDocument = PDDocument.load(myBAIS);
myPDDocument.save(myJobName + ".pdf");

If I open this PDF in Adobe Acrobat I can see everything just fine.
If I open this PDF in a viewer it shows all graphics, including SVG and
blocks with borders, but no text.
I tried loading it into iText with the sample code found here
I tried loading it into PDFRenderer
(http://java.net/projects/pdf-renderer) using the viewer in their trunk
demos, same result.
No errors on either, they just don't display text.
Now I try merging PDFs and again I can save the PDF I created and it
looks fine in Acrobat though it's missing something.
If there's only one PDF in my array, this method saves it about 2k
smaller than saving it directly.
The PDF array is a single document of separate documents, generated
using xsl:initial-page-number.

PDDocument myPDDocument = new PDDocument();
ArrayList<PDDocument> part = new ArrayList<PDDocument>();
for (int pdfLoop = 0; pdfLoop < myByteData.size(); pdfLoop ++) {
     ByteArrayInputStream myBAIS = new
     PDDocument partDoc = part.get(pdfLoop);
     List<PDPage> list = partDoc.getDocumentCatalog().getAllPages();
     for (PDPage page : list) {
myPDDocument.save(myJobName + ".pdf");

I get this error from the PDFRenderer viewer on the merged PDF:
com.sun.pdfview.PDFParseException: No dictionary called Font found in
the resources
	at com.sun.pdfview.PDFParser.findResource(PDFParser.java:912)
	at com.sun.pdfview.PDFParser.getFontFrom(PDFParser.java:1165)
	at com.sun.pdfview.PDFParser.iterate(PDFParser.java:719)
	at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
	at java.lang.Thread.run(Thread.java:662)

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