Create ZapfDingbats List In pdf in java


In this core java tutorial we will learn Create ZapfDingbats List In pdf in java using iText library - core java tutorial with program and examples.

First create ZapfDingbatsList (com.itextpdf.text.ZapfDingbatsList) and then add ListItems (com.itextpdf.text.ListItem) in ZapfDingbatsList using add method of ZapfDingbatsList (zapfDingbatsList.add(new ListItem("Item 1"))).


How to Create Roman List In pdf in java - iText java tutorial

How to Create Ordered List In pdf in java using iText - iText java tutorial

Creating the UnOrdered List In pdf in java - iText java tutorial example

How to Create Lists And SubLists In Pdf in java - iText java tutorial




Download jars required to execute program >

Or, you may download jars from here.


Program/Example how to Create ZapfDingbats List In pdf in java  - Using iText library - core java tutorial

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.ZapfDingbatsList;
import com.itextpdf.text.pdf.PdfWriter;
/**
*
*  How to Create ZapfDingbats List In Pdf program -
*  Using iText library - core java tutorial
*
*/
public class CreateZapfDingbatsListExample {
   public static void main(String[] args) {
          try {
                 String pdfFilePath = "E:/Create ZapfDingbatsList In Pdf Example.pdf";
                
                 OutputStream fos = new FileOutputStream(new File(pdfFilePath));
                 Document document = new Document();
                 PdfWriter.getInstance(document, fos);
                 document.open();
                 document.add(new Paragraph("This is ZapfDingbatsList1 "));
                 //Create ZapfDingbatsList -  in PDF using iText library in java
                 //43 is bullet type and
                 //10 is space between bullet and list items
                 ZapfDingbatsList  zapfDingbatsList  = new ZapfDingbatsList(43, 20);
                 //Add items in ZapfDingbatsList -  in PDF using iText library in java
                 zapfDingbatsList .add(new ListItem("Item 1"));
                 zapfDingbatsList .add(new ListItem("Item 2"));
                 zapfDingbatsList .add(new ListItem("Item 3"));
                 zapfDingbatsList .add(new ListItem("Item 4"));
                 zapfDingbatsList .add(new ListItem("Item 5"));
                 document.add(zapfDingbatsList );
                
                 document.add(new Paragraph("\nThis is ZapfDingbatsList2 "));
                 //Create ZapfDingbatsList -  in PDF using iText library in java
                 //45 is bullet type and
                 //20 is space between bullet and list items
                 ZapfDingbatsList  zapfDingbatsList2  = new ZapfDingbatsList(45, 40);
                 //Add items in ZapfDingbatsList -  in PDF using iText library in java
                 zapfDingbatsList2 .add(new ListItem("Item 1"));
                 zapfDingbatsList2 .add(new ListItem("Item 2"));
                 zapfDingbatsList2 .add(new ListItem("Item 3"));
                 zapfDingbatsList2 .add(new ListItem("Item 4"));
                 zapfDingbatsList2 .add(new ListItem("Item 5"));
                 document.add(zapfDingbatsList2 );
                
                 document.close();             
                 fos.close();
                
                 System.out.println("PDF created in >> "+ pdfFilePath);
          } catch (Exception e) {
                 e.printStackTrace();
          }
   }
}
/* OUTPUT of above program/Example -
PDF created in >> E:/Create ZapfDingbatsList In Pdf Example.pdf
*/



PDF formed after executing above java program(Create ZapfDingbats List In pdf in java) will look like this >


Summary -
So in this core java tutorial we Created ZapfDingbats List In pdf in java using iText library - core java tutorial with program and examples.
We first created ZapfDingbatsList (com.itextpdf.text.ZapfDingbatsList) and then added ListItems (com.itextpdf.text.ListItem) in ZapfDingbatsList using add method of ZapfDingbatsList (zapfDingbatsList.add(new ListItem("Item 1"))).



Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.

References >



RELATED LINKS>

iText library tutorial in java - How to Create and work with PDF files in java


Creating first pdf and setting attributes using itext in java - iText tutorial >

Create the first Pdf Example Using iText library in java - iText java tutorial example

Setting Pdf Attributes like Title, Author, Creator, subject, Keywords, Header and CreationDate in java



Creating PASSWORD PROTECTED PDF in java - iText tutorial >

How to Create Password Protected Pdf in java - iText Example





No comments:

Post a Comment