// 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, Here I write a program for Exchange Sort Using Java. The exchange sort compares each element of an array and swap those elemen...
-
Dear All, 16. What is the difference between a function and a method in PHP? A function is a piece of code that can be called from anywhere...
-
Dear All, 1.What is the difference between == and === in PHP? == is a comparison operator that checks for equality of values, while === is ...
No comments:
Post a Comment