问题描述
我正在开发一个需要预览和打印文档的应用程序。 我可以预览但无法打印。
PS:我在网上搜了一下,发现有个方法printwithinfo, 但是当我尝试使用它时,它说“无法识别的方法”
这是我正在使用的代码。
PDFView *pdfView = [[PDFView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:pdfView];
pdfView.translatesAutoresizingMaskIntoConstraints = NO;
UILayoutGuide * guide = self.view.safeAreaLayoutGuide;
[pdfView.leadingAnchor constraintEqualToAnchor:guide.leadingAnchor].active = YES;
[pdfView.trailingAnchor constraintEqualToAnchor:guide.trailingAnchor].active = YES;
[pdfView.topAnchor constraintEqualToAnchor:guide.topAnchor].active = YES;
[pdfView.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor].active = YES;
pdfView.autoScales = YES;
pdfView.displayDirection = kPDFdisplayDirectionVertical;
pdfView.displaysRTL = YES;
pdfView.displayMode = kPDFdisplaySinglePageContinuous;
[pdfView setdisplaysPageBreaks:YES];
[pdfView setdisplayBox:kPDFdisplayBoxTrimBox];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"sample" withExtension:@"pdf"];
PDFDocument * document = [[PDFDocument alloc] initWithURL:url];
pdfView.document = document;
[pdfView.document allowsPrinting];
PDFThumbnailView *thumbnailView = [[PDFThumbnailView alloc]init];
thumbnailView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:thumbnailView];
[thumbnailView.leadingAnchor constraintEqualToAnchor:guide.leadingAnchor].active = YES;
[thumbnailView.trailingAnchor constraintEqualToAnchor:guide.trailingAnchor].active = YES;
[thumbnailView.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor constant:10].active = YES;
[thumbnailView.heightAnchor constraintEqualToConstant:120].active = YES;
thumbnailView.thumbnailSize = CGSizeMake(100,60);
thumbnailView.layoutMode = PDFThumbnailLayoutModeHorizontal;
thumbnailView.PDFView = pdfView;
pdfView.delegate = self;
pdfView.document.delegate = self;
pdfView.displaysAsBook = YES;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)