Git Product home page Git Product logo

nathanaela / fluentreports Goto Github PK

View Code? Open in Web Editor NEW
372.0 31.0 84.0 13.05 MB

:page_facing_up: Fluent Reports - Data Driven Reporting Engine for Node.js and Browsers :page_facing_up:

Home Page: https://fluentreports.com

License: MIT License

JavaScript 96.44% CSS 1.23% HTML 2.32%
reporting report report-engine node browser pdf generate data-driven data-driven-workflows reporting-engine report-pdf browsers

fluentreports's Introduction

Fluent Reports

.github/workflows/renderer.yml

npm npm npm GitHub last commit Dependencies


Funding and sponsorship

github

You can now sponsor us on Github: https://github.com/sponsors/NathanaelA


Website and demos

See: https://www.fluentreports.com for more information.

Fluent Reports - Data Driven PDF Reporting Engine for Node.js and Browsers

Try out the reporting engine in your own browser at https://www.fluentreports.com/demo.html

Install

npm install fluentreports

Common JS

Use: const Report = require( 'fluentReports' ).Report;

ESM Support

Please use import { Report } from 'fluentReports/lib/esm/fluentReports.mjs'; as the ESM wrapper is located in the /lib/esm/ folder...

Documentation

Please read the commands.md file for an overview of all the commands. The files in the docs/ folder are generated from the source code via jsdocs, so they might be more up to date.

Please read the examples readme file for a list of examples.

Please read the tutorial.md file for the tutorials.

Features:

  • New: JSON based reports
  • New: Report Generator
  • Testing Harness to verify reports look the same after any updates
  • Completely Data Driven. You pass in the data; you tell it easily how to print the data, and it generates the PDF report.
  • Data agnostic, can be arrays, and/or objects; whatever you prefer.
  • Headers, Footers, Title Headers, Summary Footers - Both built-in and totally customizable
  • Grouping, nested grouping, and yes even more nested groupings...
  • Auto-Summing (and other automatic totals like max/min/count)
  • Sane defaults, and the ability to easily override not only the defaults but pretty much every aspect of the report generation.
  • Images, Gradients, Text, Fonts, Lines, and many other PDF features supported.
  • Data can come from anywhere, and the report engine even support Pageable data loading and related(or sub-query) data loading.
  • Sub-Reports, Sub-Sub-Reports, etc...
  • Bands (Tables/Grids) & Suppressed Bands (w/ column wrapping or column clipping)
  • Free Flow Text
  • Ability to override each part of the report for total customization of your report
  • Fluent API
  • Ability to put data over images; gradients, etc.
  • Quickly generate complex reports with minimal lines of code.
  • Colorization, Font & other changes of text per cell in Bands
  • Synchronous and Asynchronous support. If your report doesn't need to do anything Async, you can just code it without any callbacks.
  • Group Headers can be (re)printed on every new page, always, and only once.
  • Page Numbers and total number of pages
  • Text rotation
  • Cancelling of report

See the simple & stupid examples for a overview on how to generate a somewhat complex report. In these reports I tried to throw in a chunk of the features to try and give you and idea how powerful the engine is and how to use certain features.

Examples

Currently, we ship multiple examples.

Browser Based Examples

There is a demo_html.htm file in the examples folder that shows how to setup a browser ONLY based report the runs 100% in a browser. There is a readme.md in the generator folder for how to do a browser based reporting system with GUI that runs in the browser.

Simple Sample Report

This following report is using the a few of the simplest report methods. We can show you how quickly you can create a simple report.
You have the ability to EASILY FULLY override any and all of the Headers, Footers, and Detail bands (and much more).

Really Simple Report:

  // Our Simple Data in Object format:
  const data = [{name: 'Elijah', age: 18}, {name: 'Abraham', age: 22}, {name: 'Gavin', age: 28}];
  
  // Create a Report  
  const rpt = new Report("Report.pdf")        
        .pageHeader( ["Employee Ages"] )      // Add a simple (optional) page Header...        
        .data( data )	 			 	      // Add some Data (This is required)
		.detail( [['name', 200],['age', 50]]) // Layout the report in a Grid of 200px & 50px
        .render();  				          // Render the Report (required if you want output...)

