Welcome Guest Search | Active Topics | Sign In | Register

Convert HTML to PDF With Color Options
Bob Pinella
Posted: Wednesday, March 25, 2015 5:39:13 PM
Rank: Member
Groups: Member

Joined: 10/14/2014
Posts: 17
Hello,
I am experiencing a strange problem when trying to convert HTML to a PDF. I have an HTML file that uses all inline styles and sticks to e-mail friendly attributes. This HTML file has a table with several rows of data and each tr has 2 tds. The header row is supposed to have a gray background as well as the first td of each row. I am converting using HtmlToPdf.ConvertHtml and passing in my HTML along with a simple options object as follows:

EO.Pdf.PdfDocument pdf = new EO.Pdf.PdfDocument();
EO.Pdf.HtmlToPdf.Options.AutoFitX = EO.Pdf.HtmlToPdfAutoFitMode.ScaleToFit;
EO.Pdf.HtmlToPdf.Options.AutoFitY = EO.Pdf.HtmlToPdfAutoFitMode.ScaleToFit;
EO.Pdf.HtmlToPdf.ConvertHtml(htmlBody, pdf);
pdf.Save(ms);

If I remove the background color from my table cells, it generates as expected. However when I add background-color: #CCCCCC; to the appropriate cells, the rendering gets messed up. If I view the PDF at 190% scale, everything looks fine. However as I lower the percentage some borders disappear, the edges look like they are cut off and some of the borders look darker than others. Any idea what could be causing this? I can send you the PDF via email if that helps. Thank you for your time.

Bob Pinella
eo_support
Posted: Thursday, March 26, 2015 10:04:16 AM
Rank: Administration
Groups: Administration

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

This is a known issue. The root of the problem is that in PDF coordination are expressed in float values, which would always introduce rounding errors when zoomed in/out. The rounding error sometimes would be big enough to cause the result to falls onto different integer values (which is used on screen), when this occurs, it causes the artifacts you observed. Currently we are not aware of any way to work around this yet, but obviously such artifact is an annoyance so we won't close the issue and stop researching on this issue.

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.