brentnycum / BNHtmlPdfKit

Easily turn HTML data from an HTML string or URL into a PDF file on iOS
MIT License
270 stars 62 forks source link

saveHtmlAsPdf handles Images #4

Open Sun3 opened 10 years ago

Sun3 commented 10 years ago

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.

cliftonlabrum commented 10 years ago

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

jarrodglasgow commented 10 years ago

I need to do this also. Any update?

cliftonlabrum commented 10 years ago

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.

jarrodglasgow commented 10 years ago

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.

arnold-maderthaner commented 9 years ago

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 commented 9 years ago

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.