Welcome Guest Search | Active Topics | Sign In | Register

HtmlToPdf adds background image Options
BrentWiens
Posted: Monday, March 24, 2014 4:56:20 PM
Rank: Newbie
Groups: Member

Joined: 3/24/2014
Posts: 7
HtmlToPdf adds background image to page that is hidden by css.

Original page
Original page generated PDF (still shows thin outline of background image)
Page sent to HtmlToPdf.ConvertUrl When sent to eo.Pdf HTML to Pdf online demo it still shows thin outline of background image.
Page sent to HtmlToPdf.ConvertUrl Generated PDF

Note the final one I have purposefully moved the margin to make the background image easier to see as hiding with OutputArea does not hide it in all cases.

All the code does is set the Header, PageSize and OutputArea. I tried using VisibleElements and InvisibleElements however the image is already hidden by CSS so didn't make a difference.
eo_support
Posted: Monday, March 24, 2014 5:11:55 PM
Rank: Administration
Groups: Administration

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

If your CSS has hidden the background image, then it will not be visible. However if you use media=print CSS rules, then EO.Pdf does NOT recognize those. Currently EO.Pdf always use screen CSS rules because most of our users wish the PDF to appear exactly as they appear on screen.

If that's the problem, then there are two ways to avoid this problem. One way is to code your server so that it renders uses different CSS rules when it's being converted to PDF. For example, you can add a query string parameter when converting to PDF so that your server can check that query string and render it differently. Another way is to use client side JavaScript to detect whether your page is running inside the converter, and if you see your page is running inside the converter, you can use JavaScript to turn the background image off. You can find more information on how to detect if your page is running inside the converter here:

http://www.essentialobjects.com/doc/4/htmltopdf/eo_js.aspx

Thanks!
BrentWiens
Posted: Tuesday, March 25, 2014 10:07:55 AM
Rank: Newbie
Groups: Member

Joined: 3/24/2014
Posts: 7
Thanks! Finally solved this, someone was setting the background image directly in one of the .css files between certain resolutions which eo.PDF was hitting. Removing the div with background image and styling didn't help as it was being set directly.
eo_support
Posted: Tuesday, March 25, 2014 11:19:32 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Ah great. Glad to hear that it's working for you. Thanks for the update!


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.