incorrect header check



  • same here im trying to use the api call and i found how append pages from there which is weird i have to call nested pdfoperation template but it doesnt render the last page but at least it appends, my problem not is i need to merge the footer at the end to recieve current pages numbering but i can only merge before append if i try to merge after i recieve the same error, and merging before only merge 1st page footer, i want it to work the same way as in the jsreport studio pdf operation... please help!!!

    call example: "options": {
    "Content-Disposition": "Attachment; filename=report.pdf"
    },
    "template": {
    "name": "cover",
    "recipe": "chrome-pdf",
    "engine": "handlebars",
    "pdfOperations": [
    {
    "template": {
    "name": "table-of-contents",
    "recipe": "chrome-pdf",
    "engine": "handlebars",
    "pdfOperations": [
    {
    "template": {
    "name": "report-overview",
    "recipe": "chrome-pdf",
    "engine": "handlebars",
    "pdfOperations": [
    {
    "template": {
    "name": "filters",
    "recipe": "chrome-pdf",
    "engine": "handlebars"
    },
    "type": "append"
    },
    {
    "template": {
    "name": "footer",
    "recipe": "chrome-pdf",
    "engine": "handlebars"
    },
    "type": "merge"
    }
    ]
    },
    "type": "append"
    }
    ]
    },
    "type": "append"
    }
    ]
    },



  • You can find out how the template is stored using "Definition" button and then do the same in the API call.
    0_1688559825088_upload-31faa6c4-ecde-4ca0-80a6-f61df5773d2c



  • still same error with the header check, even after having a header



  • Please try to replicate the error for me.
    I need to know the following:
    jsreport version
    what template store you use mongo, fs, SQL..
    what you have stored in jsreport store
    what is body of your API call



    1. jsreport version is latest 3.13.0
    2. we dont use a store we pass a data json
    3. this is the api call also tried to use afterrender script but still same result:
      {
      "options": {
      "Content-Disposition": "Attachment; filename=report.pdf"
      },
      "template": {
      "name": "cover",
      "recipe": "chrome-pdf",
      "engine": "handlebars",
      "pdfOperations": [
      {
      "template": {
      "name": "table-of-contents",
      "recipe": "chrome-pdf",
      "engine": "handlebars",
      "pdfOperations": [
      {
      "template": {
      "name": "report-overview",
      "recipe": "chrome-pdf",
      "engine": "handlebars",
      "pdfOperations": [
      {
      "template": {
      "name": "filters",
      "recipe": "chrome-pdf",
      "engine": "handlebars"
      },
      "type": "append"
      }
      ]
      },
      "type": "append"
      }
      ]
      },
      "type": "append"
      }
      ]
      },
      "data": {...my data object}
      }


  • it seems like theres 2 seperate issues:

    1. last page is not rendered for some reason, and you always get blank page.
    2. merge operation doesn't work except when you run directly your template from the sudio with operations, my footer file the. merges good from studio but fails in api/script:

    <html>
    <head>
    <style>
    {{asset "styles.css" "utf8"}}
    {{asset "../common/styles.css" "utf8"}}
    </style>
    </head>
    <body>
    {{#each $pdf.pages}}
    {{#if 5}}
    <div style="page-break-before: always;"></div>
    {{/if}}
    <main class="main">
    {{!-- <header class="header">
    <div>fgdfhfg</div>
    </header> --}}
    <header class="header">
    Header
    </header>
    <footer class="footer">
    <div style="display:flex;justify-content: space-between;align-items:center;height:100%">
    <div>
    <div class="s10w500">Report generated for: {{@root.reportInfo.generatedBy}}</div>
    <div class="s10w500">{{dateFormatter @root.reportInfo.dateGenerated 'MMM D, YYYY'}} | Generated by Ⓒ</div>
    </div>
    <div class="s12w500">{{getPageNumber 5}} out of {{getTotalPages ../$pdf.pages}}</div>
    </div>
    </footer>
    </main>
    {{/each}}
    </body>
    </html>

    fyi: also tried to remove all these details inside the footer but it keeps failing



  • if i try to take the working 1 and use definition i get this (tryed to call api with this and failed script untill i remove the merge operation):
    {
    "name": "cover",
    "recipe": "chrome-pdf",
    "shortid": "IwukVzV",
    "folder": {
    "shortid": "0-qKPfv"
    },
    "_id": "g6wVDTSHHMQtNzYH",
    "engine": "handlebars",
    "data": {
    "shortid": "T7IElFhj9"
    },
    "chrome": {
    "printBackground": true,
    "displayHeaderFooter": false,
    "viewportWidth": null,
    "viewportHeight": null,
    "marginTop": "",
    "marginBottom": "2cm",
    "width": "595",
    "footerTemplate": "<div>yannnnnnnnnnnnfooter</div>"
    },
    "creationDate": "2023-07-03T13:42:16.960Z",
    "modificationDate": "2023-07-06T09:39:21.308Z",
    "scripts": [
    {
    "shortid": "Fq58TQxq5"
    }
    ],
    "pdfPassword": {
    "password": ""
    },
    "pdfOperations": [
    {
    "type": "append",
    "mergeWholeDocument": true,
    "templateShortid": "c5Oftl3"
    },
    {
    "type": "merge",
    "mergeWholeDocument": true,
    "templateShortid": "PJyOKkL"
    }
    ]
    }



  • full error:
    (because) error while executing pdf-utils operations
    (because) incorrect header check
    Error: incorrect header check
    at Zlib.zlibOnError [as onerror] (node:zlib:189:17)
    at Zlib.callbackTrampoline (node:internal/async_hooks:130:17)
    at processChunkSync (node:zlib:457:12)
    at zlibBufferSync (node:zlib:178:12)
    at Object.syncBufferWrapper [as unzipSync] (node:zlib:792:14)
    at mergePage (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/pdfjs/lib/mixins/merge.js:113:31)
    at merge (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/pdfjs/lib/mixins/merge.js:162:22)
    at /Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/pdfjs/lib/mixins/merge.js:7:64
    at Document.asBuffer (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/pdfjs/lib/document.js:66:13)
    wrapped by:
    Error: Error while executing pdf-utils operations
    (because) incorrect header check
    at module.exports (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/jsreport-core/lib/shared/createError.js:10:13)
    at WorkerReporter.createError (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/jsreport-core/lib/shared/reporter.js:49:12)
    at AsyncFunction.<anonymous> (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/jsreport-pdf-utils/lib/worker.js:196:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ListenerCollection.fire (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/jsreport-core/lib/shared/listenerCollection.js:157:21)
    at async afterRender (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:103:5)
    at async WorkerReporter._render (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:148:7)
    at async /Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:179:19
    at async Domain.<anonymous> (/Users/yanfaingold/Work/osint-js-report/node_modules/@jsreport/advanced-workers/lib/workerHandler.js:141:19) rootId=n9198612644wpv1, id=n9198612644wpv1



  • This post is deleted!


  • jsreport version is latest 3.13.0
    we dont use a store we pass a data json
    this is the api call also tried to use afterrender script but still same result:

    You mention you don't use store, yet your API payload includes references to entities table-of-contents, jreport-overview which are likely stored in the store. I apologize but your problem description is confusing to me. Would it be possible for you to create a minimal github repo, with your jsreport app which I can start and send there the payload so I can replicate the error? I would happily check that. Thank you

    The mentioned error says that you are merging something that is not a valid pdf. It is hard for me to tell what the problem is from the so far provided description.



  • oj everything works its my bad.. apperently i had a password on each page mistakly because i played before and then i cloned the pages which kept the password, after i removed it from all pages everything works great, i guess theres some kind of bug calling api with password but i dont need it.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.