We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Need to add content of one pdf file to the end of the other

eldoz12
eldoz12 asked
on
Medium Priority
256 Views
Last Modified: 2012-06-27
hello Experts ,
I am using itext for pdf manupilation ,
I have 2 files ,
I need to add the content of one file to the end of the other file , this is the code i have right now but for some reason instead of appending the content it completely overwrites the content of the file


PdfReader reader = new PdfReader(scr_filename.getInputStream());
                    reader.consolidateNamedDestinations();
                    // we retrieve the total number of pages
                    int n = reader.getNumberOfPages();
                    pageOffset += n;
                    List bookmarks = SimpleBookmark.getBookmark(reader);
                    if (bookmarks != null) {
                        if (pageOffset != 0)
                               SimpleBookmark.shiftPageNumbers(bookmarks, pageOffset, null);
                              master.addAll(bookmarks);
                    }


                        // step 1: creation of a document-object
                        document = new Document(reader.getPageSizeWithRotation(1));
                        // step 2: we create a writer that listens to the document
                        writer = new PdfCopy(document , new FileOutputStream(outFile,true));
                        // step 3: we open the document
                        document.open();
                        System.out.println(document.getPageNumber() );

                    // step 4: we add content
                    PdfImportedPage page;
                    for (int i = start_page; i < n; ) {
                        ++i;
                        page = writer.getImportedPage(reader, i);
                        writer.addPage(page);
                    }


plz advice
Comment
Watch Question

Author

Commented:
plz help
Top Expert 2005

Commented:

Author

Commented:
I need to use itext plz
Principal Technologist
CERTIFIED EXPERT
Commented:
Is this duplicate of http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21780746.html ?

You can post a link of 20 points instead of putting 500 points.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.