Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Controllers/ReportDesignerWebApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Controllers/ReportViewerWebApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions Controllers/ReportWriterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -139,20 +141,18 @@ 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)
{
return ConvertBase64(url).Result;
}
public async Task<string> 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,
Expand All @@ -167,7 +167,7 @@ public async Task<string> 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);
Expand Down