I am converting a FOP 0.20.5 servlet to a use FOP 0.95. We needed to have bookmarks. which are supported in 0.95.
I am completely new to Java, Apache FOP, servlets, and iText. Please excuse me, if I do not get the java semantics down correctly. No one in my shop is a java programmer. I have inherited this code that was written several years ago.. I have been successful in getting the new code to create a PDF document using the new FOP classes and methods in FOP 0.95. I am now trying to get the some older code to work which appends PDF files to the PDF stream created with FOP. The old code used PdfCopy. I have found out that the bookmarks I had in the file are now gone. Seems I need to use class PdfCopyFields. Here is where I get confused with Java's object/class casting. The following is new code that I am trying to compile: [ previous code created the PDF as a ByteArrayOutputStream in out] byte[] content = out.toByteArray(); PdfReader MainApp = new PdfReader(content); ByteArrayOutputStream FullApp = new ByteArrayOutputStream(); PdfCopyFields copy = new PdfCopyFields(FullApp); copy.addDocument(MainApp); String LorFilePath = "/usr/local/docs/sophas/lor/2009/"; File LorFile = new File(LorFilePath); String[] LorFileNames = LorFile.list(new SimpleFilter(cas_id)); for(int j=0; j< LorFileNames.length;j++) { String inFile = new String(LorFilePath + LorFileNames[j]); PdfReader LorPDF = new PdfReader(inFile); copy.addDocument(LorPDF); } copy.close(); //Return the result response.setContentType("application/pdf"); response.setContentLength(copy.length); response.getOutputStream().write(copy); response.getOutputStream().flush(); Ant complains with: [javac] symbol : variable length [javac] location: class com.lowagie.text.pdf.PdfCopyFields [javac] response.setContentLength(copy.length); [javac] ^ [javac] /home/timb/xsl_fo/portals/sophas_servlet_095/src/FopServlet.java:378: cannot find symbol [javac] symbol : method write(com.lowagie.text.pdf.PdfCopyFields) [javac] location: class javax.servlet.ServletOutputStream [javac] response.getOutputStream().write(copy); [javac] ^ [javac] 2 errors The above errors makes perfect sense to me . I cannot figure out how convert the PdfCopyFields copy object to a byte stream to pass back as in the servlet response. - I have seen the PdfCopyFields is a sub-class of Object. - Is there a method to convert an Object to a byte stream? - Research into using copy.getWriter() has led me in circles of javadoc to no avail. Any help or educational pointers would be greatly appreciated. -- View this message in context: http://www.nabble.com/How-to-convert-PdfCopyFields-object-to--byte---for-servlet-response--tp20922244p20922244.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php