One other sample report using a list type output:

      const data = [
           {item: 'Bread', count: 5, unit: 'loaf'},
           {item: 'Egg', count: 3, unit: 'dozen'},
           {item: 'Sugar', count: 32, unit: 'gram'},
           {item: 'Carrot', count: 2, unit: 'kilo'},
           {item: 'Apple', count: 3, unit: 'kilo'},
           {item: 'Peanut Butter', count: 1, unit: 'jar'}
      ];
      
      const rpt = new Report("grocery1.pdf")      
          .data( data )									 // Add our Data
          .pageHeader( ["My Grocery List"] )    		 // Add a simple header          
          .detail("{{count}} {{unit}} of {{item}}")      // Put how we want to print out the data line.
          .render(); 							         // Render the Report (required if you want output...)

GUI & Browser Implementations

See the generator documentation

fluentreports's People

Contributors

beauwest avatar christensson avatar frustrated-programmer avatar mgetz avatar mike-koder avatar nathanaela avatar xypherbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluentreports's Issues

Not an Issue, Urgent Question : Saving to disk

This is not really an issue. I am trying to save the file on the server and send it as an attachment. At this point I am trying a simple example to make sure it works.

var rpt = new Report("xnReport.pdf")
                    .pageHeader( ["Employee Ages"] )            // Add a simple (optional) page Header...
                    .data( data )                               // Add some Data (This is required)
                                                                // Layout the report in a Grid of 200px & 50px
                rpt.outputType( Report.renderType.file );
                rpt.render( function (err, name){
                    if( !err) {
                        console.log( name + '' + 'saved!!');
                    }
                });

Code runs without an error and I do get the callback console.log but I can't see the file anywhere. What am I doing wrong? Any help is much appreciated.

Times-Roman not working with fontBold attribute

If font is set to "Times-Roman" and fontBold attribute is set true in for example a .band() construct the font face doesn't change. However if font is set to "Helvetica" everything works as expected.

Howto reproduce:

  1. Go to the demo-page: http://www.fluentreports.com/demo.html
  2. Add fontBold: true to for example line 43 to render the "Date:" string in bold face using "Times-Roman". Nothing happens.
  3. Modify the font on line 47 to "Helvetica" and now the "Date:" string is rendered using bold font face.

_renderFooter error when adding multiple sub reports

Hi,

Thanks for your work on this project. I raised some issue when tried to add multiples sub reports on a main report, like this :

 var mainReport = new Report('assets/report.pdf')
        .data(formData)
        .pageheader('test')
        .footer('test')
        .pageFooter('test');

        var overviewReport = new Report(mainReport)
        .data(formData)
        .titleHeader('title1');

        var introductionReport = new Report(mainReport)
        .data(formData);

My goal is to use these subreports as "modules", and rendering later only selected subreports in the main report.
When rendering, i get an error on _renderFooter property of children, on line 3927 of fluentReport.js :

    _renderFooter: function (Rpt, State, callback) {
        var i, cnt = this._children.length, done = -1;
        var self = this;

        var renderFooterHandler = function () {
            done++;
            if (done === cnt) {
                callback();
            } else {
                self._children[done]._renderFooter(Rpt, State, renderFooterHandler);
            }
        };

        if (callback) {
            renderFooterHandler();
        } else {
            for (i=0;i<cnt;i++) {
                this._children[i]._renderFooter(Rpt, State); //_renderFooter is undefined :(
            }
        }
    },

I tried to use these reports with and without footers, but I can't figure out what I'm doing wrong ; your code seems to basically manage multiple children reports.
Can you give me a sample code of multiple subreports ?

Overlapping Final Summary and Page Footer

