In code:
/// Set image here override open func draw(with box: PDFDisplayBox, in context: CGContext) { // Get the CGImage of our image guard let cgImage = self.image.cgImage else { return } // Draw our CGImage in the context of our PDFAnnotation bounds context.draw(cgImage, in: self.bounds) }
When I using pdfDocument.dataRepresentation() to save the pdf document, the app crashed: --> self.image == nil, the work thread is not main thread, maybe this is the reason, but I should not put save work item in main thread, all right?
Can you help me to figure it out?