Hello,
I have a class that is responsible for merging
existing PDF's with the option of using outlines or
bookmarks. I can get outlines to work using the
PdfCopy object but cannot get outilines to work with
PdfCopyFields. Are PdfOutlines not supported with
PdfCopyFields?
Here is the method that generates the exception:
public synchronized void
addOutlineHeaderToRoot(String aTitle,byte[] aDocument)
throws DocumentException,IOException
{
initialize();
HashMap myOutlineMap = new HashMap();
myOutlineMap.put("Page",Integer.toString(bookmarkPage));
myOutlineMap.put("Title",aTitle);
PdfReader myPdfReader = new
PdfReader(aDocument);
pdfCopyFields.addDocument(myPdfReader);
PdfOutline myRootOutline =
pdfCopyFields.getWriter().getDirectContent().getRootOutline();
pdfCurrentOutline =
new
PdfOutline(myRootOutline,PdfAction.gotoLocalPage(bookmarkPage,new
PdfDestination(PdfDestination.FITB),pdfCopyFields.getWriter()),aTitle);
bookmarkPage += myPdfReader.getNumberOfPages();
}
Here is the intialize method:
private void initialize()
throws DocumentException,IOException
{
if (pdfCopyFields == null)
{
byteArrayOutputStream = new
ByteArrayOutputStream(10240);
pdfCopyFields = new
PdfCopyFields(byteArrayOutputStream);
pdfCopyFields.open();
mergeCount = 0;
bookmarkPage = 1;
bookmarkList = new ArrayList();
if (mergeCode == MERGECODE_OUTLINES)
{
pdfCopyFields.getWriter().setViewerPreferences(PdfWriter.PageModeUseOutlines);
}
}
}
Here is the exception that is being thrown:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at
com.lowagie.text.pdf.PdfCopyFieldsImp.getPageReference(Unknown
Source)
at
com.lowagie.text.pdf.PdfAction.gotoLocalPage(Unknown
Source)
at
com.emagic.infrastructure.util.pdf.PdfMergeProcessor.addOutlineHeaderToRoot(PdfMergeProcessor.java:82)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions