GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

PDFKit and SwiftData Questions

Forums > Swift

Hey All,

I'm wondering if anyone has used PDFKit with SwiftData? I have looked at the documentation but am trying to concieve the best way to move forward with this project.

I have a PDF Document that has multiple records that contain several values, all in a standardized format:

https://imgur.com/a/4UFBFR6

I'm trying to figure out if PDFKit would be the easiest way to parse this into all of the requisite records needed to create a SwiftData store. As I understand it, it looks like PDFKit will parse this all into a single string, but for perspective this document can be upwards of two-hundred pages in size, and I'm not quite sure how to parse all of the data into individual records when the string is that long.

Has anyone used PDFKit for this purpose before, or is there a package that might be more robust at handling my needs?

Thanks, Andy

   

I found the simplest way to generate a PDF is to use the ImageRenderer(content:) function call to turn a view into a PDF. That way I just need to create a great view, and the major work of PDF layout is done for me. You can still use PDKit after it's generated to manipulate further if you wish (I do this so I can add some PDF attributes).

As such; you'd just ingest the SwiftData into a SwiftUI view as you'd normally do; and the PDF will show the same content once built.

   

Hacking with Swift is sponsored by Alex.

SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!

Try for free!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.