Solved

Merging the pdf files together in java

Posted on 2004-09-07
11
634 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 79
Exception after setting jdbc session management 2 52
Eclipse IDE - Cannot copy/paste from console output 8 127
Error with Java/Cache JDBC Classpath 2 31
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

920 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

15 Experts available now in Live!

Get 1:1 Help Now