I need to copy the entire pdf document as it is to the target pdf and also
need to stamp some media objects to particular location in pdf document.
I can copy the entire content as it is but all the cross-references ( links
in bookmarks, toc and normal xrefs) are lost somehow. Could somebody help
with this to copy the content alongwith the links also? below is the snippet
of the code:


         PdfReader reader = new PdfReader(inputFile);
         int numberofPages = reader.getNumberOfPages();

         Document document = new Document();
         PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(outputFile));

         document.open();

         int currentPage = 0;
         ArrayList bookmarks = new ArrayList();
         bookmarks.addAll(SimpleBookmark.getBookmark(reader));
         reader.consolidateNamedDestinations();
         PdfContentByte cb = writer.getDirectContent();

         for (int i = currentPage; i < numberofPages;) {
             ++currentPage;
        ++i;
             document.newPage();
             PdfImportedPage pageToBeCopied = writer.getImportedPage(reader,
currentPage);
        cb.addTemplate(pageToBeCopied, 1f, 0, 0, 1f, 0, 0);
        System.out.println("Processing page: " + currentPage);
        if ( currentPage == 20)
           {
             document.add(new Annotation(100, 200, 300, 400, "scrollbar.swf",
"application/x-shockwave-flash", true));

                  PdfFileSpecification fs =
PdfFileSpecification.fileExtern(writer, "scrollbar.swf");
                  writer.addAnnotation(PdfAnnotation.createScreen(writer,
new Rectangle(100, 200, 300, 400), "scrollbar.swf", fs,
"application/x-shockwave-flash", true));
           }
        writer.setOutlines(bookmarks);

             }

        document.close();
-- 
View this message in context: 
http://www.nabble.com/Need-to-importpage-to-target-pdf-alongwith-all-the-cross-references-in-existing-pdf-file-tp22101625p22101625.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to