Pregunta

I want to create an application where in I can display "print preview" on a PDF file. For example, if I set the N-up option to 4, 4 pages of the pdf will be displayed in page 1, etc.

I wanted to create something similar with the print preview of PrinterShare app.

An idea that I have in mind:
1) Read pdf (like an image), then draw the changes manually, e.g. if N-up, draw the image 4 times in a page while considering the new height/width (in this case, height and width will be set to 1/4 of original).

Do you have other ideas?
Or do you know of any libraries for "print previews"?

Any help will be greatly appreciated!

¿Fue útil?

Solución

Your idea seems possible. For each option you want to consider, you can translate it to PDF drawing code.

For example, N-up can be done by scaling the previous PDF, and then redrawing it N times on the same page.
Margin can be done by changing your starting positions when drawing the PDF.

You can follow this guide for drawing to a PDF: https://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/GeneratingPDF/GeneratingPDF.html

You can also refer to the following stackoverflow question: Convert a PDF to one page PDF reason for this is PDF pages doesnot have same page height
It has sample codes for drawing PDF.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top