Hate to bring this up again, but I think I'm facing the same issue. The following method accepts a List of filenames, and then concatenates them to a single document. I have verified that each of the individual docs contain Bookmarks by opening them in Adobe Reader. In the final doc, they're missing. What am I missing?
I lifted 99% of the code from page 67 of the book.

public static void concatenateForms( List<String> fileNames, File outputFile )
   {
if ( outputFile != null && fileNames != null && fileNames.size() > 0 )
      {
         try
         {
PdfCopyFields target = new PdfCopyFields(new FileOutputStream(outputFile));
            for (String f : fileNames)
            {
log.info("Concatenating " + f + " to final document " + outputFile.getAbsolutePath());
               target.addDocument(new PdfReader(f));
            }
            target.close();
         }
         catch (FileNotFoundException fnfe)
         {
            fnfe.printStackTrace();
         }
         catch (DocumentException de)
         {
            de.printStackTrace();
         }
         catch (IOException ioe)
         {
            ioe.printStackTrace();
         }
      }
      else
      {
         log.error("No documents to concatenate");
      }
   }





On May 21, 2009, at 9:25 AM, Colin Freas wrote:


Ah, you beat me to it!

I just found section 2.2.7 in the iText book, which led me to the fairly clean code below.

Here was my solution:

        try {
            // Set up article file name and "merged" name...
String mergeFileName = articleFileName.replaceFirst(".pdf $",
                    ".merged.pdf");

            // New attempt...
PdfCopyFields mergedCopy = new PdfCopyFields(new FileOutputStream(mergeFileName)); mergedCopy.addDocument(new PdfReader(coverPdfOutputStream.toByteArray()));
            mergedCopy.addDocument(new PdfReader(articleFileName));
            mergedCopy.close();


Thanks for the response!

Good list.

-Colin

On Thu, May 21, 2009 at 11:15 AM, 1T3XT info <[email protected]> wrote:
Colin Freas wrote:
>
> Ah, that's make sense.
>
> So, what is the idiomatic way to copy the annotations along with the
> content stream?

It depends on your workflow, but my first answer would be:
use PdfCopy to concatenate the end result.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
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
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________
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
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

The human mind is an iterative processor, it never does anything right the first time. What it does well is to make improvements on every iteration (deMarco)



------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
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
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to