itext-questions  

[iText-questions] adding through direct content on multiple pages

Andrzej Semeniuk
Wed, 14 May 2008 15:30:33 -0700

Hi,
I browsed through the FAQ and archives and didn't find relevant posts about my
problem.  I'm new to iText and have the following problem: I'm trying to add
content to a PDF document by using PdfContentByte on multiple pages, but am only
able to add content to the first page -- only the first page is painted on,
subsequent pages are not painted on.  My code is as follows:

         Document document = new Document();
         PdfWriter writer = PdfWriter.getInstance(document,
                                                  new java.io.FileOutputStream(
                                                        filename));
         document.open();
         for (int page = 0; page < 3; page++) {
               PdfContentByte content = writer.getDirectContent();
               Graphics2D G = null;
               G = content.createGraphics(...);
               // paint with G, ex.  G.draw(new Line2D.Double(...));
               ...
               G.dispose();
               document.newPage();
               writer.newPage();
         }
         
         document.close();
         writer.close();


Thanks

--Andrzej


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar