简体   繁体   English

从哪里开始:在我的 Android 应用程序中创建 PDF

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

I'm creating an android app with the ultimate goal of being able to generate a PDF from the data collected from the user.我正在创建一个 android 应用程序,其最终目标是能够从用户收集的数据中生成 PDF。 Where is a good place to start my research?从哪里开始我的研究? Is there an API or studio plugin that I should be researching?是否有我应该研究的 API 或工作室插件?

Thanks and have a great weekend!谢谢,祝周末愉快!

You need android.graphics.pdf library reference page is https://developer.android.com/reference/android/graphics/pdf/package-summary.html and u can use below codes您需要 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