Solved

Merging the pdf files together in java

Posted on 2004-09-07
11
640 Views
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

vijay
0
Comment
Question by:JavaGuru2003
[X]
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
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11994654
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11994788
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11994804

http://multivalent.sourceforge.net/

This tool is command line tool. But as it is open source you can change according to ur requirements
http://multivalent.sourceforge.net/Tools/pdf/Merge.html

Regards
Sudhakar
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11994822
0
 

Author Comment

by:JavaGuru2003
ID: 11999324
Hello,

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..

0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
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
Sudhakar
0
 
LVL 92

Expert Comment

by:objects
ID: 12002204
Try the PDFAppender class in PJX

http://pjx.sourceforge.net/
0
 

Author Comment

by:JavaGuru2003
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

vijay
0
 

Author Comment

by:JavaGuru2003
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);
            a.append();
            w.close();
            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("http://192.168.0.169/voucher/v_1.pdf")))));
    [javac]                                     ^
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -deprecation for details.
    [javac] 1 error

0
 

Accepted Solution

by:
pjnola earned 200 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
0
 

Author Comment

by:JavaGuru2003
ID: 12034132
Hello..

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

thanks

vijay
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arguments to jar 5 40
How do I remove an object from a 3 53
Crystal Reports Licensing Questions 4 63
JDBC performance 8 29
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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 …

733 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