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

Posted on 2006-03-21
Medium Priority
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());
                    // 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);

                        // 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
                        System.out.println(document.getPageNumber() );

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

plz advice
Question by:eldoz12
  • 2

Author Comment

ID: 16249114
plz help
LVL 23

Expert Comment

ID: 16249969

Author Comment

ID: 16250054
I need to use itext plz
LVL 30

Accepted Solution

Mayank S earned 1500 total points
ID: 16254530
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.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question