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.