問題描述
是否有將大型 PDF 圖像存儲為文件(BMP/PNG/等)的工具或技巧? (Is there a tool or trick to store a large PDF image as a file (BMP/PNG/etc)?)
This is not strictly a programming question, but it's related to programming task I need to perform this in order to make an iPhone app.
I have a PDF file with a large image (say, a campus map) which I want to store as a PNG image to include as resource in the app. The image I want itself is much larger than the screen area (a lot larger, about 4000x4000 px). So I cannot just take a single screenshot of the PDF and save it as PNG. The only way I know to accomplish this is to take a number of screenshots of different parts of the image and manually stitch them together in an image editor. There will be 8-10 images to stitch together, if not more.
I wonder if anyone knows a more efficient way of doing this? Acrobat PDF reader does not allow this. Are there any tools or tricks in either Windows or MacOS I can use? Googling this did not bring anything that works.
參考解法
方法 1:
It would also be an option to use the PDF directly, iOS has pretty good support for reading PDFs, see the ZoomingPDFViewer sample code from Apple for an example.
As for your actual question, I'm not sure if there are existing tools that do exactly what you want here (though I'd guess there are), but it would also be pretty easy to make a small Cocoa command-line tool that converts a PDF to a number of bitmap tiles using Core Graphics.
方法 2:
You could use Ghostscript to convert your pdf to a png. A command like
gs -sDEVICE=png16m -r600 -o my_Map.png my_Map.pdf
would provide you a png from a pdf image.
(by antonio、omz、user694844)