[PDF Generator Plugin] html to pdf from uri included image in app internal storage not working on iPhone

Forge Component
(7)
Published on 29 May by Experts
7 votes
Published on 29 May by Experts

Hi there,

I am generating my own HTML because page2html and then html2pdf is not giving the results i want. In the html i include uri's to images saved to the internal file storage off the app and then create the pdf's.

Works great on Android, not on iPhone.

Android:

<td style="width: 50%;"><img src=file:///data/user/0/com.outsystemscloud.acsioncurabvdev.BIL/files/BIL/20/0.jpeg alt=" width="300" height="100" />

works fine.

iPhone:

<td style="width: 50%;"><img src=file:///var/mobile/Containers/Data/Application/37958ADB-8114-42B1-AFD1-EFBED3884271/Library/NoCloud/BIL/1/0.jpeg alt=" width="300" height="100" />

doesn't show an image in the pdf.

What would be recommended on how to include images on iPhone from auto-generated html? If i check the jpeg file in the in-app file browser, the pic opens fine.

Thanks ahead,

Wilko

Hi, 

i am not ios expert. Somehow i found this discussion.

I have noticed below line in that discussion.

"iOS web view can load the assets only from the whitelisted directory, when you pass HTML string it's impossible to know from which directories it's going to load the assets."

dlcole, somehow fix the issue , try to apply it. it may help u.

Hope this is relatable with your issue.


Cheers.

Rahul hi,

Thanks for your reply. What dlcole seems to be doing (if i am correct) is write the images to a temp folder, save the html as a file in the same folder, and not include any path to the images. When processing the html, it picks the images from the same path as the html and problem solved.

I am not sure if i can do the same, my code looks like this:

first i create a temp folder, save the logo in the temp, include the URI from the logo in the html, do the same for a list of items with pictures, include the URI from the items in table html etc, and create the pdf from the html:

any pointers on how to implement what dlcole is suggesting in this approach?

Thanks,

Wilko

after talking to Rahul, i tried inserting the images as base64 in the html:

Advantages:

works on Android and iPhone

all in memory

no need for temp storage of images, and is faster than before.

PDF looks good on iOS!

Thanks Rahul

wilko odijk wrote:

after talking to Rahul, i tried inserting the images as base64 in the html:

Advantages:

works on Android and iPhone

all in memory

no need for temp storage of images, and is faster than before.

PDF looks good on iOS!

Thanks Rahul

yes , we can add base64 in html , it is good solution that you have  found .  

you got an advantage escaped from storing image in app folder.


Cheers.