Add data to an exisiting pdf

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

Add data to an exisiting pdf

by javaiTextUser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just started using iText and had a question. I need to take an existing pdf and add some more data to it. If there is space to add data to the last page of the existing pdf, the new data needs to be appended there. If not, then I need to add a new page to the pdf and put the data in there. Is there a way to do this using iText. Thanks.

Re: Add data to an exisiting pdf

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

Reply to Author | View Threaded | Show Only this Message

javaiTextUser wrote:
> I just started using iText and had a question.

Please subscribe to the mailing list if you want answers.

> I need to take an
> existing pdf and add some more data to it. If there is space to add data
> to the last page of the existing pdf, the new data needs to be appended
> there. If not, then I need to add a new page to the pdf and put the data
> in there. Is there a way to do this using iText. Thanks.

Add data to an existing PDF: that's easy.
It's explained on different places on the net and in the book.

Find out the available white space on a page: that's difficult
(I'd say impossible) with iText.

Summarized: it's possible, but only if you know the coordinates
of the white space (and that may be impossible).

br,
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

Re: Add data to an exisiting pdf

by javaiTextUser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is what I need to do -

1. Create a pdf file from given data (Easy using iText)


2. At a later point, reopen this pdf and add some more data to it
I am not quite sure how to do this. Is there a way to get all the data in the pdf into a byte array, add more data to the byte array and recreate a pdf?


Bruno Lowagie (iText) wrote:
javaiTextUser wrote:
> I just started using iText and had a question.

Please subscribe to the mailing list if you want answers.

> I need to take an
> existing pdf and add some more data to it. If there is space to add data
> to the last page of the existing pdf, the new data needs to be appended
> there. If not, then I need to add a new page to the pdf and put the data
> in there. Is there a way to do this using iText. Thanks.

Add data to an existing PDF: that's easy.
It's explained on different places on the net and in the book.

Find out the available white space on a page: that's difficult
(I'd say impossible) with iText.

Summarized: it's possible, but only if you know the coordinates
of the white space (and that may be impossible).

br,
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@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

Re: Add data to an exisiting pdf

by wasegraves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-------------- Original message ----------------------
From: javaiTextUser <sangeetha.pisharody@...>

>
>
> This is what I need to do -
>
> 1. Create a pdf file from given data (Easy using iText)
>
>
> 2. At a later point, reopen this pdf and add some more data to it
> I am not quite sure how to do this. Is there a way to get all the data in
> the pdf into a byte array, add more data to the byte array and recreate a
> pdf?

You really, really need to get a copy of the book, if you don't wish to be caught for fraud with the name you've assumed.

As a *real* Java-iText user, you should have a copy of the book. You can get it in minutes from www.manning.com.

Once you have the book, see the HelloWorldStamper example in Chapter 2. This shows you just one of the ways that you can do what you've decribed.

Best regards,
Bill Segraves

P.S. I see you're with GE. Surely, GE would benefit from hiring Bruno to do a seminar on iText.

-------------------------------------------------------------------------
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: Add data to an exisiting pdf

by 1T3XT info :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

javaiTextUser wrote:
> This is what I need to do -
>
> 1. Create a pdf file from given data (Easy using iText)

OK, maybe you can mark the end of the file by adding
some annotation (an invisible field?) on the last page.

> 2. At a later point, reopen this pdf and add some more data to it
> I am not quite sure how to do this. Is there a way to get all the data in
> the pdf into a byte array, add more data to the byte array and recreate a
> pdf?

When you reopen the document, ask the document for that
invisible field and its coordinates. Then use PdfStamper
to add new content and new pages.

I'd also follow Bill's advice ;-)
--
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: Add data to an exisiting pdf

by Leonard Rosenthol :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

An alternative (and, IMO, a better) solution to putting the data in a  
hidden annotation is to put it in an embedded file/attachment in a  
standard format (CSV, XML, etc.).   That makes it cleaner, more  
standard and easier to access for both you and others.  (and should  
also be less code to write ;)

Leonard

On May 17, 2008, at 6:02 AM, 1T3XT info wrote:

> javaiTextUser wrote:
>> This is what I need to do -
>>
>> 1. Create a pdf file from given data (Easy using iText)
>
> OK, maybe you can mark the end of the file by adding
> some annotation (an invisible field?) on the last page.
>
>> 2. At a later point, reopen this pdf and add some more data to it
>> I am not quite sure how to do this. Is there a way to get all the  
>> data in
>> the pdf into a byte array, add more data to the byte array and  
>> recreate a
>> pdf?
>
> When you reopen the document, ask the document for that
> invisible field and its coordinates. Then use PdfStamper
> to add new content and new pages.
>
> I'd also follow Bill's advice ;-)
> --
> 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
>


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