Merging the pdf files together in java

Posted on 2004-09-07
Medium Priority
Last Modified: 2012-06-27
Hello experts,...

big task for me .. and seems difficult too.... but i am sure i will get the answers and suggestions here... and i am sure u won't let me down.......

My task is to merge all the voucher files and make one pdf file...

i explain the problem in brief....  we have vouchers for a particular transactions .. all these vouchers are scanned by an application .. on a scanner.. so we get different different 4-5 pdf files for all the vouchers for a particular transaction only... now we need to show one pdf ... means merge all those scanned vouchers pdf file into one ... and make that viewable to the client ...

the task would have been more easy if the development server environment was windows ... but we have sun solaris .. so i cannot run an vb program to merge the pdf files...

secondly i cannot enforce the scanning to merge all the pdf files ...as sometimes we receive some vouchers late .. and some of them are previously scanned... and some will be scanned later... so the activity has a specific time when to merge all the pdf files..

so i would rather make a scheduler to check for the status of transaction .. and then merge the files... so it should be a java program to merge the files....

the environment where i am suppose to do is ... jdk1.3 with weblogic 7.0 as application server. .. and sunsolaris is the O/S...

Awaiting for the answer at the earliest

it seems to be a difficult task for me ... so i am rating the question accordingly

Question by:JavaGuru2003
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1
LVL 92

Expert Comment

ID: 11994654
LVL 14

Expert Comment

ID: 11994788
LVL 14

Expert Comment

ID: 11994804


This tool is command line tool. But as it is open source you can change according to ur requirements

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI


Author Comment

ID: 11999324

i want java api which i can use and make a java program with a function to append... i don't need tool to append pdf . i want java program... a api to work with pdf so that i can append them in the program..

LVL 14

Expert Comment

ID: 11999367
Hello JavaGuru,  Multivalent is Open Source API only.

That tool was created as a part of API only. If you don't want to use that

you can directly use the API itself best regards
LVL 92

Expert Comment

ID: 12002204
Try the PDFAppender class in PJX


Author Comment

ID: 12005539
ver well said PDFAppender....

the constraint is i am working with jdk1.3 on weblogic server on sunsolaris and pjx is supported by j2se1.4 only .. it is written on their document ... prerequisite of using pjx... i have the code of pjx to append the files but i am getting errors for PDFAppender class.... if u want i can show u the error what i am getting


Author Comment

ID: 12013615
This is the error i receive when i use PJX appender to append pdf files
The code is

            List m = new ArrayList();
            m.add(new com.etymon.pjx.PdfManager(new com.etymon.pjx.PdfReader(new com.etymon.pjx.PdfInputFile(new File("@SCANNING_ROOT_VOUCHER_SERVER@/voucher/v_1.pdf")))));
            m.add(new com.etymon.pjx.PdfManager(new com.etymon.pjx.PdfReader(new com.etymon.pjx.PdfInputFile(new File("@SCANNING_ROOT_VOUCHER_SERVER@/voucher/v_2.pdf")))));
            com.etymon.pjx.PdfWriter w = new com.etymon.pjx.PdfWriter(new File("@SCANNING_ROOT_VOUCHER_SERVER@/voucher/onetwo.pdf"));
            com.etymon.pjx.util.PdfAppender a = new com.etymon.pjx.util.PdfAppender(m,w);
            PdfWriter w = new PdfWriter(new File("out.pdf"));

The error what i get is

    [javac] bad class file: /home/vijay/beaposeidon/lib/pjx/pjx.jar(com/etymon/pjx/PdfManager.class)
    [javac] class file has wrong version 48.0, should be 47.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    [javac]             m.add(new com.etymon.pjx.PdfManager(new com.etymon.pjx.PdfReader(new com.etymon.pjx.PdfInputFile(new File("")))));
    [javac]                                     ^
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -deprecation for details.
    [javac] 1 error


Accepted Solution

pjnola earned 800 total points
ID: 12033373
I recomment using the iText library (http://www.lowagie.com/iText/index.html).  It is open source (LGPL or MPL) and very capable.  The documentation includes an example of exactly what you are trying to do -- merge multiple PDFs into one.  See the source code at http://itext.sourceforge.net/src/com/lowagie/tools/concat_pdf.java

Author Comment

ID: 12034132

pjnola.. u are done .. this is what i exactly needed.... i knew to create pdf through itext.. but i was not aware we can also append two pdf using itext... anyways thanks for the comment it reduced my work ... and now its easy for me also to work with my project



Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

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…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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