我可以使用什么 C++ 库将 PDF 转换为 Windows 上的图像?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6603615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What C++ library can I use to convert a PDF to an image on windows?
提问by taxilian
I am working on a project in which I need to analyze images; the primary source of these images is the webcam, but recently we've been ask to add support for uploaded files and scanners. This is fine, for the most part, except they'd like us to be able to use documents in PDF format.
我正在做一个需要分析图像的项目;这些图像的主要来源是网络摄像头,但最近我们被要求添加对上传文件和扫描仪的支持。大多数情况下这很好,只是他们希望我们能够使用 PDF 格式的文档。
I need a raw pixel bitmap for the processing; on Mac, I can use CoreGraphics to load the PDF into an image buffer, but I'm not sure how to pull this off on Windows.
我需要一个原始像素位图进行处理;在 Mac 上,我可以使用 CoreGraphics 将 PDF 加载到图像缓冲区中,但我不确定如何在 Windows 上实现这一点。
To summarize: I need a C++ library (preferably with a license like BSD since this is closed-source, but potentially LGPL could work) that I can use to open a PDF file and export each page as a rendered image buffer bitmap.
总结一下:我需要一个 C++ 库(最好有像 BSD 这样的许可证,因为这是封闭源代码,但可能 LGPL 可以工作)我可以用来打开 PDF 文件并将每个页面导出为渲染图像缓冲区位图。
采纳答案by totowtwo
ImageMagick. Far and away the best library for reading and writing as many formats as possible http://www.imagemagick.org/script/index.php
ImageMagick。绝对是阅读和编写尽可能多格式的最佳库http://www.imagemagick.org/script/index.php
回答by Skhaz
- With swftools http://wiki.swftools.org/
- 使用 swftools http://wiki.swftools.org/
Example:
例子:
pdf2swf --pages 1 -T9 PDF_FILE.pdf -o temp.swf
swfrender temp.swf --output 1.png
- With poppler
- 带爆米花
Example using Qt http://bit.ly/8UksK6
使用 Qt http://bit.ly/8UksK6 的示例