Works for me. Here's the result with the last iText version. Best Regards, Paulo Soares
<<tg2.zip>> > -----Original Message----- > From: Beukelman, Ken [SMTP:[EMAIL PROTECTED]] > Sent: Monday, October 28, 2002 17:14 > To: '[EMAIL PROTECTED]' > Cc: Taylor, Deborah > Subject: [iText-questions] Java2D connection > > We currently generate graphical reports using Java2D. We would like to > generate PDFs from our current code by using it to drive the generation of > a > PDF. > > In order to try this, I generated a test method from the example code in > Chapter 10 of the tutorial. I call this method from a servlet: > > public ByteArrayOutputStream getPDF() > { > Document document = new Document(PageSize.LETTER); > try > { > > document.setPageSize(PageSize.LETTER.rotate()); // make it landscape > PdfWriter writer = > PdfWriter.getInstance(document, this.ba); > document.open(); > // Create a fontMapper and read all > the fonts in the font directory > DefaultFontMapper mapper = new > DefaultFontMapper(); > mapper.insertDirectory("c:\\winnt\\fonts"); > PdfContentByte cb = > writer.getDirectContent(); > cb.saveState(); > cb.concatCTM(1, 0, 0, 1, 100, 100); > Graphics2D g2 = cb.createGraphics(750,500, > mapper); > // draw things to g2 > g2.setColor(java.awt.Color.green); > g2.fillRect(0, 0, 50, 50); > g2.setColor(java.awt.Color.black); > g2.drawRect(0, 0, 50, 50); > g2.dispose(); > cb.restoreState(); > // draw Native PDF graphic at > 200,200 (a '+') > cb.moveTo(200,180); > cb.lineTo(200, 220); > cb.moveTo(180,200); > cb.lineTo(220, 200); > cb.stroke(); > } > catch (Exception e) > { > // Catch the exception? > System.out.println("Exception caught!!!"); > } > finally > { > document.close(); > } > return this.ba; > } > > ba is an instance variable defined as follows: > > private ByteArrayOutputStream ba; > > > When the code is executed, we see the PDF page in the browser with only > the > native figure present. Any hints as to how to get the figure drawn in > Java2D to appear? > > Thanks > > Ken Beukelman > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions
tg2.zip
Description: Binary data