Product: PDFTron SDK
Product Version:
How to apply Convert.toPdf() on image selected from image gallery?
Hello
In my application I am trying to combine multiple images into single PDF. All the images were selected from device image gallery. Below are the things I have tried so far.
-
I used doc.pageCreate() and Image.create(doc.sdfDoc, bitmap) to create a new page for each image. But the issue here is the selected images can be of different resoulutions. I want to maintain same page size accorss all the pages and image should be adjusted based on its resoulution.
Issue: Here I couldn’t create propery page size and placement of image due to different image sizes -
Later I found using Convert.toPdf() we can combine multiple images into a pdf without having to worry about resoultions. But I couldn’t apply this function on to gallery image as the choosen path would start with content, ex: content://xxxxx/image:3993. In the examples always Assessts folder images were used.
When I tried this, I got below exception:
Convert.toPdf(doc, File(uri.path).absolutePath)
Saved tmp path null
Please let me know how can I achive this. My requirement is choosing multiple images from gallery and generate a pdf with good quality of images, good aspect ratio and minimal file size.