tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 PDF > iTEXT > Line Separators

Line Separators 

iText is a free and open source library for creating and manipulating PDF documents in Java. The following example shows using various line separators in PDF document.

File Name  :  
com/bethecoder/tutorials/itext/tests/LineSeparatorExample.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.itext.tests;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.pdf.draw.DottedLineSeparator;
import com.itextpdf.text.pdf.draw.LineSeparator;

public class LineSeparatorExample {

  /**
   @param args
   @throws DocumentException 
   @throws FileNotFoundException 
   */
  public static void main(String[] argsthrows FileNotFoundException, DocumentException {

    Document document = new Document(PageSize.A4)
    PdfWriter.getInstance(document, new FileOutputStream("test20.pdf"));
    
    //Open the document before adding any content
    document.open();
    
    Paragraph paragraph = new Paragraph("BE THE CODER");
    document.add(paragraph);
    document.add(Chunk.NEWLINE);         //Blank line
    document.add(new DottedLineSeparator());  //Dotted line
    document.add(Chunk.NEWLINE);        //Blank line
    document.add(new LineSeparator());      //Thick line
    
    //Close the document
    document.close();
  }

}
   

It gives the following output,
test20.jpg


 
  


  
bl  br