Tue Apr 13, 2021 11:51 am
Thanks for the reply Brian,
your code works fine.
I´m trying to convert from an HTML page.
Here is the code:
String url = "xxxxxxxxxxxxxxx";
PdfDocument document2 = new PdfDocument();
Thread thread = new Thread(() =>
{
PdfPageBase page2 = document2.AppendPage();
PdfPageSettings setting = new PdfPageSettings();
setting.Size = PdfPageSize.A4;
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
htmlLayoutFormat.IsWaiting = true;
document2.LoadFromHTML(url, false, false, false, setting, htmlLayoutFormat);
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
//Save pdf file.
document2.SaveToFile(Server.MapPath("result.pdf"));
document2.Close();
but i receive this COM error (sorry for the portuguese)
System.Runtime.InteropServices.COMException
HResult=0x80004005
Message=Erro HRESULT E_FAIL foi retornado de uma chamada para o componente COM.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>