0
Я использую этот код для печати PDF-файл:Печать Pdf файл с какао, приложение аварии
- (void)printPDF:(NSURL *)fileURL {
// Create the print settings.
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
[printInfo setTopMargin:0.0];
[printInfo setBottomMargin:0.0];
[printInfo setLeftMargin:0.0];
[printInfo setRightMargin:0.0];
[printInfo setHorizontalPagination:NSFitPagination];
[printInfo setVerticalPagination:NSFitPagination];
// Create the document reference.
PDFDocument *pdfDocument = [[PDFDocument alloc] initWithURL:fileURL];
// Invoke private method.
// NOTE: Use NSInvocation because one argument is a BOOL type. Alternately, you could declare the method in a category and just call it.
BOOL autoRotate = YES;
NSMethodSignature *signature = [PDFDocument instanceMethodSignatureForSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)];
[invocation setArgument:&printInfo atIndex:2];
[invocation setArgument:&autoRotate atIndex:3];
[invocation invokeWithTarget:pdfDocument];
// Grab the returned print operation.
NSPrintOperation *op = nil;
[invocation getReturnValue:&op];
// Run the print operation without showing any dialogs.
[op setShowsPrintPanel:NO];
[op setShowsProgressPanel:NO];
[op runOperation];
}
У меня также есть это в моем коде:
- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate;
{
return nil;
}
он печатает Pdf файл, но приложение всегда падает ... Я предполагаю, что есть что-то не хватает в
(NSPrintOperation *) getPrintOperationForPrintInfo
любая помощь будет оценена
Какая ошибка возникает при сбое приложения? – ElmerCat
Тема 1: EXC_BAD_ACCESS (код = 1, адрес = 0x20) – Blue