Paulo,

One more comment: I don't add additional content to the PDF file.  I do
change the metadata, though.  Is your comment below still valid in this
case?

------------
Eli Segev



-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 18, 2006 4:14 PM
To: Segev, Eli; Antoine
Cc: [email protected]
Subject: Re: [iText-questions] PDF Version

You can't add content to PdfCopy. Assemble your pdf with PdfCopy and
then 
modify the resulting pdf with PdfStamper.

Paulo

----- Original Message ----- 
From: "Segev, Eli" <[EMAIL PROTECTED]>
To: "Antoine" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Tuesday, April 18, 2006 3:03 PM
Subject: RE: [iText-questions] PDF Version


Antoine,

Very funny!

I am looking for code that copies the content of file to another.  The
code also some changes to the content.  This part of the code is omitted
here for clarity.  Here is the code as it uses iText:

            String str = "D:\\images\\jackets.pdf";
            String fileName = "D:\\images\\jackets2.pdf";
            com.lowagie.text.pdf.PdfReader pdfReader = new
com.lowagie.text.pdf.PdfReader(str);
            pdfReader.consolidateNamedDestinations();
            List bookmarks =
com.lowagie.text.pdf.SimpleBookmark.getBookmark(pdfReader);
            if (bookmarks == null)
                System.out.println("No bookmarks");
            else {
                System.out.println("There are " + bookmarks.size() + "
bookmarks");
                if (bookmarks.size() > 0)
                    pdfWriter.setOutlines(bookmarks);
            }
            byte meta[] = pdfReader.getMetadata();
            int n = pdfReader.getNumberOfPages();
            System.out.println("number of pages " + n);
            // we retrieve the size of the first page
            com.lowagie.text.Rectangle psize = pdfReader.getPageSize(1);

            com.lowagie.text.Document document = new
com.lowagie.text.Document(psize);
            FileOutputStream fos = new FileOutputStream(fileName);
            com.lowagie.text.pdf.PdfCopy pdfWriter = new
com.lowagie.text.pdf.PdfCopy(document, fos);
            document.open();
            for (int i = 1; i <= n; i++) {
                com.lowagie.text.pdf.PdfImportedPage page =
pdfWriter.getImportedPage(pdfReader, i);
                pdfWriter.addPage(page);
            }
            pdfWriter.setViewerPreferences(pdfWriter.PageModeUseThumbs);

pdfWriter.setOutlines(com.lowagie.text.pdf.SimpleBookmark.getBookmark(pd
fReader));
            com.lowagie.text.pdf.PRAcroForm form =
pdfReader.getAcroForm();
            if (form != null) {
                pdfWriter.copyAcroForm(pdfReader);
            }

---------------------------------------------------
//  Some missing code here.

            pdfWriter.setXmpMetadata(meta);
            document.close();
            pdfReader.close();

------------
Eli Segev



-----Original Message-----
From: Antoine [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 18, 2006 9:55 AM
To: Segev, Eli
Cc: [email protected]
Subject: Re: [iText-questions] PDF Version

How about *nix
$ cp a.pdf b.pdf
or windows
copy a.pdf b.pdf

I guess you will have to be a little more explicit about what you mean
by "copy a PDF file". Why do you want to copy the file? Do you want
the whole thing? Why not use std java methods? Do you want the pages
only? Only some pages?
Cheers
Antoine

On 18/04/06, Segev, Eli <[EMAIL PROTECTED]> wrote:
> Antoine,
>
> Do you have a sample code that copies a PDF file?
>
> ------------
> Eli Segev
>
>
>
> -----Original Message-----
> From: Antoine [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 18, 2006 3:19 AM
> To: Segev, Eli
> Cc: [email protected]
> Subject: Re: [iText-questions] PDF Version
>
> Eli,
> iText is not focused on reading/modifying pdf - iText excels in pdf
> creation. I had a quick look and it looks possible, but you will spend
> a lot of time doing it. It would probably be quicker to write your own
> code to do it directly...
> Just use pdfbox - you will have the creator/producer in about 5 lines
> of code, and it is a good library (useful for those situations where
> iText doesn't have the functionality). I can send you pdfbox code if
> that is an option.
> Cheers
> Antoine
>
>
> On 17/04/06, Segev, Eli <[EMAIL PROTECTED]> wrote:
> > Antoine,
> >
> > Do you know how iText does this?  I could not find it in the
Javadoc.
> >
> > Thanks for the tip about pdfbox.
> >
> > ------------
> > Eli Segev
> >
> >
> >
> > -----Original Message-----
> > From: Antoine [mailto:[EMAIL PROTECTED]
> > Sent: Saturday, April 15, 2006 5:54 AM
> > To: Segev, Eli
> > Cc: [email protected]
> > Subject: Re: [iText-questions] PDF Version
> >
> > On 14/04/06, Segev, Eli <[EMAIL PROTECTED]> wrote:
> > > PDF files can be created in different ways and with different
> > software.
> > > Is it possible to find out what version of the PDF library is used
> in
> > > the creation of a document?
> >
> > iText probably does this but pdfbox certainly does.
> >
>
http://pdfbox.org/javadoc/org/pdfbox/pdmodel/PDDocumentInformation.html
> > Cheers
> > Antoine
> >
> > --
> > This is where I should put some witty comment.
> >
>
>
> --
> This is where I should put some witty comment.
>


--
This is where I should put some witty comment.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to