sgr-ksmt / PDFGenerator

A simple generator of PDF written in Swift.
MIT License
755 stars 110 forks source link

Unable to show Symbol Image correctly (Bug) #131

Open HassanTaleb90 opened 12 months ago

HassanTaleb90 commented 12 months ago

If there is a Symbol image, the result is incorrect. The image will appear as a color covering its entire frame.

Example:

let imgA = UIImage(systemName: "swift")!

My solution is to transform it to a regular image using this code:

extension UIImage {
    /// Convert any image (e.g symbol image) to regular image
    var regularImage: UIImage {
        return UIGraphicsImageRenderer(size: size).image { _ in
            draw(in: CGRect(origin: .zero, size: size))
        }
    }
}

Usage:

let imgA = UIImage(systemName: "swift")!
let imgB = imgA.regularImage