private ChromeProxy(ChromeProcess process, ChromeProxySettings settings) { _process = process; _settings = settings; _remoteDebuggerClient = new RemoteDebuggerClient(); _embeddedResourceReader = new EmbeddedResourceReader(); }
private void Convert(string infile, string outfile, ILogger logger = null) { using (var chrome = new ChromeProcess()) { chrome.EnsureRunning(); ConvertWithProcess(chrome, infile, outfile); } }
public static ChromeProxy Launch(ChromeProxySettings settings = null) { settings = settings ?? new ChromeProxySettings(); var process = ChromeProcess.Start(settings); var chromeProxy = new ChromeProxy(process, settings); chromeProxy.Attach(settings); return(chromeProxy); }
private void ConvertWithProcess(ChromeProcess process, string infile, string outfile) { var pageSettings = new PageSettings(); using (var converter = new Converter(process)) { converter.ConvertToPdf(new ConvertUri(infile), outfile, pageSettings); } if (!File.Exists(outfile)) { throw new Exception($"HTML to PDF conversion failed; No result: {outfile}"); } }
public void StressTest() { using (var chrome = new ChromeProcess()) { chrome.EnsureRunning(); var infile = Guid.NewGuid() + ".xml"; infile = Path.Combine(Path.GetTempPath(), infile); File.WriteAllText(infile, _xmlFileContent); for (var i = 0; i < 100; i++) { var outfile = Guid.NewGuid() + ".pdf"; outfile = Path.Combine(Path.GetTempPath(), outfile); ConvertWithProcess(chrome, infile, outfile); } } }
public void TreadingStressTest() { using (var chrome = new ChromeProcess()) { chrome.EnsureRunning(); var infile = Guid.NewGuid() + ".xml"; infile = Path.Combine(Path.GetTempPath(), infile); File.WriteAllText(infile, _xmlFileContent); var tasks = new List <Task>(); for (var i = 0; i < 100; i++) { tasks.Add(Task.Run(() => { var outfile = Guid.NewGuid() + ".pdf"; outfile = Path.Combine(Path.GetTempPath(), outfile); ConvertWithProcess(chrome, infile, outfile); })); } Task.WaitAll(tasks.ToArray()); } }