Hi,
I have some problems with rendering pdf pages in iOS 15.0. On iOS 14 and before iOS versions it’s working perfectly. But in iOS 15 and after releasing new versions I have faced the same issue. I have a PKCanvas View. Actually what I have to achieve is to convert that PKCanvas view into PDF. First I have written some words in the PKCanvas view using PencilKit and converted that PKCanvas view into an image and then I have converted that image into PDF. After that, I have loaded that PDF in WKWebview. There is no problem yet. But when I try to convert that WKWebview to again convert into PDF Using the rendering option there are mirror words are automatically occurring which error I have faced while creating the PDF from WKWebview by rendering option.
let render = UIPrintPageRenderer()
render.addPrintFormatter(self.previewWebView.viewPrintFormatter(), startingAtPageAt: 0)
// 3. Assign paperRect and printableRect
let page = CGRect(x: 0, y: 0, width: 595.2, height: 841.8) // A4, 72 dpilet printable:CGRect = CGRect(x: 0, y: 0, width: 595.2, height: 841.8) render.setValue(NSValue(cgRect: page), forKey: “paperRect”)
render.setValue(NSValue(cgRect: printable), forKey: “printableRect”)
// 4. Create PDF context and draw
let pdfData = NSMutableData()
UIGraphicsBeginPDFContextToData(pdfData, CGRect(x:0,y:0,width: 595.2,height:841), nil) for i in 1...render.numberOfPages {
UIGraphicsBeginPDFPage();
let bounds = UIGraphicsGetPDFContextBounds()
render.drawPage(at: i-1, in: bounds)
}
UIGraphicsEndPDFContext();
How to resolve this issue? Please help us ASAP. Thanks in advance. For your reference, I have attached the PDF Page screenshot!