Solved

Merging the pdf files together in java

Posted on 2004-09-07
11
631 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
  • 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bigHeights  challenge 13 56
array11 challenge 16 52
where is session ID cache stored 1 40
Java Server Faces parameter pass? 6 24
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

746 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

13 Experts available now in Live!

Get 1:1 Help Now