0
我有這個移動應用程序,我需要將數據庫的某些行導出爲pdf。我需要有一個pdf結構才能正確放置信息。這是我有的代碼,但由於某些原因,PDF文件空白。主要目標是在開頭有一個標題,然後是數據庫中的一行,然後是「輸入」,並再次顯示數據庫查詢結果中的另一行。希望有人能幫助我?在先進的感謝:)如何用iTextPDF創建段落?
Document doc = new Document();
String outPath = Environment.getExternalStorageDirectory() + "/"+nomePDF+".pdf";
try {
PdfWriter.getInstance(doc, new FileOutputStream(outPath));
Font f=new Font(Font.FontFamily.TIMES_ROMAN,30.0f,Font.UNDERLINE, BaseColor.RED);
Paragraph p = new Paragraph("Group/Machine",f);
p.setAlignment(Element.ALIGN_CENTER);
p.setSpacingAfter(40f);
doc.add(p);
bd = new Databse(MainActivity.this);
Cursor c = bd.getGroupsNamesMachines();
if (c.moveToFirst()) {
do {
String group = c.getString(c.getColumnIndex("groupname"))+"\n"+c.getString(c.getColumnIndex("otherrow"));
doc.add(new Paragraph(group));
doc.add(new Paragraph("\n"));
} while (c.moveToNext());
}
doc.open();
doc.close();
我的目標的結構是:
TITLE
row1
row2
row2
row2