Professional Documents
Culture Documents
/**
* Generates a PDF file with the text 'Hello World'
*
* @param args
* no arguments needed here
*/
public static void main(String[] args) {
System.out.println("Hello World");
SQLiteDatabase db = dbHandler.getWritableDatabase();
String filename="nameoffile.pdf";
Paragraph p3=new Paragraph(); // to enter value you have to create paragraph and add value in it
then paragraph is added into document
p3.add("Username : ");
document.add(p3);
// Code 2
table.addCell("CATEGORY");
table.addCell("BUDGET");
table.addCell("USED BUDGET");
while (c1.moveToNext()) {
table.addCell(type);
table.addCell(ex_bdgt);
table.addCell(used_bdgt);
int temp_ex=Integer.parseInt(ex_bdgt);
ttlbud=ttlbud+temp_ex;
int temp_used=Integer.parseInt(used_bdgt);
usdbud=usdbud+temp_used;
}
public void createPdf() throws FileNotFoundException, DocumentException {
while (c1.moveToNext()) {
String date = c1.getString(3);
String start = c1.getString(1);
String end = c1.getString(2);
String total = c1.getString(4);
table.addCell(date);
table.addCell(start);
table.addCell(end);
table.addCell(total);
}
document.add(table);
document.addCreationDate();
document.close();
}
Source :
http://stackoverflow.com/questions/12103863/display-sqlite-database-
content-in-pdf-format-in-android
http://www.vogella.com/tutorials/JavaPDF/article.html
http://stackoverflow.com/questions/10835316/problems-with-itext-trying-to-
create-a-pdf-file