【问题标题】:How to convert Recyclerview as PDF in android?如何在 Android 中将 Recyclerview 转换为 PDF?
【发布时间】:2021-08-09 16:01:54
【问题描述】:

我已经使用卡片视图创建了带有项目列表的 Recyclerview。

我需要在 Android 中使用 Java 将 Recylerview 项目转换为 PDF。

我该怎么做?

【问题讨论】:

标签: java android android-recyclerview


【解决方案1】:

您可以使用自 API 19 起可用的PrintedPdfDocument 来实现此目的。

来自原始文档的示例实现如下:

// open a new document
PrintedPdfDocument document = new PrintedPdfDocument(context, printAttributes);
// start a page
Page page = document.startPage(0);
// 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();

【讨论】:

    猜你喜欢
    • 2016-04-03
    • 2013-03-22
    • 1970-01-01
    • 2023-02-21
    • 2017-04-04
    • 1970-01-01
    • 2015-06-26
    • 2020-04-26
    • 2012-05-28
    相关资源
    最近更新 更多