Can't display a page number of an appended / prepended template in Table of Contents



  • Table of contents worked fine until I needed to include a page in landscape mode, which is implemented via append operation in pdf utils.

    I've created a simple test case here
    https://playground.jsreport.net/w/anon/eyb9f1ZJ

    I've also tried to find out a way to define and use a global variable instead of using pdfAddPageItem function but that didn't work.

    Is it a known limitation or bug? Merged templates aren't affected.



  • Unfortunately several problems here...

    1. You don't have a proper order of pdf utils operations. You need to do the append first and then merge the TOC, otherwise, the TOC cannot see the items of the appended template.
    2. In jsreport 2.8.0 we started to do some cleaning in the pdf that affects this case and even if you have proper order, it won't find the item in the appended content. In case you use jsreport >= 2.8.0, you need to update pdf utils package npm i jsreport-pdf-utils@1.10.1. Note this will be part of the jsreport 2.11 which should be released tomorrow.
    3. There is a known limitation that clickable links, which you have in the TOC don't work (appears but aren't clickable) when you target another appended pdf. You can track it here https://github.com/jsreport/jsreport/issues/771


  • @jan_blaha

    1. I've tried different orders and must have left it in the incorrect one. But yes, good point!
    2. I'll try the latest jsreport and jsreport-pdf-utils. Are you saying that this should potentially fix this issue I'm experiencing?
    3. Oh, I see. That would be the next issue then but at this point, if I can get the page numbers in the TOC, that would be super good.


  • Still no page number in the TOC for the landscape page. I've got these in my project:
    "jsreport": "^2.10.0",
    "jsreport-pdf-utils": "^1.10.1",
    "jsreport-postgres-store": "^1.3.2",

    I've also double checked in the logs that it loaded 1.10.1:
    info: Using extension pdf-utils@local:/app/node_modules/jsreport-pdf-utils:1.10.1

    @root in TOC template:

    {
     "chapters": [
     {
     "id": "portrait",
     "title": "Portrait"
     },
     {
     "id": "landscape",
     "title": "Landscape"
     }
     ],
     "$pdf": {
     "pages": [
     {
     "group": null,
     "items": []
     },
     {
     "group": null,
     "items": [
     {
     "id": "portrait"
     }
     ]
     },
     {
     "group": null,
     "items": []
     }
     ]
     },
     "__appDirectory": "/app/",
     "__rootDirectory": "/app/",
     "__parentModuleDirectory": "/app/"
    }
    


  • Please use the quotes here
    {{{pdfAddPageItem id='landscape'}}}
    and change the order of the operations and you should see the numbers.



  • @jan_blaha Thanks! I remember trying it with both "landscape" and landscape and couldn't get it to work before and still can't in the playground https://playground.jsreport.net/w/thehappycoder/VVPDn7OL.

    Got it working in my local though!

    The next problem I've encountered was when I added a prepended cover page https://playground.jsreport.net/w/thehappycoder/XjgKfQNV The page numbers appeared on the cover page. As soon as I put prepend operation after TOC in pdf utils, it got fixed.

    Solving the last solvable issue at the moment of having landscape footer on a landscape page. Edit: looks like hit another roadblock https://playground.jsreport.net/w/thehappycoder/wbvBD8nj As a workaround, will need to show page number on the left side, so that it's not appearing in the middle of the page for landscape pages.


Log in to reply
 

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