简体   繁体   中英

iOS Photo to PDF via Quartz2D - Specify Pixel Size AND Resolution

We need to output a pdf from an iOS app that has a specific pixel size and resolution, for example: 1200px x 1800px @ 300dpi.

Currently we are using the Quartz2D Framework which says it is 'resolution independent'. I can generate a pdf that is 1200 x 1800px, but when I check this in PSD the resolution is 144.

Is there a way within iOS, to specify the output size AND resolution, via Quartz2D or via another method?

PDF files are vector files and their page size is given in points (1/72 inches), not in pixels.
The resolution is used when converting a vector file to a raster file and it specifies how many pixels in the raster file correspond to a measure unit in the vector file. 300 dpi mean that 300 pixels in the raster file correspond to 1 inch in the vector file.
A PDF page of 1200*800 points converted to image using a 300 dpi will generate an image of 5000*3334 pixels (5000 = 1200 * 300/72).

The resolution is also used when drawing an image on a PDF page. The image size is given in pixels but the area it occupies on the PDF page is given in points. The resolution of the drawn image is computed as size of image in pixels divided by 72 and multiplied by size of image area on the page in points.
For example an image of 144*144 pixels drawn in a rectangle of 72*72 points will have a resolution of 144dpi, but if the same image is drawn on the same page in a rectangle of 144*144 points it will have a resolution of 72dpi. The dpi is tied to the drawn instance of the image, not to the actual image.

So if you want to have a PDF page of 1200*800 points and you want to draw the image on the page at 300dpi, then the size of the image must be 5000*3334 pixels.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM