From 3e0b2cfc1208009c85742054880394f1a2b4c240 Mon Sep 17 00:00:00 2001 From: Kelly Campbell Date: Sun, 8 Apr 2001 14:06:15 +0000 Subject: [PATCH] Fixed some bugs in PDF rendering when font embedding fails. FontDescriptor is now written out anyway to produce a valid PDF and acrobat reports that the font can't be displayed. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194196 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/pdf/PDFDocument.java | 32 +++++++++---------- .../fop/render/pdf/fonts/MultiByteFont.java | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/org/apache/fop/pdf/PDFDocument.java b/src/org/apache/fop/pdf/PDFDocument.java index 6636d2d62..b0314cb3b 100644 --- a/src/org/apache/fop/pdf/PDFDocument.java +++ b/src/org/apache/fop/pdf/PDFDocument.java @@ -854,17 +854,16 @@ public class PDFDocument { desc.getStemV(), desc.getItalicAngle()); } - // Check if the font is embeddable + this.objects.addElement(font); + + // Check if the font is embeddable if (desc.isEmbeddable()) { PDFStream stream=desc.getFontFile(this.objectcount+1); if (stream!=null) { this.objectcount++; font.setFontFile(desc.getSubType(), stream); - this.objects.addElement(font); this.objects.addElement(stream); } - } else { - this.objects.addElement(font); } return font; } @@ -1080,21 +1079,20 @@ public class PDFDocument { this.resources.setXObjects(xObjects); - /* loop through the object numbers */ - for ( int i=1; i <= this.objectcount; i++ ) { + Enumeration en = this.objects.elements(); + while (en.hasMoreElements()) { + /* retrieve the object with the current number */ + PDFObject object = (PDFObject)en.nextElement(); /* add the position of this object to the list of object locations */ this.location.addElement(new Integer(this.position)); - - /* retrieve the object with the current number */ - PDFObject object = (PDFObject)this.objects.elementAt(i-1); - - /* output the object and increment the character position + + /* output the object and increment the character position by the object's length */ this.position += object.output(stream); - } - + } + /* output the xref table and increment the character position by the table's length */ this.position += outputXref(stream); @@ -1157,12 +1155,12 @@ public class PDFDocument { StringBuffer pdf = new StringBuffer("xref\n0 " + (this.objectcount+1) + "\n0000000000 65535 f \n"); - /* loop through object numbers */ - for ( int i=1; i < this.objectcount+1; i++ ) { - + Enumeration en = this.location.elements(); + while (en.hasMoreElements()) { + String x = en.nextElement().toString(); + /* contruct xref entry for object */ String padding = "0000000000"; - String x = this.location.elementAt(i-1).toString(); String loc = padding.substring(x.length()) + x; /* append to xref table */ diff --git a/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java b/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java index f8305c3d6..2fb09b1b8 100644 --- a/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java +++ b/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java @@ -185,7 +185,7 @@ public class MultiByteFont extends CIDFont implements FontDescriptor { embeddedFont.addFilter("ascii-85"); embeddedFont.setData(subsetFont, subsetFont.length); } catch (IOException ioe) { - MessageHandler.error("Failed to embed font " + fontName + + MessageHandler.errorln("Failed to embed font ["+i+"] " + fontName + ": " + ioe.getMessage()); return (PDFStream) null; } -- 2.39.5