Hello, I have got Java-code that currently does formattted printing through JSE1.2-PrinterJob's. I implement the Method
public int print(Graphics g, PageFormat pageFormat, int pageIndex) { of the Interface java.awt.print.Printable. Now I want to redirect the output into a PDF-file. What I tried is something like below, but just produced a corrupt PDF-File. My german Acrobat Reader says "Ungültiger Wiederherstellungsvorgang" and displays a white Page. Can anybody tell me, what I'm doing wrong? Thaks, Lars ------------ The Code that produces a corrupt PDF-File. If redirecToPDF==false, the code does fine printing! ------------ public int print(Graphics g, PageFormat pageFormat, int pageIndex) { Document document = new Document(); if (pageIndex > 0) { return(NO_SUCH_PAGE); } else { try { Graphics2D g2d =null; if (redirectToPDF){ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:\\TEST.pdf")); document.open(); DefaultFontMapper mapper = new DefaultFontMapper(); mapper.insertDirectory("c:\\winnt\\fonts"); int h = (int)pageFormat.getImageableHeight(); int w = (int)pageFormat.getImageableWidth(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(w, h); g2d = tp.createGraphics(w, h, mapper); } else { g2d = (Graphics2D) g; } g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); componentToBePrinted.setSize( (int) pageFormat.getImageableWidth(), (int) pageFormat.getImageableHeight()); componentToBePrinted.validate(); disableDoubleBuffering(componentToBePrinted); componentToBePrinted.print(g2d); enableDoubleBuffering(componentToBePrinted); cb.addTemplate(tp,(float)pageFormat.getImageableX(),(float)pageFormat.getImageableY()); document.close(); ... _______________________________________ OSC-Information Management AG Dipl.-Inform. Lars Sitzmann Leiter Competence Center GIS Industriestraße 11, 26121 Oldenburg Tel.: 04 41/3 50 42-3 04, Fax: -3 80, Zentrale -0 E-Mail: [EMAIL PROTECTED] URL: http://www.osc-im.de http://www.InterGIS.de ------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions