I'm trying to export an HTML page to PDF with ABCpdf. The text converts OK but the charts are very blurry. I've tried increasing the font size and it helps very little. What could be the solution?
EDIT: I'm using the asp.net charts if that helps.
I'm trying to export an HTML page to PDF with ABCpdf. The text converts OK but the charts are very blurry. I've tried increasing the font size and it helps very little. What could be the solution?
EDIT: I'm using the asp.net charts if that helps.
You'll need to output the charts at a higher DPI. Not sure if you can do this with abcpdf though.
I am assuming your chats are images? If so the reason for the blur is that the DPI on the HTML image is 72 DPI and the DPI of the rendered pdf is 300 DPI.
The only way I know round this is to have the images in the HTML a much higher resolution (300 DPI) then reduce the size with a set height and width on the page. When ABCPdf imports the image it will download the source and look much nicer.
Other answers are on the right track, but not quite there.
The browser "usually" displays things at 96 DPI. This depends on settings but we're pretty safe to assume here. The PDF is going to scale to 72 DPI. So you need your Rect to be set to 3/4 the browser width. Then your images will look correct.
As a side effect you may end up needing a higher resolution image in order to get the size you want (you can increase the resolution of an image by the inverse, i.e. by a factor of 4/3 to achieve parity with what you'd see in a browser).
Using the code below, your images will never blur (though you may need to adjust your expected document width; a PDF with a width of 612pt @ 72 DPI (letter-sized portrait orientation, for example) needs to be backed by a browser width of 816px @ 96 DPI):
const Double pdfDpi = 72;
const Double browserDpi = 96;
var browserToPdfDpiRatio = BrowserDpi / PdfDpi;
pdf.HtmlOptions.BrowserWidth = (Int32)Math.Round(pdf.Rect.Width * browserToPdfDpiRatio, 0);