Welcome Guest Search | Active Topics | Sign In | Register

HTML to PDF Options
Bill_M
Posted: Wednesday, July 15, 2015 2:40:32 PM
Rank: Newbie
Groups: Member

Joined: 7/13/2015
Posts: 3
I'm 100% new to this so I may not be saying this right. I have a HTML5 page that sends the contents of a major div as a JSON string via Ajax to a .net webservice that then takes that string and makes a PDF to send in an email. All of that works fine and I get a document, but I would like to include the style sheet so that the PDF looks like the original web page. Whats the best way to do this? Do I need to make an entire HTML document to send with the style included? Right now all I'm sending is the div. Thanks

eo_support
Posted: Wednesday, July 15, 2015 5:20:57 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

The basic rule is you can do it exactly the same way as you would do with a browser. For example, you can use inline <style> element, or use <link> element to link to an external CSS style, or even use JavaScript to load style resources dynamically.

Having that said, there maybe certain things you need to set properly depending on how your styles are loaded. For example, if you use HtmlToPdf.ConvertHtml and your styles use partial Url (for example, <link href="styles.css" />, note here "styles.css" is not a full Url with host name and path), then you must set HtmlToPdf.Options.BaseUrl property. Or if you use JavaScript to load styles dynamically, then you may wish to set HtmlToPdf.Options.MinLoadWaitTime to a larger value so that your JavaScript will have enough time to run and complete.

Hope this gives you some ideas. Please feel free to let us know if you still have more questions.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.