Hi I am new to pdfkit
and iOS applications, I want to take a picture with device and then convert the image to pdf. taking pictures with camera and saving it on Cam
There's no need to instantiate a new image since the image is already stored in the pickedImage
variable. You just need to initialize the new PDFPage
object with pickedImage
. Use ImageKit
to edit the image before using it to initialize a new PDFPage
object.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
guard let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage else { return }
// Adds pickedImage to the user’s Camera Roll album.
UIImageWriteToSavedPhotosAlbum(pickedImage, nil, nil, nil)
// Creates a new PDFPage object and initializes it with pickedImage.
let newPage = PDFPage(image: pickedImage)
dismiss(animated: true, completion: nil)
}