Perry Anderson
Perry Anderson

Reputation: 43

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!

Upvotes: 2

Views: 54

Answers (1)

Dr. X
Dr. X

Reputation: 2920

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

Upvotes: 1

Related Questions