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

戏子无情 提交于 2019-12-02 11:54:36

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)
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!