Welcome Guest Search | Active Topics | Sign In | Register

Images are ugly? Options
Michael
Posted: Thursday, April 11, 2013 1:57:12 PM
Rank: Newbie
Groups: Member

Joined: 4/11/2013
Posts: 5
I'm doing some tests and the PageImages look like they're getting scaled into oblivion, and the result is not pleasing. Below is the code:

Code: C#
var options = new EO.Pdf.HtmlToPdfOptions();
options.GeneratePageImages = true;
options.PreserveHighResImages = true;
options.JpegQualityLevel = 0;
options.SaveImageAsJpeg = true;

var results = EO.Pdf.HtmlToPdf.ConvertHtml(html,ms, options);
var img = results.PageImages.First();

var ms2 = new MemoryStream();
img.Save(ms2, System.Drawing.Imaging.ImageFormat.Jpeg);


This is probably the last thing I need in order to accomplish everything, I'm hoping I'm just doing something nutty :)
eo_support
Posted: Thursday, April 11, 2013 2:08:41 PM
Rank: Administration
Groups: Administration

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

No. Your code is fine and that's normal. PreerveHighResImages and JpegQualityLevel has no impact on page images. When the converter renders an HTML into bitmap, it saves it at screen resolution, which is a very low resolution (usually at 96 DPI. Most image at least have 600 DPI, even a very low end scanner will starts from 300 DPI). So if you zoom into, it can get very ugly. Generally speaking, flatting out a PDF file into an image is not a good idea because it rasterizes everything. And the very reason why PDF is so popular is because its in vector format. That's why you can zoom into it infinitely without losing quality. Once you rasterize it, everything is lost.

SaveImageAsJpeg and JpegQualityLevel is used for images in the PDF file, not for PageImages. So they are unrelated.

Thanks!
Michael
Posted: Thursday, April 11, 2013 2:12:17 PM
Rank: Newbie
Groups: Member

Joined: 4/11/2013
Posts: 5
Is there a way 'save' it at a higher dpi? I'm not sure I see the point of being able to grab the images if there's no way to make the presentable.
eo_support
Posted: Thursday, April 11, 2013 2:22:58 PM
Rank: Administration
Groups: Administration

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

It should be presentable if you don't zoom in because it's saved at screen resolution, unless you have some advanced elements in your page such as vector graph. The only way to have a higher resolution is change your system's screen resolution to a higher DPI settings. I am not sure if that's a workable solution for you though.

Thanks!
Michael
Posted: Thursday, April 11, 2013 3:05:02 PM
Rank: Newbie
Groups: Member

Joined: 4/11/2013
Posts: 5
The system this is being run on is a server, so using the system screen isn't going to work for us. The html to pdf component works well, but the PageImages functionality won't meet our needs.


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.