Problem solved!
See:
From: bruno
To: Aaron J Weber
Cc: [EMAIL PROTECTED]
Sent: Tuesday, January 17, 2006 2:57 AM
Subject: Re: [iText-questions] simply add a bookmark at the root of new
PDF for each concat'ed document?
Thanks Bruno!!
/NM
Normen Mueller wrote:
He iText folks!
I am not really sure if we are talking about a bug or a
misunderstanding on how to use the library. Here is
what I am trying to do:
Merge a couple of pdf files and create a bookmark for
each merged file in the resulting one. For example:
Merge the pdf files A, B, C and name the resulting one
Z. In Z should not only be the three documents but also
three bookmarks pointing to the first page of each
merges file.
Z
|- A
|- B
|- C
If I try to perform that task by the following lines of
code I always get an exception complaining a wrong page
number:
[...]
while (counter < rowCount)
{
String current = (String)
pomTable.getValueAt(counter, 0);
List<Integer> pages =
getPages((String) pomTable.getValueAt(counter, 1));
if (!pages.isEmpty())
{
PdfReader reader = new PdfReader(current);
reader.consolidateNamedDestinations();
int n = reader.getNumberOfPages();
// actions only for the first document
if (counter == 0)
{
document = new Document(reader.getPageSizeWithRotation(1));
writer = new PdfCopy(document, new FileOutputStream(outFile));
writer.setViewerPreferences(PdfCopy.PageModeUseOutlines);
document.open();
}
for (Iterator i = pages.iterator(); i.hasNext();)
{
int page = ((Integer) i.next()).intValue();
if (page > 0 && page <= n)
{
writer.addPage(writer.getImportedPage(reader, page));
writer.flush();
}
}
PRAcroForm form = reader.getAcroForm();
if (form != null)
writer.copyAcroForm(reader);
writer.freeReader(reader);
if ((Boolean) pomTable.getValueAt(counter, 2)
document.getPageNumber() > 0)
//document.getPageNumber is always 0 !!!!
{
// if i remove the getPageNumber condition in
// order to get into this if-statement then the
// exception is thrown.
PdfDestination d1 = new PdfDestination(PdfDestination.FIT);
PdfOutline root = writer.getRootOutline();
new PdfOutline(root, d1, "Document " + counter);
}
}
counter++;
}
Thanks in advance for your help...
/Normen
-------------------------------------------------------
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&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions