0
在,如果我點擊「生成PDF」按鈕,然後PDF是在SD卡中建立。如果我打開這個PDF我的Android應用程序,我可以複製文本的android創建PDF,但我不韓元」這個。意思是我想只讀 與生成的PDF文件。與只讀權限
以下是代碼,
public void createPDF()
{
Document doc = new Document();
try {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/droidText";
File dir = new File(path);
if(!dir.exists())
dir.mkdirs();
Log.d("PDFCreator", "PDF Path: " + path);
System.out.println("PDF Path: "+ path);
File file = new File(dir, "sample.pdf");
FileOutputStream fOut = new FileOutputStream(file);
PdfWriter.getInstance(doc, fOut);
//open the document
doc.open();
Paragraph p1 = new Paragraph("Hi! I am generating my first PDF using DroidText");
Font paraFont= new Font(Font.COURIER);
p1.setAlignment(Paragraph.ALIGN_CENTER);
p1.setFont(paraFont);
//add paragraph to document
doc.add(p1);
} catch (DocumentException de) {
Log.e("PDFCreator", "DocumentException:" + de);
} catch (IOException e) {
Log.e("PDFCreator", "ioException:" + e);
}
finally
{
doc.close();
}
}
我沒有尚未測試,請告訴我,如果這個工程:) – 2014-09-02 07:30:29
你使用Apache POI? – 2014-09-02 09:07:34
我使用droidText 0.2罐子 – Harshad07 2014-09-02 09:10:19