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

Posted on 2006-03-21
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

    Author Comment

    plz help
    LVL 23

    Expert Comment


    Author Comment

    I need to use itext plz
    LVL 30

    Accepted Solution

    Is this duplicate of ?

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    scoresIncreasing challenge 10 47
    scoresAverage challenge 8 58
    Basics of Drool Rule Engine with few samples 2 31
    @SBGen Method 3 16
    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now