Questions tagged [apple-pdfkit]

Questions related to the Apple PDFKit framework.

Questions related to the Apple PDFKit framework (https://developer.apple.com/documentation/pdfkit).

57 questions
2
votes
0 answers

PDFDocument.write in Swift causes content corruption

I'm trying to save and load a PDF document using Swift's PDFDocument.write method, but encountered an issue where the textual content of the saved document was consistently corrupted compared to the original. For instance, "*" gets changed to "ú"…
Nguyễn Khắc Hào
  • 1,980
  • 2
  • 15
  • 25
2
votes
1 answer

Generating PDF from array of SwiftUI views

I'm building an identity app which is stored all locally within the app on device. Part of the app is the creation of IdentityCard for each user - with the standard things, name, image, position. The size of the card is a standard credit card size:…
markb
  • 1,100
  • 1
  • 15
  • 40
2
votes
3 answers

PDFKit's scaleFactorForSizeToFit isn't working to set zoom in SwiftUI (UIViewRepresentable)

I'm working on an app that displays a PDF using PDFKit, and I need to be able to set the minimum zoom level - otherwise the user can just zoom out forever. I've tried to set minScaleFactor and maxScaleFactor, and because these turn off autoScales, I…
user18457910
2
votes
0 answers

How to rotate PDFAnnotation using PDFKit (Swift)?

I am working on PDF Kit using swift. I want to rotate PDFAnnotation. Is there any way to rotate PDFAnnotation? I am trying with the below code but I am not successful to get the desired result. annotation.bounds.origin =…
Sac Allen
  • 61
  • 3
2
votes
0 answers

Inserting Blank page after adding image on previous page in pdf using PDFKit Swift

I am facing the problem while inserting a blank page in pdf using PDFKit. when there are images on pdf importing from gallery or capturing from the camera. and then we add a blank page on that pdf at that time the page is very small. it's not in A4…
2
votes
1 answer

How do you move a PDFAnnotation on a PDFPage within a PDFView?

I'm working with PDFKit and similar to the Apple Preview App, when adding PDF annotations, I'd like the user to be able to move them around on the page. I've created an example project on Github. I've tried subclassing PDFView and overriding func…
Tom J
  • 106
  • 2
  • 14
2
votes
0 answers

PDF size inflation using Swift PDFKit

I wrote a small PDF merging application in Swift for MacOS, using Apple's basic PDF framework. The basic strategy is to take a list of PDF files, and then iterate over the pages of the 2nd to nth file, appending each of them to the end of the first…
Paul Gowder
  • 2,409
  • 1
  • 21
  • 36
2
votes
0 answers

PDFPage setBounds is blurry and deform

The page I get from page.setBounds is blurry and deform. but the actual page (even after zooming) is very clear.I want to maintain pdf quality after setBounds. myPage.setBounds(box.bounds, for: .cropBox)
Spanix Dev
  • 101
  • 6
2
votes
0 answers

Not getting selection from PDFView

I see somewhere this code for highlight selected text in pdf document: let select = pdfView.currentSelection?.selectionsByLine() //assuming for single-page pdf. guard let page = select?.first?.pages.first else { return } …
Spanix Dev
  • 101
  • 6
2
votes
0 answers

Adding Button/Label on Pdf Page using PDFKIT

I am trying to add some interactive buttons on pdf pages. I am showing Pdf file using Apple PDFKit and I have implemented UITapGesture, so when user tap on screen I show a annotation on it, issue is I want to mark this annotation as number like…
Najam
  • 1,129
  • 11
  • 32
2
votes
1 answer

Apple PDFKit Notifications not working properly

I try to get notifications as soon as the currently visible pages in my pdfView change. Actually this should work according to the documentation via .PDFViewVisiblePagesChanged. However, I only get a notification the very first time when the pdfView…
Phil
  • 107
  • 1
  • 7
1
vote
0 answers

PDFView context menu event handler -- changing highlight color

I have a PDFView in an app. It allows you to highlight certain text. When you click on a highlight, the built in menu appears: In the Preview.app, when you click one of those colors (or the remove highlight) menu item, it does what you expect…
Tom J
  • 106
  • 2
  • 14
1
vote
1 answer

Swift PDFKit draw multiple images in a single PDFPage

I'm trying to draw multiple images into a single PDFPage. Looking at the docs and over StackOverflow seems like the best I got is to use PDFPage with an UIImage initializer like so: let pdfPage = PDFPage(image: image) But it just creates a page…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
1
vote
2 answers

Make a pdf document by Image using PDFKit in iOS 16

while we make a pdf using an image file at that we add an image into PDFPage. at that time PDFDocument did not show the original image content in PDFView in iOS 16. I checked the same code which worked properly in iOS 15. For both test cases, I used…
1
vote
1 answer

Cannot add image and save to pdf file using PDFKit

I have a class to edit pdf by inserting an image into the pdf and save a new pdf with the inserted image. Below code is the way I use to achieve the scenario, by creating a custom PDFAnnotation. I specify type as .widget instead of .stamp to avoid…
SaintTail
  • 6,160
  • 4
  • 31
  • 51