Comment merge plusieurs files PDF en un seul PDF

J'ai un gros problème. Je voudrais merge plusieurs files PDF en Tro Un pdf à partir d'applications iPhone. Mais je ne peux pas. Pouvez-vous m'aider ? Merci beaucoup

Si je comprends bien la question, vous essayez d'append un tas de files PDF indépendants dans un seul file PDF.

J'ai utilisé le code ci-dessous pour append 1 file pdf à la fin d'un autre pour créer un file pdf.

 //NSSsortingng *documentsDirectory = [paths objectAtIndex:0]; NSSsortingng *cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; // File paths NSSsortingng *pdfPath1 = [[NSBundle mainBundle] pathForResource:@"pdf1" ofType:@"pdf"]; NSSsortingng *pdfPath2 = [cacheDir ssortingngByAppendingPathComponent:@"temp.pdf"]; NSSsortingng *pdfPathOutput = [cacheDir ssortingngByAppendingPathComponent:@"out.pdf"]; // File URLs - bridge casting for ARC CFURLRef pdfURL1 = (__bridge_retained CFURLRef)[[NSURL alloc] initFileURLWithPath:(NSSsortingng *)pdfPath1];//(CFURLRef) NSURL CFURLRef pdfURL2 = (__bridge_retained CFURLRef)[[NSURL alloc] initFileURLWithPath:(NSSsortingng *)pdfPath2];//(CFURLRef) CFURLRef pdfURLOutput =(__bridge_retained CFURLRef) [[NSURL alloc] initFileURLWithPath:(NSSsortingng *)pdfPathOutput];//(CFURLRef) // File references CGPDFDocumentRef pdfRef1 = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL1); CGPDFDocumentRef pdfRef2 = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL2); // Number of pages NSInteger numberOfPages1 = CGPDFDocumentGetNumberOfPages(pdfRef1); NSInteger numberOfPages2 = CGPDFDocumentGetNumberOfPages(pdfRef2); // Create the output context CGContextRef writeContext = CGPDFContextCreateWithURL(pdfURLOutput, NULL, NULL); // Loop variables CGPDFPageRef page; CGRect mediaBox; // Read the first PDF and generate the output pages NSLog(@"GENERATING PAGES FROM PDF 1 (%i)...", numberOfPages1); for (int i=1; i<=numberOfPages1; i++) { page = CGPDFDocumentGetPage(pdfRef1, i); mediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); CGContextBeginPage(writeContext, &mediaBox); CGContextDrawPDFPage(writeContext, page); CGContextEndPage(writeContext); } // Read the second PDF and generate the output pages NSLog(@"GENERATING PAGES FROM PDF 2 (%i)...", numberOfPages2); for (int i=1; i<=numberOfPages2; i++) { page = CGPDFDocumentGetPage(pdfRef2, i); mediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); CGContextBeginPage(writeContext, &mediaBox); CGContextDrawPDFPage(writeContext, page); CGContextEndPage(writeContext); } NSLog(@"DONE!"); // Finalize the output file CGPDFContextClose(writeContext); // Release from memory CFRelease(pdfURL1); CFRelease(pdfURL2); CFRelease(pdfURLOutput); CGPDFDocumentRelease(pdfRef1); CGPDFDocumentRelease(pdfRef2); CGContextRelease(writeContext); 
 $mergedPath = '/tmp/bulkinvoice_merge_'.$vendor_id.'_'.$randomno.'.pdf'; $filepath = 'http://xyz/'.$vendor_id.'/'.$shipmentId.'_invoice_shipment_label.pdf'; $current = file_get_contents($filepath); $tempPath = '/tmp/bulkinvoice_'.$vendor_id.'_'.$shipmentId.'.pdf'; chmod($tempPath, 777); file_put_contents($tempPath,$current); $pdf = Zend_Pdf::load($tempPath); foreach($pdf->pages as $page){ $pdfExtract = $ex->clonePage($page); $pdf2show->pages[] = $pdfExtract; } //$pdf2show->pages[] = $ex->clonePage($pdf->pages[0]); echo "\n [->]Added in merged PDF : ".$shipmentId; $pdf2show->save($mergedPath); unlink($tempPath);