Bruno, 

The code is:

String str = "D:\\images\\jackets.pdf";
String fileName = "D:\\images\\jackets2.pdf";
FileInputStream fis = new FileInputStream(str);
com.lowagie.text.pdf.PdfReader pdfReader = new
com.lowagie.text.pdf.PdfReader(fis);
byte meta[] = pdfReader.getMetadata();
int n = pdfReader.getNumberOfPages();

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);
}
List bookmarks =
com.lowagie.text.pdf.SimpleBookmark.getBookmark(pdfReader);
if (bookmarks == null)
    System.out.println("No bookmarks");
else {
    if (bookmarks.size() > 0)
        pdfWriter.setOutlines(bookmarks);
}
com.lowagie.text.pdf.PRAcroForm form = pdfReader.getAcroForm();
if (form != null) {
    pdfWriter.copyAcroForm(pdfReader);
}


pdfWriter.setXmpMetadata(meta);

document.close();
pdfReader.close();
fis.close();

BTW, in my test document there are no bookmarks or forms.  There is one
page, metadata and a thumbnail.


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



-----Original Message-----
From: bruno [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 13, 2006 8:49 AM
To: Segev, Eli
Cc: [email protected]
Subject: Re: [iText-questions] RE: getThumbnail

Segev, Eli wrote:

>Bruno,
>
>If there is a thumbnail already in a PDF document and the document is
>copied with iText code, the thumbnail will be lost.
>
That's not always true.
There are at least three ways to copy a PDF with iText code.
What way are you using?
br,
Bruno


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