如何解决生成的 pdf 不包含整个视图它被剪切
生成的pdf不包含整个视图(它被剪切了)
我尝试了两种从 android 视图生成 pdf 的方法:
PdfDocument document = new PdfDocument();
PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(1200,1200,1).create();
PdfDocument.Page page = document.startPage(pageInfo);
content.draw(page.getCanvas());
document.finishPage(page);
在上面最初当我将宽度保持为 500 时。
生成的pdf是一个剪辑的。整个景色都不在那里。
所以我尝试将宽度增加到 1200 和 90% 的东西
以pdf格式出现在页面内。所以增加它会使视图
完全出现。但这是一个手动过程。有没有办法正确地做到这一点?
此外,当使用 PdfDocument 类时,我们没有选择
指定 pdf 媒体大小,如 PrintedPdfDocument。
以下是我尝试使用 PrintedPdfDocument 的代码。但这也削减了
在生成的 pdf 中查看,并且无法像以前的方法那样使其成为完整视图。
View content = findViewById(R.id.topLL);
PrintAttributes printAttrs = new PrintAttributes.Builder().
setMediaSize(PrintAttributes.MediaSize.ISO_A4).
setMinMargins(PrintAttributes.Margins.NO_MARGINS).
setResolution(new PrintAttributes.Resolution("id","label",300,300)).
build();
PrintedPdfDocument document = new PrintedPdfDocument(this,printAttrs);
PdfDocument.Page page = document.startPage(0);
content.draw(page.getCanvas());
document.finishPage(page);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。