I have updated the code according to the document as below. Still the pdf export doesn't have the pie chart.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BoldReports.Web;
using BoldReports.Web.ReportViewer;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SSRSAuth.Configuration;
namespace SSRSAuth.Controllers
{
[Route("api/[controller]/[action]")]
[Microsoft.AspNetCore.Cors.EnableCors("AllowAllOrigins")]
public class ReportAPIController : Controller,IReportController
{
private Microsoft.Extensions.Caching.Memory.IMemoryCache _cache;
private Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;
private ReportServerConfig _reportServerConfig { get; }
private PowerBIDBConfig _powerBIDBConfig { get; }
private readonly ILogger _logger;
// Post action to process the report from server based json parameters and send the result back to the client.
public ReportAPIController(Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache,
Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment,
ReportServerConfig reportServerConfig,
PowerBIDBConfig powerBIDBConfig,
ILogger<ReportAPIController> logger
)
{
_cache = memoryCache;
_hostingEnvironment = hostingEnvironment;
_reportServerConfig = reportServerConfig;
_powerBIDBConfig = powerBIDBConfig;
_logger = logger;
}
// Post action to process the report from server based json parameters and send the result back to the client.
[HttpPost]
public object PostReportAction([FromBody] Dictionary<string, object> jsonArray)
{
return ReportHelper.ProcessReport(jsonArray, this, this._cache);
}
// Method will be called to initialize the report information to load the report with ReportHelper for processing.
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
reportOption.ReportModel.ExportResources.UsePhantomJS = true;
reportOption.ReportModel.ExportResources.PhantomJSPath = _hostingEnvironment.WebRootPath + @"\PhantomJS\";
reportOption.ReportModel.ExportResources.Scripts = new List<string>
{
"https://cdn.boldreports.com/2.2.32/scripts/common/bold.reports.widgets.min.js",
"https://cdn.boldreports.com/2.2.32/scripts/common/bold.reports.common.min.js",
//Chart component script
"https://cdn.boldreports.com/2.2.32/scripts/data-visualization/ej.chart.min.js",
//Gauge component scripts
"https://cdn.boldreports.com/2.2.32/scripts/common/ej2-base.min.js",
"https://cdn.boldreports.com/2.2.32/scripts/common/ej2-data.min.js",
"https://cdn.boldreports.com/2.2.32/scripts/common/ej2-pdf-export.min.js",
"https://cdn.boldreports.com/2.2.32/scripts/common/ej2-svg-base.min.js",
"https://cdn.boldreports.com/2.2.32/scripts/data-visualization/ej2-lineargauge.min.js",
"https://cdn.boldreports.com/2.2.32/scripts/data-visualization/ej2-circulargauge.min.js",
//Map component script
"https://cdn.boldreports.com/2.2.32/scripts/data-visualization/ej.map.min.js",
//Report Viewer Script
"https://cdn.boldreports.com/2.2.32/scripts/bold.report-viewer.min.js"
};
reportOption.ReportModel.ExportResources.DependentScripts = new List<string>
{
"https://code.jquery.com/jquery-1.10.2.min.js"
};
try
{
string basePath = _hostingEnvironment.WebRootPath;
var credential = new DataSourceCredentials()
{
ConnectionString = _powerBIDBConfig.ConnectionString,
Name = _powerBIDBConfig.Name,
UserId = _powerBIDBConfig.Username,
Password = _powerBIDBConfig.Password
};
reportOption.ReportModel.ReportServerCredential = new System.Net.NetworkCredential(_reportServerConfig.Username, _reportServerConfig.Password);
reportOption.ReportModel.DataSourceCredentials.Add(credential);
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
}
// Method will be called when reported is loaded with internally to start to layout process with ReportHelper.
public void OnReportLoaded(ReportViewerOptions reportOption)
{
}
//Get action for getting resources from the report
[ActionName("GetResource")]
[AcceptVerbs("GET")]
// Method will be called from Report Viewer client to get the image src for Image report item.
public object GetResource(ReportResource resource)
{
return ReportHelper.GetResource(resource, this, _cache);
}
[HttpPost]
public object PostFormReportAction()
{
return ReportHelper.ProcessReport(null, this, _cache);
}
}
}