• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

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

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
0
eldoz12
Asked:
eldoz12
  • 2
1 Solution
 
eldoz12Author Commented:
plz help
0
 
brettmjohnsonCommented:
0
 
eldoz12Author Commented:
I need to use itext plz
0
 
Mayank SAssociate Director - Product EngineeringCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now