Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Concatenate two pdf files

                         

In this program we are going to concatenate two pdf files into a  pdf file through java program. The all data of files  are concatenated into
the pdf. You can concentrate only two  files into a single file.   

In this example we need iText.jar file, without this jar file we never compile our application . The package we need to import are java.io. FileOutputStream,j com.lowagie.text.pdf.PdfCopy,com.lowagie.text.pdf.PdfReader,

The java.io.FileOutputStream  class is used to create file.T. com. lowagie.text.pdf.PdfCopy  class is used to make copies of  PDF documents and It extends PdfWriter. The com.lowagie.text.pdf.PdfReader class is used to read pdf from specified file. PdfReader class throws an IOException  and extends Object class

To make the program for concatenate pdf  files  firstly we will make a class Concanenate. Remember the name of the file should be such that, if any other person sees the example then just by seeing the name of the program he can understand what the program is going to do without seeing the code. 
The steps to execute this program:

  1. Makes minimum two pdf file.
  2. Download the  iTex.jar file .
  3. Copy iText.jar into lib directory and Set the class.
  4.  Make or Download the source code of program.
  5. Put the source code and pdf files into same directory.
  6. Compile the source code.
  7. Press enter to execute your program. 


Inside this class declare the main method which must throws Exception. After that follow the simple steps find the version:

  1. Makes two object of  PdfReader to read the files.
  2. Create object of  PdfCopyFields to create new pdf file where we copy two pdf files.
  3. add the two pdf into copy object by using addDocument() method.
  4.  close the copy object

The code of the program is given below:

import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.pdf.PdfCopyFields;
import com.lowagie.text.pdf.PdfReader;
public class Concatenate2PDF {
public static void main(String[] args)throws Exception {
System.out.println("Concatenate Two PDF"); 
PdfReader reader1 = new PdfReader("1PDF.pdf");
PdfReader reader2 = new PdfReader("2PDF.pdf");
PdfCopyFields copy = new PdfCopyFields(new FileOutputStream("concatenatedPDF.pdf"));
copy.addDocument(reader1);
copy.addDocument(reader2);
copy.close();
}
}

Download file1 example.

Download file2 example.

The output of the program is given below:

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
get url
using javascripting in
source code for chat p
jnlp
html:checkbox is check
how to write in pdf us
java 2d arraylist
Hibernate Min() Functi
JSF Fragments
Matrix Example in Java
how is application of
Netbeans JSF
netbens jsf
class float
Linux Administration L
JSF richfaces for tree
ั?à¹???ะà¸?ะà¸?à
breadcrumbs in jsp
decimals
java arrays
ejp
fireTableCellUpdated
swapping arrays
jsp tag
breakаÐ?????аÐ????а
spring
to retrieve a data gri
matcher
Migrating EJB 2.x app
read space character f
jsp bank examples
AddressAction
how to put logout code
HibernateTemplate
Visual Basic Date and
hibernate template
mobile testing
oracle.jdbc.driver.Dat
java mail with attache
sort array
ActionErrors in struts
ajax database conectiv
struts2 checkbox
facelets
swing close button
swap arrays in java
use normal submit butt
COMO USAR JOptionPane
Copy One Database Tabl
logic iterate
Photoshop Effects Crea
how to capture multipl
C : A Dialog: Program
partially selected che
storing text data to a
file chooser web appli
array java
excel from java
Photoshop Brushes Spar
jdk1.6.0_07 download
java is useful in netb
continue
4th and 5th normal for
JSP scriptlets
api struts
Player Class in the Ja
login
charts using POI
Table of Contents
zip code
how will we set enviro
<c:if
JSP:File Input type re
FCKediter
JSP:File Input Paramet
JavaFX Mobile
list iteration in java
JDBC with Mysql in Ecl
one-to-one- Mapping
flex
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.