Oh, I see now... Thank you so much.
I will pass this to the DEV team, since they are more familiar with this. I am more like DevOps/Sysadmin side.
Calza36
@Calza36
Posts made by Calza36
-
RE: Using jsreport embedded on .NET App. How to configure S3 for storing templates?
-
RE: Using jsreport embedded on .NET App. How to configure S3 for storing templates?
Hi! Thanks
What I meant is that I do not have installednpm jsreport
on my server. My jsreport gets activated by the app, by the library it self. See here my code:`using BBWM.DataProcessing.Classes;
using jsreport.Client;
using jsreport.Local;
using jsreport.Types;using Microsoft.Extensions.Options;
using System.Runtime.InteropServices;
namespace BBWM.DataProcessing.Services;
/// <summary>
/// Service for creating reports using node services
/// </summary>
public class ReportService : IReportService
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly JsReportSettings _jsReportSettings;public ReportService(IHttpClientFactory httpClientFactory, IOptions<JsReportSettings> options) { _httpClientFactory = httpClientFactory; _jsReportSettings = options.Value; } /// <summary> /// Convert html to pdf /// </summary> /// <param name="htmlReport">HTML report</param> public async Task<byte[]> HtmlToPdf(string htmlReport) { var rs = new LocalReporting() .UseBinary(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? jsreport.Binary.JsReportBinary.GetBinary() : jsreport.Binary.Linux.JsReportBinary.GetBinary()) .RunInDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "data", "jsreport")) .Configure(ConfigureJsReport) .AsUtility() .Create(); var report = await rs.RenderAsync(new RenderRequest { Template = new Template { Recipe = Recipe.ChromePdf, Engine = Engine.None, Content = htmlReport, }, Options = new RenderOptions { Timeout = 300000, } }); using var ms = new MemoryStream(); report.Content.CopyTo(ms); // send the PDF file to browser return ms.ToArray(); } public async Task<byte[]> FormioHtmlToPdf(FormioHTMLData reportData) { try { return await GeneratePDFWithJsReportLocalServer(reportData); } catch (Exception ex) { // option to generate the PDF with JsReport Online return await GeneratePDFWithJsReportOnline(reportData); } } /// <summary> /// Downloading the page and converting html to pdf /// </summary> /// <param name="url">The address of the page to load</param> public async Task<byte[]> PageToPdf(string url) { using var client = _httpClientFactory.CreateClient(); var response = await client.GetAsync(url); var html = await response.Content.ReadAsStringAsync(); return await HtmlToPdf(html); } private async Task<byte[]> GeneratePDFWithJsReportOnline(FormioHTMLData reportData) { // TODO: hardoded var rs = new ReportingService("https://formio-demo.jsreportonline.net/", "xxxxxxxxx@gmail.com", "xxxxxxxxx"); var data = new { HtmlContent = reportData.HtmlContent }; var report = await rs.RenderByNameAsync("formio-template", data); using var ms = new System.IO.MemoryStream(); report.Content.CopyTo(ms); // send the PDF file to browser return ms.ToArray(); } private async Task<byte[]> GeneratePDFWithJsReportLocalServer(FormioHTMLData reportData) { var rs = new ReportingService("http://localhost:5488"); var data = new { HtmlContent = reportData.HtmlContent }; var report = await rs.RenderByNameAsync("formio-template", data); using var ms = new MemoryStream(); report.Content.CopyTo(ms); // send the PDF file to browser return ms.ToArray(); } private Configuration ConfigureJsReport(Configuration configuration) { if (!string.IsNullOrEmpty(_jsReportSettings?.TempDirectory)) configuration.TempDirectory = _jsReportSettings.TempDirectory; return configuration; }
}
`That's why I said those documentations were not what I was looking for... For using that I would have to change everything.
However, maybe that's the only way...
Or the one that I am looking for is too complicated. Supposedly I would have to modify the jsreport configuration in my libraries, trying to integrate S3 into them...Otherwise, I am looking for another approach, which will be to automate the Template's upload process each time a release is made.
-
Using jsreport embedded on .NET App. How to configure S3 for storing templates?
Using jsreport embedded on .NET. Can I add a S3 config for storing the templates I am using?
Because right now I have to upload it after each release.
The Documentation explains about installing an extension, but this is for the case in which jsreport is installed on the server, which is not my case.