正确答案:使用打印和pdf插件,为了将 PDF 转换为图像,我们可以简单地通过以下方式实现:
// send pdfFile as params
imageFromPdfFile(File pdfFile) async {
final document = await lib.PDFDocument.openFile(pdfFile.path);
final page = await document.getPage(1);
final pageImage = await page.render(width: page.width, height: page.height);
await page.close();
print(pageImage.bytes);
//... now convert
// .... pageImage.bytes to image
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12742 次 |
| 最近记录: |