Toc page numbers are rendering in all pages issue
-
Hello @jan_blaha @bjrmatos
I am creating TOC page in one of my project for getting page number of other pages. I have referred playground demo "toc" and "stock report". but I am facing one issue in my version of jsreport that:
page numbers are rendering for all pages not only toc page. Though I have created one demo playground , but not able to reproduce same issue in playground.
can it because of different version of JSReport? I'm using 2.11.0 jsreport version. because I can see in my version when I am using "merge whole document" with pdf utils it's not rendering page numbers and when I'm using "Render for every page" they are rendering for all the pages.
but in https://playground.jsreport.net/ "render for every page" option is deprecated and with "merge whole document" options page numbers are rendering correct.If you can help me with this that will be great.
Thanks!
-
Could you please export your example and upload it here or somewhere else? I would check how it works with 2.11.0.
-
I have sent my folder with 2.11.0 in your email [JAN.BLAHA@JSREPORT.NET].
Please have a look at it once you've a moment. Please let me know if you're not able to find my mail.Thanks!
-
This is how your pdf utils config should look like
-
@jan_blaha I have one another scenario as well. where I need to add another toc page in same report. but not able to fetch the page numbers on the page where I want if I use two toc pages in a single report. Please have a look at this example. [https://playground.jsreport.net/w/Heplinesss_17/92zo6EfJ] page numbers are not displaying in this page
Can you please help me with that?
Thank for above solution that works fine for me.
-
A similar thing is solved in the stock showcase. What you can do is use
pdfAddPageItem
to mark the place where the second TOC starts. Then find this mark in the second TOC and add blank pages before.{{{pdfAddPageItem anotherTocStart=1}}} {{#each (getPagesBeforeTOC)}} <div style="visibility: hidden;"> </div> <div style="page-break-before: always;"></div> {{/each}}
function getPagesBeforeTOC (opts) { if (opts.data.root.$pdf) { const res = [] for (let page of opts.data.root.$pdf.pages) { if (page.items.find(i => i.anotherTocStart)) { return res } res.push(page) } throw new Error('anotherTocStart not found') } return [] }
The second TOC page numbers will be merged to the right page then. See the upadted playground here
https://playground.jsreport.net/w/anon/EG4FRTXJ
-
Thanks! @jan_blaha got it. but can we jump on the page number while clicking on the page numbers which we have get? for example If I click on "6" it should jump on page 6. I already linked that but not working.
-
The problem is that the link needs to be known when you render the main page the first time and we don't know the page number at that time. But there are tricks...
You can make the element representing the link bigger with css and then merge inside the page number.
Your demo
https://playground.jsreport.net/w/anon/kw2PQVKsOfficial toc demo
https://playground.jsreport.net/w/anon/IrIdohZ7You can use
pdfDest
helper that can add links between different pdfs rendered with pdf utils.The documentation
https://jsreport.net/learn/pdf-utils#pdfdestTOC example using
pdfDest
https://playground.jsreport.net/w/anon/CP7r9q~t
-
Thanks @jan_blaha Working fine.