5/4/2023 0 Comments Apple pdfkitFinally, the PDFView’s document is set, which in turn is added to the existing view for display on the screen. In the code example, we are creating the PDFView at a specific size, then setting up a PDFDocument with a PDF from the main bundle. PDFDocument manages the details of the document itself, as well as handling searching, writing, and selecting data within the PDF file. The PDFView object is the primary one you’ll be working with and controls the display area, nagivation, which PDF is loaded, and which page of the PDF is shown. Here’s a quick explanation of the code above: NSString *pathToPDF = *pdfDoc = initWithURL:] īe sure to read the official PDFKit documentation to better understand how all of these objects work. Then add this code to viewDidLoad or whatever other function you want to do this work: PDFView *pdfView = initWithFrame: Import PDFKit into your project at the top of your file: #import The PDF output from this example (with a few additions) shows the power of PDFKit producing complex documents with a very small amount of code. It displays a PDF file in the default vertical scroll view at the size of the current view. To start, here is the simplest implementation you can get, with no customization or options. Along with that, I’ll be including all of my code in a GitHub repository for reference and testing. With that in mind, I’m planning a series of blog posts to cover the use of PDFKit, to help other developers who are implementing it using Objective-C. In fact, even some of Apple’s documentation only includes Swift examples. While working with PDFKit on a project this year, I found the general online support to be somewhat lacking, especially for Objective-C.
0 Comments
Leave a Reply. |