それぞれのページを 1 つの PDF に追加して、複数の PDF を 1 つに結合したいと考えています。このサイトの同じ質問に対する回答は、次のコードを提供しました (inputDocuments が PDFDocuments の配列であると仮定します:
PDFDocument *outputDocument = [[PDFDocument alloc] init];
NSUInteger pageIndex = 0;
for (PDFDocument *inputDocument in inputDocuments) {
for (PDFPage *page in inputDocument) {
[outputDocument insertPage:page atIndex:pageIndex++];
}
}
PDFDocument クラスがもともと高速列挙をサポートしていたかどうかはわかりませんが、現在はサポートされていないようです。次のように、単一ページの PDFDocuments の配列を使用して一連の for ループを使用して、同じことを試みました。
PDFDocument *outputDocument = [[PDFDocument alloc] init];
NSUInteger aPageCount=0;
for (PDFConverter* aConverter in [self finishedPDFConverters])
{
[outputDocument insertPage:[[aConverter theDoc] pageAtIndex:0] atIndex:aPageCount];
aPageCount++;
}
ただし、エラーが発生します
"2011-07-19 23:56:58.719 URLDownloader[37165:903] *** WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: <NSRangeException> *** -[NSCFArray insertObject:atIndex:]: index (1) beyond bounds (1)"
最初のドキュメントが追加された後、1 ページしかない PDF になります。どうすればこれを修正できますか?