AddingChunkToParagraphPDF.java Source code

Java tutorial

Introduction

Here is the source code for AddingChunkToParagraphPDF.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class AddingChunkToParagraphPDF {
    public static void main(String[] args) {
        try {
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document,
                    new FileOutputStream("AddingChunkToParagraphPDF.pdf"));
            document.open();
            Paragraph p = new Paragraph();
            p.add(new Chunk("Font.TIMES_ROMAN", new Font(Font.TIMES_ROMAN, 12)));
            document.add(new Paragraph(p));

            document.close();
        } catch (Exception de) {
            de.printStackTrace();
        }
    }
}