Click here to Skip to main content
15,885,093 members

Comments by merh (Top 26 by date)

merh 8-Sep-21 4:04am View    
Thanks Richard!
merh 12-Mar-21 12:22pm View    
Hi!My code crashes at return await browser.PrintToPdfAsync(path);

using System;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
using System.Threading.Tasks;
using System.Threading;

namespace CefTest
{
public class Program
{
private static ChromiumWebBrowser browser;

[STAThread]
public static async Task Main(string[] args)
{
await HtmlToPdfHeadless();
}

private static async Task HtmlToPdfHeadless()
{
const string testUrl = "https://www.google.com/";
var settings = new CefSettings();
Cef.Initialize(settings);
browser = new ChromiumWebBrowser(testUrl);
string path = "Test.pdf";
Task<bool> printToPdfAsync = PrintToPdfAsync(path);
var result = await printToPdfAsync;
}

public static async Task<bool> PrintToPdfAsync(string path)
{
return await browser.PrintToPdfAsync(path);

}
}


}
merh 12-Mar-21 9:54am View    
Sorry I have changed to the following and it still dosent work.
Task<int> printToPdfAsync = PrintToPdfAsync(path);
int result = await printToPdfAsync;
merh 12-Mar-21 9:24am View    
Deleted
Hi!
There is await before PrintToPdfAsync method. I have also changed the the invoked method to the following but it still dosent work.

await PrintToPdfAsync(path);
public static async Task PrintToPdfAsync(string path)
{
await browser.PrintToPdfAsync(path);
}
merh 8-Jun-20 10:18am View    
Yes, thanks!