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 try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

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.