Android Guides | Samples

Android.Graphics.Pdf Namespace

Remarks

Contains classes for manipulation of PDF content.

Classes

TypeReason
PdfDocument

java Example

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

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

 // start a page
 Page page = document.startPage(pageInfo);

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

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

 // close the document
 document.close();
PdfDocument+Page
PdfDocument+PageInfo
PdfDocument+PageInfo+Builder
PdfRenderer

Print preview and print output

  • Respect the property whether the document would like to be scaled for printing as per PdfRenderer.ShouldScaleForPrinting.
  • When scaling a document for printing the aspect ratio should be preserved.
  • Do not inset the content with any margins from the PrintAttributes as the application is responsible to render it such that the margins are respected.
  • If document page size is greater than the printed media size the content should be anchored to the upper left corner of the page for left-to-right locales and top right corner for right-to-left locales.
PdfRenderer+Page
PdfRenderModeEnumerates values returned by several types and taken as a parameter of the PdfRenderer+Page.Render member.