Hi Team,
when converting HTML to PNG while using HTMLDocument the fond and other css are braking. where as when we convert the html to PDF and then to image it is retaining the font and css.
in the code snippet attached when convertType = 0, i’m converting the html to pdf and then to png.
when converttype=1, then html to png.
the output of the two are very different. i need the output same as converting to pdf and then to image. let me know what approach to follow.
i’m using .net 8 framework. with Aspose.pdf 19.7 and aspose.html 19.7
aspose.zip (66.2 KB)
@NPSwaroop
We are checking it and will get back to you shortly.
@NPSwaroop
We tested using 24.8 version of the API and we noticed the issue in our environment during initial investigation. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): HTMLNET-5757
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@NPSwaroop
We have investigated this issue and discovered the following points:
- Obviously you set up the page size in pixels. But in this case the vertical & horizontal resolution settings have no effect and resolution is set to 96 dpi, because this is the only way to keep the page size you want if the size is set in pixels. If you want to obtain higher resolution, use page size in millimeters, centimeters or inches as follows:
options.PageSetup.AnyPage = new Aspose.Html.Drawing.Page(new Drawing.Size(Unit.FromMillimeters(210), Unit.FromMillimeters(297)));
- The broken font appearance is caused by GDI+ smoothing (antialiasing) peculiarity. By default the background color is transparent black, or 0x00000000 in ARGB. With this background color, antialiasing on the font drawing produces black artifacts on the edge of glyphs, on a low resolution (96 dpi) they are relatively big and nicely visible, and significantly distort the font appearance; on a higher resolution (300 dpi e.g.) such effect is present too but it is almost invisible.
To bypass it, you may use non-transparent background color; set up it in ImageSaveOptions:
var options = new ImageSaveOptions(ImageFormat.Png)
{
Compression = Compression.CCITT4,
SmoothingMode = SmoothingMode.HighQuality,
HorizontalResolution = 300,
VerticalResolution = 300,
BackgroundColor = System.Drawing.Color.White
};
The issues you have found earlier (filed as HTMLNET-5757) have been fixed in this update. This message was posted using Bugs notification tool by avpavlysh