I'm working on rendering an image on a pdf document. The rendering is done in C# method like this:
public void PrintPdf(System.Drawing.Image image, string htmlCode, string url)
{
PdfDocument Document = new PdfDocument();
Document.Margins = new PdfDocumentMargins(20, 20, 20, 20);
Document.ImagesCompression = 0;
Document.Compress = false;
Document.SerialNumber = "our-serial-number";
PdfPage page = Document.AddPage(PdfPageSize.A4, Document.Margins, PdfPageOrientation.Portrait);
PdfHtml overlayHtml = new PdfHtml(0, 0, htmlCode, url);
overlayHtml.BrowserWidth = 740;
overlayHtml.MediaType = "print";
PdfLayoutInfo layoutInfo = page.Layout(overlayHtml);
PdfImage pdfImage = new PdfImage(0, (float)115.5, image);
layoutInfo = page.Layout(pdfImage); // <-- this row causes exception from the HiQPdf library
}
The last row throws the following exception from the HiQPdf library. Any thoughts on why?
[HiQPdfException: Cannot layout the image]
HiQPdf.PdfImage.LayoutObject(PdfCanvas objectsContainer) +7243
HiQPdf.PdfPage.Layout(PdfObject pdfObject) +86
This error started happening after we updated HiQPdf version from 5.4.0.0 to 10.17.0.0
The parameters seem ok, there is normal html in htmlCode and I don't see anything wrong with the image either. The image itself can be downloaded as png well as pdf, which works fine.