Android Api for PDF file creation

Asked

Viewed 274 times

1

What are the free file creation api available pdf in Android?

  • I may be wrong, but it seems to me opinion-based

1 answer

3


You can use the package classes android.graphics.pdf which are available from the API LEVEL 19 (Android 4.4).

Example taken from the documentation:

 // cria um novo documento
 PdfDocument document = new PdfDocument();

 // cria a descrição da página
 PageInfo pageInfo = new PageInfo.Builder(new Rect(0, 0, 100, 100), 1).create();

 // inicia a página
 Page page = document.startPage(pageInfo);

 // desenha alguma coisa na página
 View content = getContentView();
 content.draw(page.getCanvas());

 // finaliza a página
 document.finishPage(page);
 . . .
 // você pode adicionar mais páginas ...
 . . .
 // escreve o conteúdo do documento
 document.writeTo(getOutputStream());

 // fecha o documento
 document.close();

If you need to support previous versions of Android, a free option is the library Android PDF Writer

  • I can’t download the library

  • @Ludger If you’re talking about Android PDF Writer, open this link and click "Download snapshot"

  • Have some tutorial on how to use the library?

  • @Ludger you can see the documentation at this link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.