adding through direct content on multiple pages

View: New views
4 Messages — Rating Filter:   Alert me  

adding through direct content on multiple pages

by Andrzej Semeniuk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
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

Re: adding through direct content on multiple pages

by 1T3XT info :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrzej Semeniuk wrote:
> Hi,
> I browsed through the FAQ and archives and didn't find relevant posts about my
> problem.

It's obvious that you haven't been looking at:
http://itextdocs.lowagie.com/tutorial/general/copystamp/index.php#pdfstamper

> 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:

I honestly don't understand how you came up with that code.
Please read the documentation and try some examples before
writing code that hurts the eyes. Look at the PdfStamper
examples of chapter 2 of the book:
http://www.1t3xt.info/examples/browse/?page=toc&id=7
--
This answer is provided by 1T3XT BVBA

-------------------------------------------------------------------------
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@...
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

Re: adding through direct content on multiple pages

by Andrzej Semeniuk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

1T3XT info <info <at> 1t3xt.info> writes:

> > 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:
>
> I honestly don't understand how you came up with that code.
> Please read the documentation and try some examples before
> writing code that hurts the eyes.

Please don't reply to my posts again.  If I wanted a smart remark
I wouldn't write "I'm new to iText".  Did you miss that?  It's
at the top of my post.






-------------------------------------------------------------------------
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@...
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

Re: adding through direct content on multiple pages

by Bruno Lowagie (iText) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrzej Semeniuk wrote:
> If I wanted a smart remark
> I wouldn't write "I'm new to iText".  Did you miss that?  It's
> at the top of my post.

I don't think anyone missed that, but it's not always accepted as
an excuse: see http://www.catb.org/%7Eesr/faqs/smart-questions.html

If people provide plenty of examples on their site (for instance on
the 1T3XT BVBA site: http://1t3xt.info/examples/itext-in-action.php ),
it's not very respectful to ask questions that aren't 'smart' in the
way Eric Raymond describes in his How-to.

Everybody is allowed to make himself ridiculous, but if it's done
in public, please understand that some people (I'd most people)
don't like the 'noise'. If you want a respectful answer, show some
respect by not asking questions that have been answered many times
before. By not reading the documentation first, you are 'stealing'
precious development time from the project.

best regards,
Bruno

-------------------------------------------------------------------------
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@...
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