From: eschaeffer Date: Tue, 23 May 2000 09:21:35 +0000 (+0000) Subject: changes in PDFXobject (also add a method to get the X number) X-Git-Tag: pre-columns~502 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=52019d9a93b5c91167956e96159dbf704d2da6c6;p=xmlgraphics-fop.git changes in PDFXobject (also add a method to get the X number) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193372 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/pdf/PDFXObject.java b/src/org/apache/fop/pdf/PDFXObject.java index f915be811..008dafccf 100644 --- a/src/org/apache/fop/pdf/PDFXObject.java +++ b/src/org/apache/fop/pdf/PDFXObject.java @@ -49,14 +49,18 @@ */ /* modified by JKT to integrate with 0.12.0 */ +/* modified by Eric SCHAEFFER to integrate with 0.13.0 */ package org.apache.fop.pdf; +// Java import java.io.IOException; import java.io.PrintWriter; -// shouldn't have to do this -import org.apache.fop.image.*; +// FOP +import org.apache.fop.datatypes.ColorSpace; +import org.apache.fop.image.FopImage; +import org.apache.fop.image.FopImageException; /** * PDF XObject @@ -68,7 +72,6 @@ import org.apache.fop.image.*; public class PDFXObject extends PDFObject { FopImage fopimage; - int[] map; int Xnum; @@ -81,10 +84,16 @@ public class PDFXObject extends PDFObject { this.Xnum=Xnumber; if (img == null) System.err.println("FISH"); - this.map = img.getimagemap(); fopimage=img; } + /** + * @return the PDF XObject number + */ + public int getXNumber() { + return this.Xnum; + } + /** * represent as PDF */ @@ -92,46 +101,47 @@ public class PDFXObject extends PDFObject { int length=0; int i=0; int x,y; - int ncc=(fopimage.getcolor()? 3 : 1);//Number of Color Channels - int size=(fopimage.getpixelwidth())*(fopimage.getpixelheight()*ncc); - String p; - String pdf = this.toPDF(); - // push the pdf dictionary on the writer - writer.write(pdf); - length +=pdf.length(); - p = (size*2+1) + " >>\n"; - p = p + "stream\n"; - writer.write(p); - length +=p.length(); - // push all the image data on the writer and takes care of length for trailer - for (y=fopimage.getpixelheight()-1;y>=0;y--) - { - for (x=0;x>\n"; + + // don't know if it's the good place (other objects can have references to it) + fopimage.close(); + + // push the pdf dictionary on the writer + writer.write(p); + length += p.length(); + // push all the image data on the writer and takes care of length for trailer + length += imgStream.outputPDFStream(writer); + + p = "endobj\n"; + writer.write(p); + length += p.length(); + } catch (FopImageException imgex) { +System.err.println("Error in XObject : " + imgex.getMessage()); + } catch (PDFFilterException filterex) { +System.err.println("Error in XObject : " + filterex.getMessage()); + } return length; } String toPDF() { +/* Not used any more String p = this.number + " " + this.generation + " obj\n"; p = p + "<