I can reproduce the problem and I have emailed you the file in the past.
The issue may be that my test of a good thumbnail is Adobe Illustrator.
If AI sees the thumbnail, the thumbnail is fine. What is your test?
The two lines that I have added following your example are:
copy.setViewerPreferences(PdfWriter.PageModeUseThumbs);
copy.setOutlines(SimpleBookmark.getBookmark(reader));
Now we have identical code, but AI does not see the thumbnail that
exists in the original file, but not in the copy.
------------
Eli Segev
-----Original Message-----
From: bruno [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 30, 2006 2:38 AM
To: Segev, Eli; '[email protected]'
Subject: Re: Including a Thumbnail in a PDF File
Segev, Eli wrote:
>Bruno,
>
>I would like to submit a request to correct the problem in copying
>thumbnails from one PDF file to another. How do I do that?
>
>
The problem with this kind of questions, is that an we may be
talking about a completely different problem. You say it doesn't
work, but if we can't reproduce the problem, we can't help you.
The following code snippet is taken from a Servlet I am using.
The doPost gets a String referring to a resource (an existing
PDF file with thumbnails) and String array with page numbers
(if not an HTML page is returned). The String[] is turned into
a comma separated sequence of page numbers.
PdfReader and PdfCopy are used to return a selection of pages
and the Thumbnails panel is opened because thumbnails are
important in this example. This works for me. I hope it works for you.
public void makePdf(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try {
String[] pages = request.getParameterValues("page");
// take the message from the URL or create default message
StringBuffer selection = new StringBuffer();
if (pages.length == 0) {
response.setContentType("text/html");
makeHtml(response.getOutputStream(), "You must at least
choose one!");
return;
}
selection.append(pages[0]);
for (int i = 1; i < pages.length; i++) {
selection.append(",");
selection.append(pages[i]);
}
PdfReader reader = new PdfReader(resource);
reader.selectPages(selection.toString());
int p = reader.getNumberOfPages();
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfCopy copy = new PdfCopy(document, baos);
document.open();
for (int i = 0; i < p; ) {
i++;
copy.addPage(copy.getImportedPage(reader, i));
}
copy.setViewerPreferences(PdfWriter.PageModeUseThumbs);
copy.setOutlines(SimpleBookmark.getBookmark(reader));
document.close();
// setting some response headers
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
// setting the content type
response.setContentType("application/pdf");
// the contentlength is needed for MSIE!!!
response.setContentLength(baos.size());
// write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();
} catch (Exception e) {
System.out.println("Error in " + getClass().getName() + "\n"
+ e);
throw(new ServletException(e));
}
}
-------------------------------------------------------
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