使用 PDFKit 打印 PDF目标 C

问题描述

我正在开发一个需要预览和打印文档的应用程序。 我可以预览但无法打印。

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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...