From 30743d7b858f1c872be76f90c39d52a7e6c9912c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 10 Sep 2020 16:24:07 +0000 Subject: [PATCH] --- devdocs/specs/core-reporting.txt | 103 ++++++++++++++++++++++++++++++- server/AyaNova/biz/WidgetBiz.cs | 15 +++-- server/AyaNova/models/Report.cs | 3 +- 3 files changed, 114 insertions(+), 7 deletions(-) diff --git a/devdocs/specs/core-reporting.txt b/devdocs/specs/core-reporting.txt index c6183ed0..8a7a0251 100644 --- a/devdocs/specs/core-reporting.txt +++ b/devdocs/specs/core-reporting.txt @@ -23,4 +23,105 @@ REQUIREMENTS - When report is run it will have all fields this way returned but will still be sorted and filtered by table view - As part of editing process user can select an existing datalistview to prime their report editing view - A report can be selected from any client table that is based on the same view - \ No newline at end of file + + +//======================= + + +USEFUL REPORTING RELATED LINKS + + https://github.com/jsreport/jsreport-core + https://github.com/jsreport/jsreport-core/blob/master/lib/render/engineScript.js + + //actual render here + https://github.com/jsreport/jsreport-chrome-pdf/blob/d3fe318aac3628d8cb62f86f8f71314f21745798/lib/conversion.js + + This is the jsreport designer libs used for reference: https://github.com/jsreport/jsreport-studio/blob/master/package.json +https://jsreport.net/learn/api + +Report templates pre-designed and open source: https://github.com/wildbit/postmark-templates + +HTML -> PDF + JSREPORT has a comparison table of various html to pdf tools here: + https://jsreport.net/learn/pdf-recipes + + + Headless Chrome + https://github.com/jsreport/jsreport-chrome-pdf + FAST SPEED (according to jsreport docs) + jsreport uses headless chrome by default which has built in pdf from html ability. + they use a NODE library Puppeteer for it, but there is a c# wrapper for .net core linux windows mac: https://github.com/hardkoded/puppeteer-sharp + some kind of example that may be relevant: https://github.com/kblok/netconfar-puppeteer-sharp-demo/blob/master/hacking-the-browser-api/Controllers/MediumController.cs#L13 + Maybe not the only one for c# core, need to dig around + Issues: + Issue with header / footer not being settable apparently which is a big breaking issue for many biz reports usage + someone said that another pdf tool can be used to set those post processing but fuckery abounds + other solutions below apparently don't have this issue. + Even jsreport has listed workarounds and tools to resolve this + Update: apparently there are ways: + https://stackoverflow.com/questions/44575628/alter-the-default-header-footer-when-printing-to-pdf?noredirect=1&lq=1 + see last comment seems relevant, also other linked cases all mention various things. Finally, could use a pdf writer tool to post process maybe. + + There seem to be many potential issues with missing libraries, rights and sandbox and etc etc etc on linux + These things kind of turned me off this a bit, it's not plug and play and simple + + + LINKS: + https://github.com/hardkoded/puppeteer-sharp + https://github.com/puppeteer/puppeteer + https://stackoverflow.com/search?q=puppeteer-sharp + https://stackoverflow.com/questions/62042078/puppeteer-sharp-for-server-side-html-to-pdf-conversions + https://www.singlestoneconsulting.com/blog/how-to-generate-server-side-pdf-reports-puppeteer-d3-handlebars/ + https://github.com/hardkoded/puppeteer-sharp/issues/1510 - shows being used by someone other than jsreport which buries all the details in endless libs + https://github.com/hardkoded/puppeteer-sharp/issues/1514 + + WeasyPrint + https://github.com/jsreport/jsreport-weasyprint-pdf + SLOWEST SPEED + https://github.com/Kozea/WeasyPrint based on python, does it's own rendering doesn't rely on a web browser engine like the rest + free, recommended by wkhtmltopdf author as an alternative + May be slow, slower than the other options likely, has some installation steps that are a bit convoluted but ironically only for windows as it's included in package managers + Very good support for modern css3 PAGE properties apparently + WRAPPER + https://github.com/balbarak/WeasyPrint-netcore/blob/master/src/Balbarak.WeasyPrint/WeasyPrintClient.cs + + + wkhtmltopdf + https://github.com/jsreport/jsreport-wkhtmltopdf + MEDIUM SPEED + https://wkhtmltopdf.org/downloads.html + Well used, old based on older webkit so doesn't support css3 but likely enough for our purposes + has an easy installer for all platforms + free + Has warnings about how unsanitized html can take down a server or own it somehow + WRAPPERS + https://github.com/carloscds/HtmlToPDFCore/tree/master/HtmlToPDFCore This one looks cool, all platforms supported includes binary possibly? + https://blog.elmah.io/generate-a-pdf-from-asp-net-core-for-free/ + + +HTML -> DOCX + This is a possiblity that needs to be researched, instead of pdf go docx which is in theory multi platform and openable on other devices? Not sure + https://github.com/jsreport/jsreport-docx + https://github.com/EricWhiteDev/Open-Xml-PowerTools + +HTML -> XLSX + https://github.com/jsreport/jsreport-xlsx + +HTML -> TEXT + https://github.com/jsreport/jsreport-html-to-text + https://github.com/jsreport/jsreport-text + + +TEMPLATE ENGINE + https://github.com/jsreport/jsreport-handlebars + Handlebars by default for jsreport which is easy peasy to work with + +PDF META DATA EDITING + https://github.com/jsreport/jsreport-pdf-meta + +Render outputs + JSReport renders to different outputs, they call it recipes https://jsreport.net/learn/recipes + HTML - just outputs as html for viewing in the browser / printing from browser + PDF: https://jsreport.net/learn/pdf-recipes + Outputs 5 different pdf converters because they all support different feature sets which is ominous + diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index a0428960..e898f757 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -13,7 +13,7 @@ namespace AyaNova.Biz { internal class WidgetBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject { - + internal WidgetBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles) { @@ -284,9 +284,16 @@ namespace AyaNova.Biz //whatever needs to be check to delete this object } - + //Fulfil report request for data public async Task GetReportData(long[] idList) - { + { + //NOTE: Report widget is a superset of biz object widget + //Biz objects will add and needed linked records here as extra fields with the data included + //for example instead of a userid only there will be username added to the record + //so the report designer can just select it as a field, no need to query seperately for it etc + //REMEMBER: there is a name display format system and it should honour that so that the report + //displays a user the same as it would display in the UI in an input form, no surprises + JArray j = new JArray(); while (idList.Any()) { @@ -299,7 +306,7 @@ namespace AyaNova.Biz foreach (Widget w in orderedList) { j.Add(JObject.FromObject(w)); - } + } } return j; } diff --git a/server/AyaNova/models/Report.cs b/server/AyaNova/models/Report.cs index f35c8f2d..f750b1a3 100644 --- a/server/AyaNova/models/Report.cs +++ b/server/AyaNova/models/Report.cs @@ -29,8 +29,7 @@ namespace AyaNova.Models [Required] public ReportRenderType RenderType { get; set; } - //tentative in case of need - // public string Locale { get; set; } + //tentative in case of need in future // public string Header { get; set; } // public string Footer { get; set; }