BNHtmlPdfKit icon indicating copy to clipboard operation
BNHtmlPdfKit copied to clipboard

saveHtmlAsPdf handles Images

Open Sun3 opened this issue 10 years ago • 6 comments

I have html code which also includes an images, would the saveHtmlAsPdf handle the image and is there anything special that I would need to do to pass the image info?

Thanks for this lib.

Sun3 avatar Mar 30 '14 05:03 Sun3

I'm trying to do this as well. Did you ever figure it out?

cliftonlabrum avatar Jun 24 '14 05:06 cliftonlabrum

I need to do this also. Any update?

jarrodglasgow avatar Aug 21 '14 03:08 jarrodglasgow

I haven't heard anything on this, sorry.

In my case, I needed some icons in my PDF, so I ended up rendering them with SVG instead of using an image. Seems to work well.

cliftonlabrum avatar Aug 21 '14 16:08 cliftonlabrum

I found a nice solution. I temporarily stash the UIImage in the app's Documents folder and store the path. Then I just add an tag with that path.

Works like a champ.

jarrodglasgow avatar Aug 21 '14 17:08 jarrodglasgow

I also have the issue that I need to provide an image into the PDF (f.e. icon.png) but I don' t know how to reference it in the html tag. Could someone provide an example how to best do that ?

arnold-maderthaner avatar Sep 18 '15 11:09 arnold-maderthaner

I fixed the issue by setting the baseURL correctly to the documents folder like this:

NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSURL *baseURL = [NSURL fileURLWithPath:path]; self.htmlPdfKit.baseUrl = baseURL;

now I can reference with in my html and it will pick it up from the Documents/images/icon.png file.

arnold-maderthaner avatar Sep 18 '15 17:09 arnold-maderthaner