Post

Replies

Boosts

Views

Activity

Black image when rendering PDF to image with UIGraphicsImageRendererFormat
Hi everyone, We have been noticing since release iOS 17, that our code which renders PDFPage objects to images was randomly failing (while no error is logged) and produced full black images. This problem seems to mainly occurs on old devices (iPad Pro 2017 and 2018). I mention that this portion code has been running for several years in our app without any issue from iOS10 to iOS16. let renderFormat = UIGraphicsImageRendererFormat.default() renderFormat.opaque = true renderFormat.scale = CGFloat(scale) let renderer = UIGraphicsImageRenderer(size: pageRect.size, format: renderFormat) mainImage = renderer.image { context in // Setup drawing context context.cgContext.setShouldAntialias(false) context.cgContext.setShouldSmoothFonts(false) context.cgContext.setAllowsFontSmoothing(false) context.cgContext.setShouldSubpixelPositionFonts(true) context.cgContext.setShouldSubpixelQuantizeFonts(true) // Draw pdf page context.saveGState() UIColor.white.setFill() context.clip(to: rect) context.fill(rect) page.draw(with: .cropBox, to: context) context.restoreGState() } Did anyone encountered a similar issue? Is there any mean to get an error at least in such cases ? Thanks for any help or advice on this issue.
1
0
482
Mar ’24