how to create a pdf from image which taken by camera with pdfkit

后端 未结 1 650
野性不改
野性不改 2021-01-26 17:26

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

相关标签:
1条回答
  • 2021-01-26 17:49

    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)
    }
    
    0 讨论(0)
提交回复
热议问题