0

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!

MiuMiu
  • 1,905
  • 2
  • 19
  • 28
  • You mean having a Print Preview before Air Print ? – Raptor Sep 05 '13 at 08:24
  • Not necessarily AirPrint since we are also considering other methods/protocols in printing. – MiuMiu Sep 05 '13 at 08:27
  • Can you show us your existing codes ? – Raptor Sep 05 '13 at 08:27
  • I do not have existing codes yet. I am still gathering ideas on how to proceed with this. – MiuMiu Sep 05 '13 at 08:35
  • Stack Overflow is for solid programming questions. Please search & try to implement some codes & get back here. – Raptor Sep 05 '13 at 08:40
  • Hmm, I can't think of any benefit in implementing some codes for my question. But, first of all, what part of the code do you want to see? I may be able to come up with something depending on your answer. – MiuMiu Sep 05 '13 at 09:02
  • the code of rendering PDF on screen. – Raptor Sep 05 '13 at 09:03
  • Rendering PDF on screen, without considering printing options? – MiuMiu Sep 05 '13 at 09:05
  • 1
    I think the reason for marking this question as off-topic is wrong. Firstly, this is not a question about code I've written, since I have not written any code yet. This question is about the possible approaches to a problem (in this case, the "print preview" problem). Maybe it can be considered as a "software algorithm" question? (http://stackoverflow.com/help/on-topic) If you have an idea on how to edit this question, feel free to edit or post a comment. – MiuMiu Sep 06 '13 at 03:30

1 Answers1

1

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.

Community
  • 1
  • 1
Dj S
  • 10,232
  • 1
  • 21
  • 24