我试图将TextView和EditText保存在ListView中,并让用户写入EditText并将其另存为PDF文件。如何将数组添加到文档?请看我的代码。
public List<Product> getProductList() {
//pseudo code to get product, replace your code to get real product here
productList = new ArrayList<>();
productList.add(new Product("item1 : " ," / / "));
productList.add(new Product("item2:" ,""));
productList.add(new Product("item3:" ,""));
return productList;
}
public void createPDF(View view){
//create document object
Document doc=new Document();
//output file path
String outpath=Environment.getExternalStorageDirectory()+"/HHelpFolder/allfile.pdf";
try {
//create pdf writer instance
PdfWriter.getInstance(doc, new FileOutputStream(outpath));
//open the document for writing
doc.open();
//add paragraph to the document
doc.add(new Paragraph(String.valueOf(productList)));
//close the document
doc.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
我应该使用Paragraph()
还是PageInfo
还是类似的东西?