Posted 5 August 2021, 6:31 am EST
We are receiving the following error.
Image is not created or loaded into a GcBitmap. at GrapeCity.Documents.Imaging.GcBitmap.SetDpi(Single dpiX, Single dpiY)
using (var gchtml = new GcHtmlRenderer(html))
{
using (GcBitmap b = new GcBitmap())
{
gchtml.RenderToGcBitmap(b, new HtmlToImageFormat(true, true)
{
WindowSize = new Size(414, 896), // size of browser window
DefaultBackgroundColor = Color.Empty, // this will be inferred from the HTML
MaxLeftMargin = 125,
MaxRightMargin = 125
});
b.SetDpi(300); // default resize pixel width and height is proportionate to 300DPI taken from google page found
using (var resizedBitmap = Resize(b, new Size(650, 5610)))
{
resizedBitmap.SaveAsPng(filePath);
}
}
}
The contents of the html variable is attached
We are using NuGet libraries:
- GrapeCity.Documents.Html version: 4.1.0.663.
- GrapeCity.Documents.Html.Windows.X64 version: 4.1.0.663
- NetStandard.Library version 2.0.3
Please can you advise as to what is wrong with the above code.
NOTE: This code works for most HTML, but not others, like the attached file