pageNum and numPages
-
Hi,
I have a question regarding the page number and number of pages.
I have an array of data that im passing it to jsreport to draw it on the .hbs file.using {{#each this}} to loop through the array and display items on the template, i would like to know for each item in that array, how many pages it is using off the report, and i would like to display them; example:
lets say the array has 3 items, the first item takes 5 pages of the report, i would like to add on each page (1 / 5, 2 / 5, ...).
For the second item in that array, lets say it needs 7 pages, i want it to display (1/7, 2/7, ... )any guidance please?
-
hi! hmm sounds like you want some kind of grouping, and reset page counter based on the group, i think you can achieve something like that with some of the pdf-utils features and with custom logic for the counter.
my advice will be that you try to use pdf-utils, if you encounter any problem you can put a minimal example of your case here https://playground.jsreport.net , save it and share the link with us so we can know better how your case looks like.
-
Hi again,
I am using jsreport-core on top of an existing nodejs app, is there any configuration example available to include the {{pdfCreatePagesGroup }} ?
Thanks in advance.----- EDIT -----
I have the following configurationreturn jsreport.render({ template: { content: fs.readFileSync(path.join(__dirname, 'policyPrint.hbs')).toString(), engine: 'handlebars', shortid: 'header', recipe: 'phantom-pdf', helpers: helpers, ****pdfOperations: [{ type: 'merge', renderForEveryPage: true, templateShortid: 'header' }]**** },
and in the helpers.js that im referencing, i have the following method:
function mySum() { return this.$pdf.pages[this.$pdf.pageIndex].items.reduce((a,c) => a + c) }
and in the policyPrint.hbs i have
{{{pdfCreatePagesGroup name="Jan" age=33}}} {{mySum}}
but my problem here is, whenever the helper mySum gets called, an error occurs saying: cannot read property pages of undefined, whereas the value of this.$pdf is undefined in my helpers.js
Any guidance please?
-
The helper
mySum
should be called in the "header" template. Not in the parent template. Don't you have this wrong?
Handlebars floats with context, so thethis
in helpers doesn't necessary needs to refer to the root one. Make sure you call this helper from the top context. Not from a loop or something like that.
You can try to enable logs and see what is printed out. For example with setting env var "DEBUG=jsreport".
If you are lost in the end. It would help us if you create a minimal repository and we can look there what is wrong. But it really needs to be minimal working repository just with jsreport code that fails. Thanks for that in that case.
-
https://github.com/anthony-elhaddad/jsreport-jsreport-pdf-util
Please check this repo, and navigate to controllers/underwriting/policyPrint/policyPrint.controller.jsthis is where im stuck.
'{{$pdf.pageNumber}}/{{$pdf.pages.length}}', is not returning any value.Your help is much appreciated.
navigate to http://localhost:3000/test/policy to test the pdf
-
hi @anthony-elhaddad your repository was helpful for us to identify the issue of your problem.
the problem was that your input data is an array, and since pdf-utils adds some meta data (the $pdf object) into data of templates, those extra data additions get lost when that data gets serialized for inter-process communication between the tasks workers of jsreport and the server itself (because you activated http-server strategy for tasks). one easy way to verify that the problem was caused by your data being an array + http-server strategy is changing tasks strategy to
in-process
, if you do that change your example will work normally. for your case the best will be to change this to an object, like:{ "data": [ { "LOB_DESC": "FIRE", "PRODUCT_DESC": "Home Gold", "POLICY_NO": "FI-021331", "END_NO": null, "SUM_INSURED": 103000, "SUM_INSURED_CUR_CODE": "USD ", "SUM_INSURED_CUR_DESC": "US Dollars", "DATE_EFFECTIVE": "2017-01-27T00:00:00", "DATE_EXPIRY": "2018-01-27T00:00:00", "TOTAL_PREMIUM": 171, "PREMIUM_CUR_CODE": "USD ", "PREMIUM_CUR_DESC": "US Dollars", "POLICY_END_AT_NOON": "(at noon)", "PRINT_NAME": "Insured - 1111111", "TITLE_DESC": "MR.", "PRINT_ADDRESS": "Test Location 1", "Covers": [ { "POLICY_ID": 1, "COVER_DESC": "Construction", "SUM_INSURED": 50000 }, { "POLICY_ID": 2, "COVER_DESC": "Contents", "SUM_INSURED": 40000 }, { "POLICY_ID": 3, "COVER_DESC": "Removal of debris and demolition", "SUM_INSURED": 10000 }, { "POLICY_ID": 4, "COVER_DESC": "Loss of use", "SUM_INSURED": 3000 }, { "POLICY_ID": 5, "COVER_DESC": "Thunderbolt and/or lightning", "SUM_INSURED": 90000 }, { "POLICY_ID": 6, "COVER_DESC": "Aircraft damage", "SUM_INSURED": 90000 }, { "POLICY_ID": 7, "COVER_DESC": "Impact damage", "SUM_INSURED": 90000 }, { "POLICY_ID": 8, "COVER_DESC": "Explosion", "SUM_INSURED": 90000 }, { "POLICY_ID": 9, "COVER_DESC": "Water damage", "SUM_INSURED": 90000 }, { "POLICY_ID": 10, "COVER_DESC": "Earthquake", "SUM_INSURED": 90000 }, { "POLICY_ID": 11, "COVER_DESC": "Storm, Tempest and Flood", "SUM_INSURED": 90000 }, { "POLICY_ID": 12, "COVER_DESC": "Burglary - Contents", "SUM_INSURED": 20000 } ], "Clauses": [ { "POLICY_ID": 1, "CLAUSE_DESC": "Renewal by endorsement - Assuroof", "CLAUSE_CONTENT": "<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Courier New';font-size: 16px;\"><b><u>RENOUVELLEMENT</u></b></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><u>Description du risque </u></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">: Appartement (Superficie: 160 mètres carrés) situé au </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> rez-de-chaussée de l'immeuble Georgette Amine Ishak,</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> élevé sur le bien-fonds No. 202 ,sis à côté de" Hitti</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> for glass", rue Al Ain, Green area, Adonis, Keserwan,</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> Liban.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">A la demande du Souscripteur et par la présente Police,la Compagnie renouvelle</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">l'effet de la Police échue No. FI-017981 citée en marge, aux mêmes</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">termes, conditions et sommes assurées comme indiquées ci-après, pour une</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">nouvelle période d'une année allant du 27.01.2017 (à midi) au </span><span style=\"font-family: 'Courier New';font-size: 13.34px;color: #000000;\">27.01.2018</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">(à midi).</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">Le tout sujet aux sous-limites de la Police.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">Par conséquent, le Souscripteur s'engage à payer, contre quittance séparée, la</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">prime mentionnée.</span><span style=\"font-family: 'Times New Roman';font-size: 16px;\"> </span></p>" }, { "POLICY_ID": 2, "CLAUSE_DESC": "SANCTION LIMITATION AND EXCLUSION CLAUSE", "CLAUSE_CONTENT": "<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">SANCTION LIMITATION AND EXCLUSION CLAUSE</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">No (re)insurer shall be deemed to provide cover and no (re)insurer shall be</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">liable to pay any claim or provide any benefit hereunder to the extent that</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">the provision of such cover, payment of such claim or provision of such</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">benefit would expose that (re)insurer to any sanction, prohibition or</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">restriction under United Nations resolutions or the trade or economic</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">sanctions, laws or regulations of the European Union, United Kingdom or United</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">States of America.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">JC2010/014 </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">11 August 2010 </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span></p><p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Verdana';font-size: 16px;\"> </span></p>" }, { "POLICY_ID": 3, "CLAUSE_DESC": "FIN DE POLICE", "CLAUSE_CONTENT": "<p style=\"margin-top: 6.66px;margin-bottom: 6.66px;line-height: 1.15;\"><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> </span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><b> LE SOUSCRIPTEUR POUR LA COMPAGNIE</b></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><b> ASSUREX S.A.L. </b></span></p>" } ] }, { "LOB_DESC": "FIRE", "PRODUCT_DESC": "Fire - Housing Loan Broker", "POLICY_NO": "FI-021393", "END_NO": null, "SUM_INSURED": 1339500, "SUM_INSURED_CUR_CODE": "USD ", "SUM_INSURED_CUR_DESC": "US Dollars", "DATE_EFFECTIVE": "2017-01-15T00:00:00", "DATE_EXPIRY": "2018-01-15T00:00:00", "TOTAL_PREMIUM": 1000, "PREMIUM_CUR_CODE": "USD ", "PREMIUM_CUR_DESC": "US Dollars", "POLICY_END_AT_NOON": "(at noon)", "PRINT_NAME": "Insured - 2222222", "TITLE_DESC": "MR.", "PRINT_ADDRESS": "Test Location 2", "Covers": [ { "POLICY_ID": 1, "COVER_DESC": "Construction", "SUM_INSURED": 893000 }, { "POLICY_ID": 2, "COVER_DESC": "Neighbours' recourse", "SUM_INSURED": 446500 }, { "POLICY_ID": 3, "COVER_DESC": "Thunderbolt and/or lightning", "SUM_INSURED": 893000 }, { "POLICY_ID": 4, "COVER_DESC": "Aircraft damage", "SUM_INSURED": 893000 }, { "POLICY_ID": 5, "COVER_DESC": "Impact damage", "SUM_INSURED": 893000 }, { "POLICY_ID": 6, "COVER_DESC": "Explosion", "SUM_INSURED": 893000 }, { "POLICY_ID": 7, "COVER_DESC": "Earthquake", "SUM_INSURED": 893000 }, { "POLICY_ID": 8, "COVER_DESC": "Storm, Tempest and Flood", "SUM_INSURED": 893000 } ], "Clauses": [ { "POLICY_ID": 1, "CLAUSE_DESC": "CREDEX - Renewal Endt ", "CLAUSE_CONTENT": "<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: center;\"><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><b><u>RENEWAL</u></b></span><span style=\"font-family: 'Courier New';font-size: 12px;\"></span></p><p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><u>Description of risk</u></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">: Apartment(Part 10 - Block B ;Surface: 235 square meters),</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> situated on the Seventh floor of Building # 4345 ,erected</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"> </span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> on Plot No.4345, Achrafieh Quarter Sioufi Street, Beirut,</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"> </span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> Lebanon.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">At the Insured's request and by the present Policy, the Company agrees to</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">renew the expired Policy No. FI-017932 at same terms , conditions and</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">sums insured, for one further year as from 15.01.2017 (at noon) to </span><span style=\"font-family: 'Courier New';font-size: 13.34px;color: #000000;\">15.01.2018</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">(at noon).</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><u>Designation of risk</u></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> </span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><u>Sums insured</u></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">- Construction USD 893,000.-</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">- Neighbours' recourse USD 446,500.-</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">Subject to Policy sub-limits if any.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">- The above construction sum insured includes the Insured's share in the</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> building common parts (Parts 1 & 3B).</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">Consequently, the Insured agrees to settle to the Company the premium here</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">above indicated.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">- See attached Annexes: "Beneficiary Clause" and "Sanction Limitation and</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> Exclusion Clause".</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span></p>" }, { "POLICY_ID": 2, "CLAUSE_DESC": "Beneficiary Clause", "CLAUSE_CONTENT": "<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Courier New';font-size: 13.34px;\">BENEFICIARY CLAUSE </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">At the Insured's request, the Company irrevocably transfers the </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">benefits granted by the present Policy to:</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">Creditbank S.A.L. </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">and undertakes not to cancel it without giving the above-mentioned</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">beneficiary prior notice as provided for by the "CODE DES OBLIGATIONS </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">ET DES CONTRATS " nor to alter its conditions unless so requested, in</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">writing, by said beneficiary.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">Consequently,in case of occurrence of a covered loss,the indemnification </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">shall be directly settled to the aforesaid Bank in its capacity as</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">beneficiary but only to the limits of the portion pertaining to the evidence</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">of debit due by the Insured.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> </span></p><p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Courier New';font-size: 13.34px;\"> </span></p>" }, { "POLICY_ID": 3, "CLAUSE_DESC": "SANCTION LIMITATION AND EXCLUSION CLAUSE", "CLAUSE_CONTENT": "<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">SANCTION LIMITATION AND EXCLUSION CLAUSE</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">No (re)insurer shall be deemed to provide cover and no (re)insurer shall be</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">liable to pay any claim or provide any benefit hereunder to the extent that</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">the provision of such cover, payment of such claim or provision of such</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">benefit would expose that (re)insurer to any sanction, prohibition or</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">restriction under United Nations resolutions or the trade or economic</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">sanctions, laws or regulations of the European Union, United Kingdom or United</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">States of America.</span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">JC2010/014 </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\">11 August 2010 </span><span style=\"font-family: 'Courier New';font-size: 12px;\"><br /></span></p><p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1;text-align: left;\"><span style=\"font-family: 'Verdana';font-size: 16px;\"> </span></p>" }, { "POLICY_ID": 4, "CLAUSE_DESC": "End of Policy", "CLAUSE_CONTENT": "<p style=\"margin-top: 0px;margin-bottom: 12px;line-height: 1.15;\"><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><b>THE INSURED FOR THE COMPANY</b></span><span style=\"font-family: 'Verdana';font-size: 16px;\"><br /></span><span style=\"font-family: 'Courier New';font-size: 13.34px;\"><b> ASSUREX S.A.L.</b></span></p>" } ] } ] }
and finally change this to:
{{#each data}}
we find that this behaviour (data as array not working consistently in http-server, dedicated-process strategies) is confusing so in jsreport v2 we are going to enforce that data should be always an object. thanks
-
Hi @bjrmatos,
My git repo has been updated with your solution.
I have managed to follow your guidance and got an output.
I am interested in knowing how many pages each object in the data array(which has for now 2 objects) took.For example: first object in the array took 3 pages, i would like to have it displayed on the report, "1/3 " on the first page, "2/3" on the second and "3/3" on the third.
For the second object, lets assume it took 2 pages, it should display "1/2", and the second page "2/2".What im looking for is: pageNumber and pageIndex of each group, in other words group.pageNumber, group.pageIndex, group.totalPages ... Something like that.
How can I reach this functionality?
Thanks in advance.----- EDIT -----
Please check my repo, and generate a report for latest update
Thanks in advance.----- EDIT 2 -----
Instead of retrieving data from mock file, i am getting them from an api call usingrequest(url, { json: true }, (error, response, body) => { // manipulate the data // to have a proper format // similar to the mock // call jsreport.render .... (similar to the repo) });
the data retrieved and manipulated is around 2000 records.
i am getting the following error:Error: Navigation Timeout Exceeded: 30000ms exceeded at Promise.then (C:\Users\jsreport-git\node_modules\puppeteer\lib\NavigatorWatcher.js:71:21) at <anonymous> GET /test/policy - - ms - -
I tried changing the
"strategy": "in-process"
to
"strategy": "http-server"
but nothing works.