在adroid studio中添加图库中的图片并保存到pdf中。

问题描述 投票:0回答:1

我在android studio(Java)中做了一个应用程序,可以在文本框中填写一些简短的数据。另外应用程序有两个按钮,一个用于从图库中加载图片,一个用于将完整的数据保存到pdf。我可以成功地保存所有的文本数据,但有问题的加载图像。图片被成功加载到应用程序中,但我不知道如何将其保存到pdf中。Image is loaded as an ImageView object.Just to mention for pdf part I use itext.

Pls, help with hints or code for saving ImageVIew object to pdf file.

android pdf imageview itext
1个回答
0
投票

看成 PdfDocument

文件中的例子

  // 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();
© www.soinside.com 2019 - 2024. All rights reserved.