// This code help to create a PDF file using java. that is stored in given file location.
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class pdfGeneration {
public static void main(String[] args) {
try {
OutputStream file = new FileOutputStream(new File("C:\\newPDF.pdf")); //Saved file path
Document document = new Document();
PdfWriter.getInstance(document, file);
document.open();
document.add(new Paragraph("Welcome to TECHIE SNACKS, Author Balamurugan.M.R"));
document.add(new Paragraph("This is simple pdf generation code \n Created on \t"+ new Date().toString()));
document.close();
file.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Notes: Please and Must include the " iText-2.1.5" jar file then only it works.
You will find the jar in given location " http://grepcode.com/snapshot/repo1.maven.org/maven2/com.lowagie/itext/2.1.5 ".
Enjoy the life :)
Subscribe to:
Post Comments (Atom)
Backup files to google drive using PHP coding
Dear All, To backup files to Google Drive using PHP coding, you can use the Google Drive API and the Google Client Library for PHP. Here...
-
Hi All, "No bootable device – insert boot disk and press any key" Solution ...
-
Hi All, Here I write a program for Email with an attached excel document using PHP. Also I design dynamic table for maintaining c...
-
Hi All, Here I write a program for Exchange Sort Using Java. The exchange sort compares each element of an array and swap those elemen...
No comments:
Post a Comment