I am encountering an issue wherein the final summary overlaps with the page footer. I just want the page footer to be always at the bottom of the page so I set a specific y-coordinate, but sometimes this happens. I cannot upload a sample PDF as it is not supported here. Here is my code instead:

var Report = require('fluentreports').Report;

function constructReport() {
"use strict";

var orderItems = [
    {number: 1, description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Lorem ipsum dolor sit amet, consectetur adipisicing el", quantity: 1, amount: 100, common: 1},
    {number: 2, description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Lorem ipsum dolor sit amet, consectetur adipisicing el", quantity: 1, amount: 100, common: 1},
    {number: 3, description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Lorem ipsum dolor sit amet, consectetur adipisicing el", quantity: 1, amount: 100, common: 1},
    {number: 4, description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Lorem ipsum dolor sit amet, consectetur adipisicing el", quantity: 1, amount: 100, common: 1}
];

var pageHeader = function(report, data) {
    report.fontSize(14);
    report.setCurrentY(50);

    //Company Name, INVOICE
    report.band([
        {data: "Best Products, Inc.", width: 270, fontBold: true},
        {data: "INVOICE", align: 3, width: 260, fontBold: true}
    ], {border: 0, wrap: 1}); 

    report.fontSize(10);

    //Company Address, Invoice Date
    report.band([
        {data: "#35", width: 270},
        {data: "12/01/2013", align: 3, width: 260}
    ], {border: 0, wrap: 1}); 

    report.band([
        {data: "City, State Zip Code", width: 270},
        {data: "Invoice #001", align: 3, width: 260}
    ], {border: 0, wrap: 1}); 

    report.band([
        {data: "85-23923-3102923", width: 270},
        {data: "12345", align: 3, width: 260}
    ], {border: 0, wrap: 1}); 

    report.band([
        {data: "1232193210-01", width: 530},
    ], {border: 0, wrap: 1}); 

    report.newLine(5);
}

var detailBondBody = function(report, data) {
    report.fontSize(11);

    report.band([
                {data: data.number, width: 50, align: 2},
                {data: data.description, width: 300},
                {data: data.quantity, width: 60},
                {data: data.amount, width: 120}], {border: 0, width: 0, wrap: 1});
};

var pageFooter = function(report, data) {
    //report.newLine(); 

    report.print("Invoice #001", {width: 530, y: 720, align: "right"});
    report.print("Company slogan here!", {width: 530, align: "right"});

    //report.newLine();
}

var finalSummary = function(report, data) {
    report.newLine();

    report.band([
                {data: "", width: 350},
                {data: "Subtotal", width: 60},
                {data: "1000", width: 120}], {border: 0, width: 0, wrap: 1});

    report.band([
                {data: "", width: 350},
                {data: "Taxable", width: 60},
                {data: "1000", width: 120}], {border: 0, width: 0, wrap: 1});

    report.band([
                {data: "", width: 350},
                {data: "Tax Rate", width: 60},
                {data: "1000", width: 120}], {border: 0, width: 0, wrap: 1});

    report.band([
                {data: "", width: 350},
                {data: "Tax Due", width: 60},
                {data: "1000", width: 120}], {border: 0, width: 0, wrap: 1});

    report.band([
                {data: "", width: 350},
                {data: "Other", width: 60},
                {data: "1000", width: 120}], {border: 0, width: 0, wrap: 1});

    report.band([
                {data: "", width: 350},
                {data: "Total Due", width: 60},
                {data: "1000", width: 120}], {border: 0, width: 0, wrap: 1});
}

var report = new Report("issue_overlapping.pdf", {paper: "letter"});
report.pageHeader(pageHeader)
      .data(orderItems)
      .detail(detailBondBody)
      .pageFooter(pageFooter)
      .margins(40);

report.groupBy("common")
      .footer(finalSummary);

report.printStructure();

var pdf = report.render(function(err, name) {
    if (err) {
        console.error("Report had an error: ", err);
    } else {
        console.log("Filename: ", name);
    }
});
}

var rpt = constructReport();

I hope you can help me with this. Thank you!

How to send pdf as a response to express request?

First off, thank you for the module!

I'm using fluent to creat a report with data tables. I am trying to replace my pdfkit module and I was able to achieve sending a file as response with pdfkit, but not with fluentreports. I can't write the pdf to a file for my project and I know there is something that I am missing. The Report object does take a 'string' or 'object' parameter, but it isn't clear to me how to pass some buffer in and retrieve it once rendered to pass to my response.

Here is what I did for pdfkit:
server.js

server.post('/api/pdf', function createPdf(req, res) {
    var theStatement = req.body.statement;
    pdf.createPdf( JSON.parse(theStatement), finishPdf );
    function finishPdf(err, thePdf) {
        if(err){
            log.error('err:%j',err);
            res.send(err);
        }
        else {
            res.type('pdf');
            res.send(thePdf);
        }
    }
});

pdf module

var _createPdf = function (theStatement, cb) {
        var doc = new PDFDocument();

        var text = 'Statement..';
        var margin = 10;
        var top = 0;
        var options = {
            Title : 'statement.pdf',
            Author : 'XXXXX'
        };

        doc.addPage();

        doc.output(function(theDocument){
            cb(null, theDocument);
        });
    };

Here is what I tried for fluentreports:
*same server as above
pdf module:

    var _createPdf = function (theStatement, cb) {
            var buff = new Buffer(1000);
        var r = new report(buff).data({});
        r.margins(20)
        .pageheader(function(x){x.print('simple page header');});
        r.printStructure();
        r.render();
        cb( null, buff.toString() );
    };

How do you supply a buffer?

Thanks again,

Troy

fluentreports hangs when adding something with width <= 2.0 to rpt.band

While this runs fine:

var Report = require('fluentreports').Report;
var rpt = new Report();
var options = {};
var header = function (rpt, data) {
    rpt.band([
        {data: 'Test', width: 82}
    ]);
};

rpt.header(header);
rpt.data(options);
rpt.render();

adding something with a width <= 2.0 will make it hang permanently:

var Report = require('fluentreports').Report;
var rpt = new Report();
var options = {};
var header = function (rpt, data) {
    rpt.band([
        {data: 'Test', width: 1},
        {data: 'Test', width: 82}
    ]);
};

rpt.header(header);
rpt.data(options);
rpt.render();

(Can easily be verified on https://npm.runkit.com/fluentreports )

I don't know since when this happens but it worked fine ~2 years ago when I first tried it with the then current version.

Force New Page

Hi,
What a awesome repo this is, imho designing reports are much better/faster than pdfkit. Is there a way to issue a page break?
TIA
John

Concept of label or container box

Hi and cool project here. This is an ambitious project and would love to see this moving.

FYI, we have developed some business programs and uses 3rd party commercial reporting modules.

For the reports, I don't see any way to define labels or boxes and then bind data into them. This will be helpful for (when creating report designer) reports to adjust text-wrapping / auto-grow, etc.

finalSummary disappears

finalSummary disappears when all items of detail have been printed at end of a sheet as seem in these pdf.
1.pdf
2.pdf
Please some adviced in order solve this, it shoulnd.t be a issue.

Documentation for box() is incorrect

Documentation for box indicates:

box ( startX, startY, endX, endY, options)

This led me to assume that the endX and endY options were a fixed point on the page. They appear to actually be width & height values.

It'd more correctly be:

box ( startX, startY, boxWidth, boxHeight, options)

`pageNumber` does not display on the final page.

I'm using pageFooter.

report.pageFooter(footerGenerator);

var footerGenerator = function (reportObject) {
  reportObject.fontSize(7);
  reportObject.pageNumber({footer: true, align: 'right', text: 'Page {0}'});
  reportObject.fontNormal();
};

The page number shows on every page except the final page.

Error: Report is not a function

Hi,

I am trying to use fluentreports in my node js project, where I have the following code(which I copied from the readme section) in a file which is used by route.

var Report = require('fluentreports');
module.exports.generateReport = function(next){
    var data = [{name: 'Elijah', age: 18}, {name: 'Abraham', age: 22}, {name: 'Gavin', age: 28}];
    var rpt = new Report("Report.pdf")        
            .pageHeader( ["Employee Ages"] )      // Add a simple (optional) page Header...        
            .data( data )                         // Add some Data (This is required)
            .detail( [['name', 200],['age', 50]]) // Layout the report in a Grid of 200px & 50px
            .render();
}

But when I call the above method, I am getting an error which says
{"message":"Report is not a function","error":{}}

Is this an issue? Or if am using it wrong?

Thanks.

Sanitze

as sanitize html (&nbsp) and more...

Encountering page footer issue if margins are set on four sides

Hi Nathan,

There is a page footer issue if I set the margins on four sides of the page like this:

var report = new Report("test.pdf", {paper: "letter"});
...
report.margins({left: 50, bottom: 5, right: 0, top: 0});
...

The footer size is not being considered when rendering resulting to page footer being printed on the next page.

However, when I set the margins like this:

var report = new Report("test.pdf", {paper: "letter"});
...
report.margins(50);
...

I am not encountering any issue. I hope you can look into this. Thank you!

Page height

Hi, I'm getting this Feedback

REPORTAPI: Your Report's Page Footer exceeds the page bottom margin ( 821.89 ) by 10.110000000000014 -- Please subtract 10.110000000000014 pixels from (probably) where you set Y to 735.89

var rpt = new Report(rp)
.margins({ left:30, top: 30, right: 30, bottom: 30 })
.paper("A4")
.autoPrint(false)
.pageHeader(header)
.data( nt.lotes )
.detail( lotesDetail )
.sum( "valorVenda" )
.pageFooter(summary)
.fontSize(9);

what am I doing wrong?

another question, with align = "justify"

thanks

Column size 5 chars

Any width < 10 for .band related operation fails . I looked in fluentreports.js modified the items I thought would allow for a smaller char cell but no luck.

Thanks

Question about how page breaks work with groups

I haven't had a lot of time yet to play around with fluentreports, but before I spend a lot of time trying to migrate from other solutions, can you explain how the engine handles page breaks for groups of data? Are there options to have the engine dynamically insert page breaks to keep groups from spanning pages? In other words, if I have 9 rendered groups in a report and it can only fit 2 on the first page, 3 on the second, 4 on the third can it automatically do this? Having the ability to prevent a group from spanning pages (assuming a rendered group will fit on a single page) is a necessary feature for my needs.

Also, what is the status of the pre-rendering system you mentioned that would give the ability to have context for things like total number of pages?

Rotated text

I'd like to request the ability to write text rotated a certain number of degrees. I'm not particular about how we do it, perhaps something like print('Some Text', {rotate:90}). It seems like it would be easiest if this would simply render the text onto the report and leave the Y and X the same as when we started. KellPro is interested in sponsoring this, so shoot me an e-mail with a quote if you'd like to implement this for us.

Render data that contains boolean value

Let data be

var data = [ { hasProp1: true, hasProp2: false, hasProp3: true }];

var rpt = new fluentreports.Report('buffer');

rpt.data(data)
.margins(20)
.detail("{{hasProp1}} - {{hasProp2}} - {{hasProp3}}");

Will genererate

true - {{hasProp2}} - true


In order to test if a data value exists you might have to use
if (typeof obj.prop !== 'undefined) ...

and not
if (obj.prop) ...

Error: target.hasOwnProperty is not a function

****** Error on query TypeError: target.hasOwnProperty is not a function
at ReportGroup._expandRowTree (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:5276:28)
at continueRendering (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:5057:22)
at groupChangeCallback (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:5103:21)
at ReportGroup._renderIt (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:5131:21)
at groupContinue (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:3811:33)
at renderData (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:3836:17)
at ReportDataSet._renderIt (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:3967:17)
at renderGroup (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:4105:41)
at ReportSection._renderIt (D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:4113:13)
at D:\EtiquetesP\node_modules\fluentreports\lib\fluentReports.js:1227:33 +67ms

The code:

I get the data for the report from a form.

router.post('/', function(req, res, next) {
	debug('****** Form Data: \n %O', req.body);
	
	var qry = new dbConfig.PW.Request();
	
	debug('****** Query Insert Eti: ',qrys.qry_insert_eti(req.body));
	qry.query(qrys.qry_insert_eti(req.body))
	.then(function(next){

		var headerFunction = function(Report) {
	        Report.print("Label", {fontSize: 22, bold: true, underline:true, align: "center"});
	        Report.newLine(2);
	    };

	    var footerFunction = function(Report) {
	        Report.line(Report.currentX(), Report.maxY()-18, Report.maxX(), Report.maxY()-18);
	        Report.pageNumber({text: "Page {0} of {1}", footer: true, align: "right"});
	        Report.print("Printed: "+(new Date().toLocaleDateString()), {y: Report.maxY()-14, align: "left"});
	    };

	    var reportdetail = function (Report,data) {
		    Report.band( [
		        {data: data.foofield1, width: 50, align: 3, zborder:{left:1, right: 1, top: 0, bottom: 1}}
		    ], {border:1, width: 0, wrap: 1} );
		};

	    var rpt = new Report("EtiquetaP2.pdf")
	        .margins(20)                            // Change the Margins to 20 pixels
	        .pageHeader(headerFunction)             // Add a header
	        .data(req.body)                           // Add our Data
	        .detail(reportdetail) 					// Put how we want to print out the data line.
	        .pageFooter(footerFunction)             // Add a footer          
	        .render();

		res.render('newEti', { title: 'Nova Etiqueta' });
	})
	.catch(function (err) { 
		debug('****** Error on query', err);
		req.body=''; 
		res.render('newEti', { title: 'Nova Etiqueta' });
	});
});

ReportRenderer#fontBold, #fontItalic, #fontNormal dont work with external font

examples/demo2:

var resultReport = new Report(rptName, {font: "c:\\windows\\fonts\\times.ttf"})
      .data(mydata)
      .totalFormatter(totalFormatter);
resultReport.fontBold();

//REPORTAPI: Error running header in report [TypeError: Cannot read property 'FamilyName' of undefined] TypeError: Cannot read property 'FamilyName' of undefined

this._PDF._font.font.attributes is absent in ttf font

Now I use this code in fluentReports.js:

fontBold: function () {
    var font = this._fonts[this._PDF._font.filename || (this._PDF._font.font.attributes &&  this._PDF._font.font.attributes.FamilyName) || this._PDF._font.name];
    //...

In the application i use Report#registerFont

How To add continue after adding sub report?

Hi I am creating a report using your package, and thanks for creating this module.

I am trying to generate report, with data like:

data = [
  today: "Today",
  tomorrow: "Tomorrow",
  meta: [
    { value: "One" },
    { value: "Two" },
  ]
]

So I have created report like this:

rpt = new Report(reportName)
      .data(data)
      .pageHeader(["Daily Report"])
      .header(header)

subRpt = new Report(rpt)
      .data(data[0].meta)
      .detail(find_outs)

So the problem is I am able to continue the main report after the sub report. I am not sure which function to use to write something after the sub report.

Also, when I add header on sub report, it repeats for each row. Is there a way it can have only one header or section before the sub report.

Is there any documentation for this module other then five examples?

Thanks,

Sanjay

Need to swap interface for write/stream for new version of pdfkit.

Current release is still using the old depreciated pdfkit write/stream interface. So "buffer" function is now broken, and write method throws a warning to the console.
Need to switch code to new stream interface so that it can run on both client and server and so that buffer method is working again..

Update pdfkit package to 0.8.0.

Due to the problem that some CJK characters are not visible with current pdfkit 0.7.2, I would like to be pdfkit updated to the latest version 0.8.0 in package.json of fluentreports package.
"dependencies": {
"pdfkit": "^0.7.2"
},
-->
"dependencies": {
"pdfkit": "^0.8.0"
},

How to browserify fluentReports?

Hello,

I tried to use browserify to bundle up fluentreports in a js that can run in the browser, however I ran into some problems. Here's what I did: I installed fluentreports, pdfkit, blob-stream into node.js, then in the fluentreports downloaded directory, I ran:

browserify lib/fluentReports.js -o fr-bundle.js

However, here's what I got:

SyntaxError: Line 92: Unexpected token ILLEGAL while parsing /Users/mar/Downloads/fluentreports-master/node_modules/pdfkit/js/font.js
at Stream.end (/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/index.js:71:21)
at _end (/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/through/index.js:65:9)
at Stream.stream.end (/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/through/index.js:74:5)
at Transform.onend (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:505:10)
at Transform.g (events.js:180:16)
at Transform.emit (events.js:117:20)
at /usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:942:16
at process._tickCallback (node.js:419:13)

I'm very new at node.js, and am not sure whether all node modules can work with browserify. Care to give a hand?

Thanks a lot in advance.
Best regards,
M.

Column Headers do not Wrap as Expected

var pageHeader = function(r) {
    r.fontSize(9);
    r.band([
      {data: 'Favorite Ice Cream', width: 70, align: 'left'}, 
      {data: 'Least Favorite Ice Cream', width: 70, align: 'right'} 
      ], {fontBold: true, wrap: true});
  }
  var detail = function(r, row) {
    r.fontsize(9);
    r.band([
      {data: row.favorite, width: 70, align: 'left'}, 
      {data: row.least, width: 70, align: 'right'}
    ]);
  }

  var report = new Report("myReport.pdf")
    .data([{favorite: 'Butter Pecan', least: 'Pistachio'}])
    .pageHeader(pageHeader)
    .detail(detail);

  Report.render(function(err, name) { console.log("The report was saved to", name); });

In the code in the example above, the least favorite ice cream header is left aligned because it is wrapping. I would like the wrapped text to be right aligned.

Setting the report font does not work

Tried setting it with .font off the report object, as well as in a band

x.band([{data: 'Sample Data'}], {x: 10, font: 'times'});

Neither method changed the font.

use userData

in the documentation (and also examples) you mention how to set userData
by
rpt.userdata({hi:4})

I noticed it is all lowercase 'userdata' and not camelCase 'userData'

I could not find an example where you were actually using this data in a report or a detail report.

I tried

report.userData.hi

report.userData().hi

...

I do have a use data where I would like to store some data in an object that is accessed later in generating links in the
.details(function(report,data){
var myUserData = report.userData; ??
})

I must be missing something...

QUESTION: Sub-Reports for account groups?

I'd like to add a sub-report after each group for a .groupBy() object. Is that possible?

var nameGroup = rpt.groupBy( "name" )
      .header( nameHeader )
      .footer( nameFooter );

nameGroup.addReport(subReportObject, data);

Based on the code, it feels like that type of thing should work, but I haven't been successful.

Data is not getting printed in the report

I'm trying to generate a very simple report. Data is coming from mysql db. But, data is not being printed in the generated pdf file. Though header and footer is being printed. Here is the code:

app.post('/adminreport', function(req,res){
  var reportDate = req.body.report_Date;
  
  console.log("Report Date : " + reportDate);
  
    connection.connect(function(err){
     if(err){
       console.log('Error connecting to Db');
       return;
     }
     console.log('Connection established');
   });
   
   connection.query('SELECT id, fName, lName, pickUpDate FROM reservations_db WHERE pickUpDate = ?', [reportDate], function(err, results, fields){
     if (!err) 
	 {
	  //res.sendStatus(200).json({status:"ok"});
	  
      console.log('The result is generated successfully!');
	  console.log(results);
	  //console.log(fields);
	  
	var headerFunction = function(Report) {
      Report.print("Report By Date", {fontSize: 22, bold: true, underline:true, align: "center"});
      Report.newLine(2);
    };

    var footerFunction = function(Report) {
        Report.line(Report.currentX(), Report.maxY()-18, Report.maxX(), Report.maxY()-18);
        Report.pageNumber({text: "Page {0} of {1}", footer: true, align: "right"});
        Report.print("Report printed: "+ reportDate, {y: Report.maxY()-14, align: "left"});
    };
	//var res = function(Report) { 
	//    Report.print(results);
	//};
	
	var rpt = new Report("report_js.pdf")
        .margins(20)                                 // Change the Margins to 20 pixels                                  // Add Data
        .pageHeader(headerFunction)                  // Add a header
        .data(results) 		                                // Add Data
        .pageFooter(footerFunction)                  // Add a footer
        .render();         
	  }
      
     else 
	 {
	 console.log('Error while performing persistence!'); 
	 } 
    });

This is the generated pdf file:
report_js.pdf

Possible bug when piping to write stream

Hi,

I think : this._parent = null is needed as per below maybe (in fluentReports.js)?. Else you get an error later: cannot call render on undefined.

function Report(parent, options) {
.......
} else if (typeof parent === "object" && typeof parent.write === "function" && typeof parent.end === "function") {
this._parent = null;
this._outputType = Report.renderType.pipe;
this._pipe = parent;
} else {

Export to Download PDF not save locally

I'm not finding this in the documentation. I want to serve this in a web application, not CLI. How do I get the Report Framework to "not" save the PDF locally to the server but send it to the browser in PDF to download for the person viewing the page?

Support Multi Language (Arabic)

Hello Folks,

Does it supports Arabic language ?! Once I write Arabic it shown stars chars.
And Is it possible to support RTL & LTR direction?!

Thanks :)

PDF/A Format

Hello,

can I create pdf/a format using this library??

Thanks.

Paging Issue

There is a corner case that can cause the paging system to fail and you will not get a footer on current page and/or a header on the next page.

I have a duplicatable case; so this hopefully will be fixed soon..

How to repeat table header on each page?

Hello,

by looking at the examples and at fluentReports' code, it is not clear to me whether it is possible to repeat a table header at the beginning of each page, in the case where a table spans multiple pages. Is there such an option?
My idea is to have the header repeat at each page, and also to insert a partial total which is reported at the beginning of each page (say I have a sum on an "amount" field, at the beginning of each page I'd like to know how much that sum is worth at that point).

Thanks,
M.

Create a pre-rendering system

This would allow us to do some nifty things like know how many total pages will be rendered; and auto-size grids, auto-wrap parts of grid cells.

However for extremely large reports we might need to make this optional as it would be a lot more memory intensive to pre-render data and hold the stats and/or report parts in memory to do the final rendering...

utf8 doesn't work?

I'm trying to play around with the demo reports, and change the titles, labels e.t.c to a utf8 string. It doesn't seem to work, and displays gibberish.

Is there any way to make it work?

Multiple format in a single cell

Apart from being able to apply different formats per cell, it would be great if we can also apply different formats inside a single cell.

As an example, I want to print "Steve Jobs_", but I want the asterisk (_) to be of different color and size.

(This can be done with pdfkit by using the "continued" key as parameter in .text() method)

Something like this:
doc.fillColor(‘black’)
.fontSize(10)
.text(“Steve Jobs”, {continued: true, width: 50})
.fontSize(18)
.fillColor(‘red’)
.text(“*”);

I hope this can be available soon! 👍 Thank you Nathan!

npm publish 0.0.2

Hey, I think this tool is great and we're making good use of it. I did note that your package.json is on 0.0.2 but npm seems not to be aware of anything after 0.0.1. Can you npm publish 0.0.2?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.