简体   繁体   中英

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. Where is a good place to start my research? Is there an API or studio plugin that I should be researching?

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

 // 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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM