From: Jeremias Maerki Date: Mon, 22 Aug 2005 15:14:43 +0000 (+0000) Subject: Fix the DSC comment (Begin|EndDocument) for EPS files. It wasn't in the right place. X-Git-Tag: fop-0_90-alpha1~360 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=de8d88e2a43539da52998032a49f58b83be44e67;p=xmlgraphics-fop.git Fix the DSC comment (Begin|EndDocument) for EPS files. It wasn't in the right place. Added a FOP-specific comment around the whole EPS to delimit the EPS code. Use the original URI if the EPS file has no name (which isn't parsed at the moment anyway). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@234504 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/ps/PSImageUtils.java b/src/java/org/apache/fop/render/ps/PSImageUtils.java index b4c3d5f43..812ed9ab8 100644 --- a/src/java/org/apache/fop/render/ps/PSImageUtils.java +++ b/src/java/org/apache/fop/render/ps/PSImageUtils.java @@ -162,7 +162,11 @@ public class PSImageUtils { int[] bbox = img.getBBox(); int bboxw = bbox[2] - bbox[0]; int bboxh = bbox[3] - bbox[1]; - renderEPS(img.getEPSImage(), img.getDocName(), + String name = img.getDocName(); + if (name == null || name.length() == 0) { + name = img.getOriginalURI(); + } + renderEPS(img.getEPSImage(), name, x, y, w, h, bbox[0], bbox[1], bboxw, bboxh, gen); @@ -184,14 +188,15 @@ public class PSImageUtils { * @param bboxy y-coordinate of EPS bounding box in points * @param bboxw width of EPS bounding box in points * @param bboxh height of EPS bounding box in points + * @param gen the PS generator * @throws IOException in case an I/O error happens during output */ public static void renderEPS(byte[] rawEPS, String name, float x, float y, float w, float h, int bboxx, int bboxy, int bboxw, int bboxh, PSGenerator gen) throws IOException { + gen.writeln("%FOPBeginEPS: " + name); gen.writeln("BeginEPSF"); - gen.writeln("%%BeginDocument: " + name); gen.writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " translate"); gen.writeln("0 " + gen.formatDouble(h) + " translate"); @@ -207,10 +212,11 @@ public class PSImageUtils { gen.writeln(gen.formatDouble(bboxy) + " " + gen.formatDouble(bboxy) + " " + gen.formatDouble(bboxw) + " " + gen.formatDouble(bboxh) + " re clip"); gen.writeln("newpath"); + gen.writeln("%%BeginDocument: " + name); gen.writeByteArr(rawEPS); gen.writeln("%%EndDocument"); gen.writeln("EndEPSF"); - gen.writeln(""); + gen.writeln("%FOPEndEPS"); } }