English 中文(简体)
iText - Overview
  • 时间:2024-12-27

iText - Overview


Previous Page Next Page  

The Portable Document Format (PDF) is a file format that helps to present data in a manner that is independent of apppcation software, hardware, and operating systems. Each PDF file holds description of a fixed-layout flat document, including text, fonts, graphics, and other information needed to display it.

There are several pbraries available to create and manipulate PDF documents through programs, such as −

    Adobe PDF Library − This pbrary provides API in languages such as C++, .NET and Java. Using this, we can edit, view, print, and extract text from PDF documents.

    Formatting Objects Processor − Open-source print formatter driven by XSL Formatting Objects and an output independent formatter. The primary output target is PDF.

    PDF Box − Apache PDFBox is an open-source Java pbrary that supports the development and conversion of PDF documents. Using this pbrary, you can develop Java programs that create, convert and manipulate PDF documents.

    Jasper Reports − This is a Java reporting tool which generates reports in PDF document including Microsoft Excel, RTF, ODT, comma-separated values and XML files.

What is iText?

Similar to above psted software s iText is a Java PDF pbrary using which, you can develop Java programs that create, convert, and manipulate PDF documents.

Features of iText

Following are the notable features of iText pbrary −

    Interactive − iText provides you classes (API s) to generate interactive PDF documents. Using these, you can create maps and books.

    Adding bookmarks, page numbers, etc − Using iText, you can add bookmarks, page numbers, and watermarks.

    Sppt & Merge − Using iText, you can sppt an existing PDF into multiple PDFs and also add/concatenate additional pages to it.

    Fill Forms − Using iText, you can fill interactive forms in a PDF document.

    Save as Image − Using iText, you can save PDFs as image files, such as PNG or JPEG.

    Canvas − iText pbrary provides you a Canvas class using which you can draw various geometrical shapes on a PDF document pke circle, pne, etc.

    Create PDFs − Using iText, you can create a new PDF file from your Java programs. You can include images and fonts too.

IText Environment

Follow the steps given below to set the iText environment on Ecppse.

Step 1 − Install Ecppse and open a new project in it as shown below.

Ecppse Project

Step 2 − Create an iTextSample project as shown below.

New Project Window

Step 3 − Right-cpck on the project and convert it into a Maven project as shown below. Once you convert it into Maven project, it will give you a pom.xml where you need to mention the required dependencies. Thereafter, the jar files of those dependencies will be automatically downloaded into your project.

Maven Configuration

Step 4 − Now, in the pom.xml of the project, copy and paste the following content (dependencies for iText apppcation) and refresh the project.

Using pom.xml

Convert the project into Maven project and add the following content to its pom.xml.

<project xmlns="http://maven.apache.org/POM/4.0.0" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
   http://maven.apache.org/xsd/maven-4.0.0.xsd">   
   
   <modelVersion>4.0.0</modelVersion>   
   <groupId>SanthoshExample</groupId>   
   <artifactId>SanthoshExample</artifactId>   
   <version>0.0.1-SNAPSHOT</version>   
   <build>     
      <sourceDirectory>src</sourceDirectory>     
      <plugins>       
         <plugin>         
            <artifactId>maven-compiler-plugin</artifactId>         
            <version>3.5.1</version>         
            <configuration>           
               <source>1.8</source>           
               <target>1.8</target>      
            </configuration>       
         </plugin>     
      </plugins>   
   </build>     
   
   <dependencies>     
      <!-- always needed -->     
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>kernel</artifactId>         
         <version>7.0.2</version>     
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>io</artifactId>         
         <version>7.0.2</version>     
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>layout</artifactId>         
         <version>7.0.2</version>
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>forms</artifactId>         
         <version>7.0.2</version>    
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>pdfa</artifactId>         
         <version>7.0.2</version>     
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>sign</artifactId>         
         <version>7.0.2</version>     
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>barcodes</artifactId>         
         <version>7.0.2</version>     
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>font-asian</artifactId>         
         <version>7.0.2</version>     
      </dependency>  
      
      <dependency>         
         <groupId>com.itextpdf</groupId>         
         <artifactId>hyph</artifactId>         
         <version>7.0.2</version>    
      </dependency> 
   </dependencies>
   
</project>

Finally, if you observe the Maven dependencies, you can observe that all the required jar files were downloaded.

iText Sample Apppcation Advertisements