Hi,
I did found a way to perform "select all" on the cropView, but it's working only with images from the library or ones that taken from the camera, but not from image that created from PDF for example.
This is my solution:
guard let frame = image?.size else { return }
cropView.setCorners(newCorners: [.zero,
CGPoint(x: frame.width, y: 0),
CGPoint(x: frame.width, y: frame.height),
CGPoint(x: 0, y: frame.height)])
From some reason, when I'm running this on an image that created from PDF file, it's returns a very small size, I could say it looks like the thumbnail that you can see in the UIDocumentPickerViewController, but when I'm setting the image as the image of the imageView I can see it all over the screen and very sharp, it doesn't looks like the imageView resized it or something.
So in the bottom line - I wanted to ask if there is some built-in way in the library to perform "select all" or if you have any better idea that will work also with PDF converted to image it will be great.
BTW, the code that I'm using to convert the PDF to UIImage is:
func drawPDFfrom(url: URL) -> UIImage? {
guard let document = CGPDFDocument(url as CFURL) else { return nil }
guard let page = document.page(at: 1) else { return nil }
let pageRect = page.getBoxRect(.mediaBox)
let renderer = UIGraphicsImageRenderer(size: pageRect.size)
let img = renderer.image { ctx in
UIColor.white.set()
ctx.fill(pageRect)
ctx.cgContext.translateBy(x: 0.0, y: pageRect.size.height)
ctx.cgContext.scaleBy(x: 1.0, y: -1.0)
ctx.cgContext.drawPDFPage(page)
}
return img
}
Thanks,
Ido.
Hi,
I did found a way to perform "select all" on the
cropView, but it's working only with images from the library or ones that taken from the camera, but not from image that created from PDF for example.This is my solution:
From some reason, when I'm running this on an image that created from PDF file, it's returns a very small size, I could say it looks like the thumbnail that you can see in the
UIDocumentPickerViewController, but when I'm setting the image as the image of theimageViewI can see it all over the screen and very sharp, it doesn't looks like theimageViewresized it or something.So in the bottom line - I wanted to ask if there is some built-in way in the library to perform "select all" or if you have any better idea that will work also with PDF converted to image it will be great.
BTW, the code that I'm using to convert the PDF to UIImage is:
Thanks,
Ido.