I am uploading pdf document through document picker from One drive. When I am uploading pdf document from OneDrive personal account it is working fine but when I am uploading from OneDrive business account it is getting failed.
PDFKit
RSS for tagDisplay and manipulate PDF documents in your applications using PDFKit.
Posts under PDFKit tag
52 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
if I get the string contents of a PDF and print to the console in Xcode .
when run on simulator it’s fine but on device some words are missing.
same PDF, same code. only difference is simulator and physical device.
its only a word or two missing from the page.
anyone have any experience or suggestions with PDFKit to explain why a string would be missing the odd word ?
Im trying to duplicate the display of the built in Files app for documents in my app.
How do I convert a page in a PDFDocument to an Image to display as an icon like seen here (from Files App) with SwiftUI.
SOLVED:
Image(uiImage: (document.page(at: 0)?.thumbnail(of: CGSize(width: 100, height: 100), for: .cropBox))!)
Is it possible to generate pdf data from a html content, including the background graphics (background color, box shadow, etc..) ? Right now, I can only make a pdf view from the apple website like this:
It can be seen that the background images and colors are missing.
Hi, I am trying to make a simple note taking app that users can draw something on pdfview with apple pencil.
(I used PDFKit, PencilKit for the code.)
I followed the instruction code of WWDC22's "What's new in PDFKit." - "overlayProvider"
(so you can see the code at the video.) I was able to draw something each view of pdf page.
But the issue was, the resolution of overlayview or subview of pdfview is low.
As far as I know, the pkcanvasview draws vertor-based drawings. So I never thought the image or the lines I draw will be that blurry.
Is this buggy or is this the normal thing? (+ I added a uibutton as subview of pdfview and the button also looks blurry.)
I even tried to scale up the all the subviews when the subviews' layout is done, using contentScaleFactor.
PKCanvasView inherits UIScrollView, so I enlarged the frame of pkcanvas view and fixed the scale to below 1.0. If the pkcanvasview looks blurry and that is because somewhat zoomed in wrong way, zooming out should be the solution. But, didn't work. Still blurry.
and any other stuff like changing frame or size.
So, anyone having same problem with me, or anyone can give me any solution.
Please help me. I wish this is bug thing that can be fixed in any moment.
-> This image is little bit zoomed in. but the drawing is blurry.
and this is the normal pkcanvasview drawing, just subview of view(of VC).
Hi everyone,
We have been noticing since release iOS 17, that our code which renders PDFPage objects to images was randomly failing (while no error is logged) and produced full black images.
This problem seems to mainly occurs on old devices (iPad Pro 2017 and 2018).
I mention that this portion code has been running for several years in our app without any issue from iOS10 to iOS16.
let renderFormat = UIGraphicsImageRendererFormat.default()
renderFormat.opaque = true
renderFormat.scale = CGFloat(scale)
let renderer = UIGraphicsImageRenderer(size: pageRect.size, format: renderFormat)
mainImage = renderer.image { context in
// Setup drawing context
context.cgContext.setShouldAntialias(false)
context.cgContext.setShouldSmoothFonts(false)
context.cgContext.setAllowsFontSmoothing(false)
context.cgContext.setShouldSubpixelPositionFonts(true)
context.cgContext.setShouldSubpixelQuantizeFonts(true)
// Draw pdf page
context.saveGState()
UIColor.white.setFill()
context.clip(to: rect)
context.fill(rect)
page.draw(with: .cropBox, to: context)
context.restoreGState()
}
Did anyone encountered a similar issue?
Is there any mean to get an error at least in such cases ?
Thanks for any help or advice on this issue.
Problem:
Hello! I have some problems with UIEditMenuInteraction in WKWebView which show PDF using PDFKit (as far as I know) - when text is selected, there is no copy/paste buttons on iOS 16.4 or higher. Also I've noticed that selection blue view take less space than actual text is on iOS 17. The problem both cyrillic and latin characters.
How I can fix this?
p.s. I found on stackoverflow that PDFKit can treat PDF files like images, but on view hierarchy there is no differences between 16 and 17 iOS
How it looks:
The problem file:
https://drive.google.com/file/d/1Tu8RCrlwOI_H3TcwOGFbDR0G9h1OP7MU/view?usp=sharing
I'm developing a PDF application that display vertical pages horizontally. Some of users might use mouses with scroll wheels. I want to provide a option enabling them to browse pages with scroll wheels. How can I achieve that with PDFKit?
Hello together,
does anyone know how I can scale a view to a given document size (e.g. A4: 210/297 mm) without scaling the view itself?
With enclosed code I can create the pdf-document, but the paperize is not the intended size. It is too big.
Variation this line of code
var mediaBox = CGRect(origin: .zero, size: CGSize(width: size.width, height: size.height))
into
var mediaBox = CGRect(origin: .zero, size: CGSize(width: 595, height: 842)
does not scale the view (it just shows a part of it at the correct papersize).
So what do I have to do to scale the rendered view to the proper size?
Enclosed a very simple code snipped to see th strange behavior.
Thx, best regards
Peter
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
Rectangle()
.frame(width: 2100, height: 2910)
.foregroundColor(.red)
Rectangle()
.frame(width: 2100/2, height: 2910/3)
.foregroundColor(.blue)
Text("Hello, world!")
}
.padding()
.onAppear(perform: {
generatePDF()
})
}
// generate pdf from given view
@MainActor func generatePDF() -> URL {
// Select UI View to render as pdf
let image = ImageRenderer(content: ContentView())
let url = URL.documentsDirectory.appending(path: "generatedPDF.pdf")
image.render{ size, context in
var mediaBox = CGRect(origin: .zero, size: CGSize(width: size.width, height: size.height))
guard let consumer = CGDataConsumer(url: url as CFURL),
let pdfContext = CGContext(consumer: consumer, mediaBox: &mediaBox, nil)
else {
return
}
pdfContext.beginPDFPage(nil)
pdfContext.translateBy(x: mediaBox.size.width / 2 - size.width / 2,
y: mediaBox.size.height / 2 - size.height / 2)
context(pdfContext)
pdfContext.endPDFPage()
pdfContext.closePDF()
}
print("Saving PDF to \(url.path())")
return url
}
}
#Preview {
ContentView()
}
.jpg;width=2652;height=2526")
.jpg;width=2132;height=1510")
Dear Developer Community,
My app is saving handwritten notes, forms and images as annotations in PDF documents by using PDFKit.
Since iPadOS 17.2, the content of the annotations within the annotation boundaries is scaled down when saving the annotated PDF file. I.e. the annotation boundaries remain unchanged, but the displayed annotation content shrinks and no longer fills the boundaries. This gets worse with every save operation and applies both to newly created annotations and to elements that were saved before iPadOS 17.2.
This issue only occurred after updating to iPadOS 17.2. The same code on my test device with iPadOS 17.1 works perfectly.
Does anybody have a similar issue and/or found a workaround to solve this problem?
Thanks for any idea!
Hello y'all,
I would like to discuss here if anyone else is noticing that some PDF files are not rendered as expected in iOS/iPadOS 17, it seems that some text with background (screenshot attached) are not rendered and you can only see the back color.
The issue is reproducible on Preview, Safari, where I guess Apple is using PDFKit framework too.
We submitted different issues with Feedback Assistant, however I've not hear back from Apple yet.
Is anyone else able to reproduce the issue?
Thanks,
PDFKit’s characterIndex(at:) method consistently returns the incorrect character index on iOS 17. It seems to get worse the further down the page you get. This breaks critical functionality that my app relies on. Prior to iOS 17, it would be wrong sometimes but not as consistently.
This is the method in question:
https://developer.apple.com/documentation/pdfkit/pdfpage/1503775-characterindex
I've filed feedback FB12951475 with a sample project attached.