This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
enum OSDocumentError: Error { | |
case unknownFileFormat | |
} | |
#if canImport(UIKit) | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func drawOnPDF(path: String) { | |
// Get existing Pdf reference | |
let pdf = CGPDFDocumentCreateWithURL(NSURL(fileURLWithPath: path)) | |
// Get page count of pdf, so we can loop through pages and draw them accordingly | |
let pageCount = CGPDFDocumentGetNumberOfPages(pdf); | |
// Write to file | |
UIGraphicsBeginPDFContextToFile(path, CGRectZero, nil) |