从哪里开始:在我的 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();