Comments (3)
Awesome, thanks for the confirmation. I'll upload a new version of the code as that monkey patching should actually have been safeguarded to make sure people can't accidentally do what you did. Thanks for the report and it is now fixed in v1.4.1
from fluentreports.
Your issue is very weird. There are two possibilities I can think of (the second being more likely)...
And yes, you are correct this code just eliminates basically empty stuff, however I think w/o the _finalize code you might randomly get output glitches occasionally as null offsets would probably be translated to 0,0 offsets...
-
Can you tell me which version of PDFKit that you are using, maybe an upstream change in it broke something...
-
The main thing I can think of is that somehow the FluentReports.pdfkit.js overrides is being initialized multiple times and replacing _end & _finalize a second time in the PDFKit, which would for sure create a loop like you are seeing.
Could you be using two different copies of FluentReports or perhaps FR is npm installed in two (or more) directories, or perhaps their is some weird issue with bundling or node that is causing thefluentreports.pdfkit.js
to be loaded a second time. In any case, changing the code in all copies offluentreports/lib/fluentReports.pdfkit.js
to the following should eliminate that possibility...
if (!pdfkit.prototype._PKIEnd) {
pdfkit.prototype._PKIEnd = pdfkit.prototype.end;
pdfkit.prototype.end = function () {
if (this.isEmptyPage()) {
this.deletePage();
}
this._PKIEnd();
};
}
if (!pdfkit.prototype._PKIFinalize) {
pdfkit.prototype._PKIFinalize = pdfkit.prototype._finalize;
pdfkit.prototype._finalize = function (fn) {
let i = 0;
while (i < this._offsets.length) {
// Eliminate any NULL Offsets from deleted pages
if (this._offsets[i] === null) {
this._offsets.splice(i, 1);
continue;
}
i++;/
}
this._PKIFinalize(fn);
};
}
from fluentreports.
Thanks for the quick response. That code snippet worked!
It also prompted me to test a bit more to see if I could optimize how those routes are loading.
I found that using
const Report = require('fluentReports').Report;
at the top of my report generation files caused the overrides to be initialized in each file (then would later cause the stack overflow).
then replacing
const Report = require('fluentReports').Report;
with
import { Report } from 'fluentReports';
fixed the issue without your code changes.
FluentReports was up to date and using pdfkit .13 - for reference I also tried previous versions of fluentreports that used pdfkit .12 and .11 but had the same issue. Also pdfkit isn't installed anywhere else in our lock file so no conflicts there.
Either way that helped solve things, and eased my mind a bit 😄 thanks again!
from fluentreports.
Related Issues (20)
- [FRG] Add ability to set border style through GUI
- [FRG] Add a way to set exact position on page HOT 2
- [FRG] Remove requirement of “report group” column in data HOT 4
- [FRG] Fix X & Y coordinates changing from what they’re set to on save
- [FRG] Fix align: right going off the screen
- [FRG] Fix clearing font size field wiping out report HOT 2
- [FRG] Improve band line visual positioning
- [FRG] Update right-aligned element position after margin changes HOT 2
- [FRG] Expose a focus handler in the options object HOT 2
- [FRG] Fix async print function adding done() when it shouldn’t HOT 1
- newPage() doesn't cause header to be rendered on the new page HOT 2
- Feature Request: Add option to saveState() and restoreState() for font settings only HOT 1
- Fix band() adding extra margin when multiple cells wrap
- Use fluentreports with VUE HOT 1
- Buffer is not defined, Platform React JS HOT 2
- ES6 Support HOT 3
- v1.4.2 removes the ./generator directory from the NPM package HOT 1
- How to implement Typescript support? HOT 1
- ERROR[Cannot set property 'getEmptyPageStats' of undefined] when bundle by webpack(express, nodejs) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentreports.