簡體   English   中英

從哪里開始:在我的 Android 應用程序中創建 PDF

[英]Where to start: Creating a PDF in my Android application

我正在創建一個 android 應用程序,其最終目標是能夠從用戶收集的數據中生成 PDF。 從哪里開始我的研究? 是否有我應該研究的 API 或工作室插件?

謝謝,祝周末愉快!

您需要 android.graphics.pdf 庫參考頁面是https://developer.android.com/reference/android/graphics/pdf/package-summary.html ,您可以使用以下代碼

 // create a new document
 PdfDocument mydocument = new PdfDocument();

 // crate a page description
 PageInfo mypageInfo = new PageInfo.Builder(new Rect(0, 0, 100, 100), 1).create();

 // start a page
 Page mypage = mydocument.startPage(mypageInfo);

 // draw something on the page
 View content = getContentView();
 content.draw(mypage.getCanvas());

 // finish the page
 mydocument.finishPage(mypage);
 . . .
 // add more pages
 . . .
 // write the document content
 mydocument.writeTo(getOutputStream());

 // close the document
 mydocument.close();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM