You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to convert multiple html file to multiple pdf file using a for loop, however, the app crashes with Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
Why?
Here's the code I'm using:
for (int i=0; i<= 47; i++) {
NSString *inputHTMLfileName = [NSString stringWithFormat:@"wkhtml_tempfile_%d",j];
NSString *outputPDFfileName = [NSString stringWithFormat:@"~/Documents/%d_delegateDemo%d.pdf",loop,j];
NSURL *htmlFileUrl = [[NSBundle mainBundle]
URLForResource:inputHTMLfileName withExtension:@"html"];
// Check for existing pdf file and remove it
NSError *pdfDeleteError;
if ([[NSFileManager defaultManager] fileExistsAtPath:outputPDFfileName]){
//removing file
if (![[NSFileManager defaultManager] removeItemAtPath:outputPDFfileName error:&pdfDeleteError]){
NSString * errorMessage = [NSString stringWithFormat:@"wk %d Could not remove old pdf files. Error:%@",j, pdfDeleteError];
NSLog(@"%@",errorMessage);
}
}
self.PDFCreator = [NDHTMLtoPDF createPDFWithURL:htmlFileUrl pathForPDF:[outputPDFfileName stringByExpandingTildeInPath] pageSize:kPaperSizeA4 margins:UIEdgeInsetsMake(10, 5, 10, 5) successBlock:^(NDHTMLtoPDF *htmlToPDF) {
NSString *result = [NSString stringWithFormat:@"HTMLtoPDF did succeed (%@ / %@)", htmlToPDF, htmlToPDF.PDFpath];
NSLog(@"%@",result);
self.resultLabel.text = result;
} errorBlock:^(NDHTMLtoPDF *htmlToPDF) {
NSString *result = [NSString stringWithFormat:@"HTMLtoPDF did fail (%@)", htmlToPDF];
NSLog(@"%@",result);
self.resultLabel.text = result;
}];
}
The text was updated successfully, but these errors were encountered:
Hi, I'm trying to convert multiple html file to multiple pdf file using a for loop, however, the app crashes with Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
Why?
Here's the code I'm using:
The text was updated successfully, but these errors were encountered: