Welcome Guest Search | Active Topics | Sign In | Register

Microsoft Pie Chart Low Quality Options
Alester Gómez
Posted: Wednesday, August 1, 2012 12:34:17 AM
Rank: Member
Groups: Member

Joined: 7/10/2012
Posts: 14
Hi.
A still evaluating the EO.Pdf.HtmltoPdf.ConvertUrl Method and I'm not getting y good quality of Image. Microsoft creates a physical image file in this case the format I have selected is jepg. When I review the image it has a good quality but when the pdf is created it has no good quality. Maybe I am not using the rigth setiings.
Here are some of the setting I am using:
// Set landscape
options.PageSize = new System.Drawing.SizeF(
PdfPageSizes.A4.Height, PdfPageSizes.A4.Width);
// Set margins to .5
options.OutputArea = new System.Drawing.RectangleF(0.5f, 0.5f, 11f, 8.5f);
//Image sections
options.JpegQualityLevel = 100;
options.SaveImageAsJpeg = true;
options.PreserveHighResImages = true;

Appreciate your support, The customer is waiting for a new test with new image qaulity.
Please let me know if you need I send you the images files.
eo_support
Posted: Wednesday, August 1, 2012 7:41:24 AM
Rank: Administration
Groups: Administration

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

Your code is fine. Can you create a small test project that demonstrates the problem and send it to us? We will PM you as to where to send the file.

Thanks!
Alester Gómez
Posted: Wednesday, August 1, 2012 12:38:51 PM
Rank: Member
Groups: Member

Joined: 7/10/2012
Posts: 14
Thanks.
Yes, I can send it to you but on night.
eo_support
Posted: Wednesday, August 1, 2012 12:40:57 PM
Rank: Administration
Groups: Administration

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

No problem. We will look into it as soon as we receive it.

Thanks!
eo_support
Posted: Thursday, August 2, 2012 11:26:06 AM
Rank: Administration
Groups: Administration

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

We have looked into the sample project you sent to us. There is no quality loss in the image. The reason that you see it not as clear as on the screen is because Adobe Reader scaled it. For example, if the original image is 100 pixels by 100 pixels, Adobe Reader might display it as 120 pixels by 120 pixels when you view the PDF file depending on your zoom level in the Adobe Reader.

Most of the time Adobe Reader produces very good result when it scales contents ---- this is especially true for text. As you can see your text in the PDF file actually look much smoother than what you see in a browser window. For most bitmap images, such as a scenic view, Adobe Reader can scale it without any noticeable quality loss. However for simple bitmaps with shapes, lines and text, you will notice artifacts when it is scaled. Unfortunately Adobe Reader does not have a true "100%" mode (you will notice the image size is still different than what you see in a browser even if you set Adobe Reader's zoom level to 100%). As a result, the chart image will almost always be scaled thus produces a noticeable fuzzy result.

There are two ways to resolve this issue:

1. Use a higher resolution on your chart image. Most chart control allows you to set the chart image resolution --- unfortunately this is not the case for ASP.NET Chart controls. For ASP.NET Chart control, you must first save the image into a separate image with something like this:

Code: C#
//Create a new bitmap that is the same size as the chart control
Bitmap bmp = new Bitmap(584, 338);

//Set the bitmap resolution. Here we use 120, which is higher than
//the standard resolution (standard is 96 DPI)
bmp.SetResolution(120, 120);

//Paint the Chart into the bitmap and save it
using (Graphics g = bmp.FromImage(bmp))
{
    Chart1.Paint(g, new Rectangle(0, 0, bmp.Width, bmp.Height));
}
bmp.Save(MapPath("~/test.bmp"));


Now you can reference the image in your page directly through an asp:Image control:

Code: HTML/ASPX
<asp:Image runat="server" id="ChartImg" NavigateUrl="~/test.bmp">


This image has a higher resolution and when it is converted into PDF you will notice that it has better quality.

Note that when you use this approach you will probably need to:
1. Use dynamically generated file names for each request and have some code to clean up these images files on your server;
2. Use a query string argument to distinguish regular browser request and the HTML to PDF converter request so that you only use this high resolution image logic when the request comes from HTML to PDF converter;

The above code saves the image as bmp files, which are bigger than jpeg. This is not a concern. The HTML to PDF converter will convert bmp as jpeg automatically (and apply JpegQualityLevel during the conversion). So the final PDF file size will not be affected (it will still be slightly bigger than before since now you have a higher resolution image).

2. Alternatively, you can use a different chart control that output chart in vector format such as svg instead of as bitmap format. Vector format chart can produce stunning result because it can be scaled up/down infinitely;

Hope this helps to meet your customers' requirement. Please let us know if it works for you.

Thanks!


Alester Gómez
Posted: Thursday, August 2, 2012 3:24:56 PM
Rank: Member
Groups: Member

Joined: 7/10/2012
Posts: 14
Thanks a lot for your help.
On night I will test the first option and will let you know the customer review.
Again, good time of reponse.
Great team.
eo_support
Posted: Thursday, August 2, 2012 3:27:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
You are very welcome. Please let us know how it works out for you after you tested it.


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.