您好,我正在尝试使用iText库从 Recyclerview 创建 PDF 输出文件。经过几个小时的努力,我能够从 recyclerview 创建 PDF。
以下是我用来创建 PDF 的类
主类的代码
private void getPrint() {
ArrayList<View> viewArrayList = mAdapter.getPrintView(); // A function from Adapter class which returns ArrayList of VIEWS
Document document = new Document(PageSize.A4);
final File file = new File(getStorageDir("PDF"), "print.pdf");
try {
PdfWriter.getInstance(document, new FileOutputStream(file));
} catch (DocumentException | FileNotFoundException e) {
e.printStackTrace();
}
for (int im = 0; im < viewArrayList.size(); im++) {
// Iterate till the last of the array list and add each …Run Code Online (Sandbox Code Playgroud) 示例数据是Android Studio团队的一项重大发明.它使设计开发变得非常简单.所以我的实际问题是,我们如何从Java/Kotlin类而不是XML访问样本数据.