diff --git a/Controllers/ReportDesignerWebApiController.cs b/Controllers/ReportDesignerWebApiController.cs index ccbd486..41a5dd9 100644 --- a/Controllers/ReportDesignerWebApiController.cs +++ b/Controllers/ReportDesignerWebApiController.cs @@ -119,6 +119,7 @@ public void OnInitReportOptions(ReportViewerOptions reportOption) reportOption.ReportModel.ReportServerUrl = this.ServerURL; reportOption.ReportModel.EmbedImageData = true; reportOption.ReportModel.ReportServerCredential = new NetworkCredential("Sample", "Passwprd"); + reportOption.ReportModel.ExportResources.BrowserExecutablePath = Path.Combine(_hostingEnvironment.WebRootPath, "puppeteer", "Win-901912", "chrome-win"); if (reportOption.ReportModel.FontSettings == null) { diff --git a/Controllers/ReportViewerWebApiController.cs b/Controllers/ReportViewerWebApiController.cs index 276664c..7ea1325 100644 --- a/Controllers/ReportViewerWebApiController.cs +++ b/Controllers/ReportViewerWebApiController.cs @@ -76,7 +76,7 @@ public void OnInitReportOptions(ReportViewerOptions reportOption) reportOption.ReportModel.FontSettings = new BoldReports.RDL.Data.FontSettings(); } reportOption.ReportModel.FontSettings.BasePath = Path.Combine(_hostingEnvironment.WebRootPath, "fonts"); - + reportOption.ReportModel.ExportResources.BrowserExecutablePath = Path.Combine(_hostingEnvironment.WebRootPath, "puppeteer", "Win-901912", "chrome-win"); } // Method will be called when reported is loaded with internally to start to layout process with ReportHelper. diff --git a/Controllers/ReportWriterController.cs b/Controllers/ReportWriterController.cs index d8986d4..bc510aa 100644 --- a/Controllers/ReportWriterController.cs +++ b/Controllers/ReportWriterController.cs @@ -59,9 +59,11 @@ public IActionResult Generate(string reportName, string type) reportWriter.ReportServerCredential = System.Net.CredentialCache.DefaultCredentials; reportWriter.ReportProcessingMode = ProcessingMode.Remote; - reportWriter.ExportSettings = new customBrowsertype(_hostingEnvironment); reportWriter.ExportResources.BrowserType = ExportResources.BrowserTypes.External; reportWriter.ExportResources.ResourcePath = Path.Combine(basePath, "puppeteer"); + string puppeteerPath = reportWriter.ExportResources.ResourcePath + @"/Win-901912/chrome-win/chrome.exe"; + reportWriter.ExportSettings = new customBrowsertype(puppeteerPath); + reportWriter.ExportResources.BrowserExecutablePath = Path.GetDirectoryName(puppeteerPath); FileStream inputStream = new FileStream(Path.Combine(basePath, "resources", "Report", reportName + ".rdl"), FileMode.Open, FileAccess.Read); reportWriter.LoadReport(inputStream); @@ -139,11 +141,11 @@ public IActionResult Generate(string reportName, string type) public class customBrowsertype : ExportSettings { - private IWebHostEnvironment _hostingEnvironment; + private string _puppeteerPath; - public customBrowsertype(IWebHostEnvironment hostingEnvironment) + public customBrowsertype(string path) { - _hostingEnvironment = hostingEnvironment; + _puppeteerPath = path; } public override string GetImageFromHTML(string url) { @@ -151,8 +153,6 @@ public override string GetImageFromHTML(string url) } public async Task ConvertBase64(string url) { - string puppeteerChromeExe = ""; - puppeteerChromeExe = Path.Combine(_hostingEnvironment.WebRootPath, "puppeteer", "Win-901912", "chrome-win", "chrome.exe"); await using var browser = await PuppeteerSharp.Puppeteer.LaunchAsync(new PuppeteerSharp.LaunchOptions { Headless = true, @@ -167,7 +167,7 @@ public async Task ConvertBase64(string url) "--dump-blink-runtime-call-stats", "--profiling-flush", }, - ExecutablePath = puppeteerChromeExe + ExecutablePath = _puppeteerPath }); await using var page = await browser.NewPageAsync(); await page.GoToAsync(url);