This project is read-only. HtmlRender.RenderToImage : Problem

Jan 4, 2014 at 3:13 AM
First, I have to say that this library is just about the most awesome thing I have ever found. Being able to go directly from my complex HTML straight to an image without having to create an HTML File, then a PDF, then an image from the PDF.... is amazing.

I ran into the the AA issues that others have brought up with the HtmlRender.Render method, so I wanted to give HtmlRender.RenderToImage a whirl. No matter what I pass in, I get the following error message:

_"PInvokeStackImbalance was detected
Message: A call to PInvoke function 'HtmlRenderer!HtmlRenderer.Utils.Win32Utils::BitBlt' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."_

HERE IS MY METHOD INVOCATION: (the html is valid html, and .Render and .RenderToImageGdiPlus work, only they have aliased text)

public void SaveHTMLToImage(string html, string filename)

        Size MaxSize = new Size(500, 700);
        var image = HtmlRender.RenderToImage(html, MaxSize);
Any ideas as to what I might need to do to resolve the issue?

Thank you!
Jan 4, 2014 at 3:18 AM
Oh boy... I have been sitting with this problem for about 6 hours straight now... and someone looking over my shoulder chuckled and told me to do the following:

deselect the Managed Debugging Assistants--> PInvokeStackImbalance option.

Thank you,
Marked as answer by mynameisandycook on 1/3/2014 at 7:18 PM
Jan 4, 2014 at 5:46 PM
Sorry about that the BitBlt function has incorrect signature.
The proper way to fix it is to change the signature to:
public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
(the last argument needs to be int and not long)

Jan 18, 2014 at 11:32 AM
fixed in
Marked as answer by ArthurTep on 3/10/2014 at 7:01 AM