ios-pdfkit

iOS PDFkit cannot add custom attribute to pdf document

寵の児 提交于 2021-02-07 20:25:34
问题 I am trying to add custom attribute to a pdf document metadata, but after savedocument(document) the custom attribute is not added to the document. @IBOutlet weak var pdfContainerView: PDFView! private func setDocumentAttributes(){ if let document = pdfContainerView.document{ var attributes = document.documentAttributes attributes!["NewAttribute"] = "Test" document.documentAttributes = attributes savedocument(document) } } 来源: https://stackoverflow.com/questions/54986089/ios-pdfkit-cannot-add

How to override draw method on PDFAnnotation IOS-PDFKIT

对着背影说爱祢 提交于 2020-08-26 10:18:48
问题 I followed another StackOverflow post that explains how i could override the draw method of a PDFAnnotation so i could draw a picture instead of a traditional PDFAnnotation. But sadly i was not able to achieve that and the annotation that is drawn on top of my pdf is still a regular one. This is the code that i used : @implementation PDFImageAnnotation { UIImage * _picture; CGRect _bounds;}; -(instancetype)initWithPicture:(nonnull UIImage *)picture bounds:(CGRect) bounds{ self = [super

open PDF with PDFKit.PDFView on iOS

一个人想着一个人 提交于 2020-05-17 05:58:08
问题 I have an application with PDF viewer, and I try to use PDFKit.PDFView which need to PDFKit.PDFDocument object. My code is: var pdfview = new PdfKit.PdfView(); var path = NSBundle.MainBundle.PathForResource("Harvard", "pdf"); var urll = new NSUrl(path); var pdfdoc = new PdfDocument(urll); pdfview.Document = pdfdoc; I get an exception at line 4, which says : Could not initialize an instance of the type 'PdfKit.PdfDocument': the native 'initWithURL:' method returned nil My pdf file, Harvard.pdf

Saved PDFView with PDFKit IOS not showed properly in Adobe reader

偶尔善良 提交于 2020-02-25 04:33:11
问题 I am creating an app where I open a PDF with form elements, add some data and export it again to a new PDF file. The code to export this file looks like this: @IBAction func exportPDF(_ sender: Any) { guard let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first, let data = pdfView.document?.dataRepresentation() else {return} let fileURL = url.appendingPathComponent("test.pdf") do { try data.write(to: fileURL, options: .atomicWrite) print(fileURL) } catch {

Saved PDFView with PDFKit IOS not showed properly in Adobe reader

纵饮孤独 提交于 2020-02-25 04:32:49
问题 I am creating an app where I open a PDF with form elements, add some data and export it again to a new PDF file. The code to export this file looks like this: @IBAction func exportPDF(_ sender: Any) { guard let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first, let data = pdfView.document?.dataRepresentation() else {return} let fileURL = url.appendingPathComponent("test.pdf") do { try data.write(to: fileURL, options: .atomicWrite) print(fileURL) } catch {

Rotate PDF page with usePageViewController

老子叫甜甜 提交于 2019-12-24 07:28:20
问题 I am working on PDFKit and try to rotate the page. It is rotating good but without using usePageViewController. With usePageViewController it won't update the frame of the page. // At defining PDFVIEW object pdfView.displayMode = .singlePageContinuous pdfView.usePageViewController(true, withViewOptions: nil) // For rotating screen pdfView.currentPage?.rotation += 90 without usePageViewController pagination is not working. How to achieve both at same place. https://i.stack.imgur.com/xifjV.jpg

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'

我们两清 提交于 2019-12-11 14:54:50
问题 The problem started with the XCode 10.2.x as I guess While it was working fine with the XCode 10.1 The crash point is " pdfView.frame = self.view.frame " from below code: import UIKit import PDFKit class ViewController: UIViewController { var pdfView = PDFView() override func viewDidLoad() { super.viewDidLoad() // Prepare document to show let url = Bundle.main.url(forResource: "sample", withExtension: "pdf") let pdfDocument = PDFDocument(url: url!) // PDFView pdfView = PDFView() pdfView.frame