As you pointed out, you need one PDFDocument
output object that will contain all pages of all PDF input files. To do this, you need to skip all the input files, create PDFDocument
objects for each of them, and PDFDocument
over all the pages to add them using insertPage
to the output PDFDocument
object.
Assuming inputDocuments
is an NSArray
one or more PDFDocument
objects, you can use this snippet:
PDFDocument *outputDocument = [[PDFDocument alloc] init]; NSUInteger pageIndex = 0; for (PDFDocument *inputDocument in inputDocuments) { for (NSUInteger j = 0; j < [inputDocument pageCount]; j++) { PDFPage *page = [inputDocument pageAtIndex:j]; [outputDocument insertPage:page atIndex:pageIndex++]; } }
source share