Is it possible to have a link from a TOC leading to a page in an appended report?



  • I'm appending reports in afterRender.

    My TOC works fine and the correct page numbers are identified even in the appended reports. But I cannot get the <a> link to work. Is it not possible to add hrefs to the TOC because the target pages are not yet appended in that stage of the rendering?



  • Answer: Yes, this should be possible.
    I just found pdfDest which seems to be the solution. Awsome!

    My problem is that my link links to itself. Both the anchor and the outline takes me to the actual row in the TOC instead of page 10. Page 10 is an appended page where I'm using {{{pdfDest}}}. I have even tried to hardcode the guid in pdfDest to ensure that the correct id is used, i.e. {{{pdfDest "hardcodedGuid"}}}.

    <a class='toc-item {{getTocLevelClass}}' id='{{guid}}' href='#{{guid}}' data-pdf-outline data-pdf-outline-title='{{title}}' data-pdf-outline-parent='{{parentSectionGuid}}'>

    What could be wrong?



  • Almost solved..

    Because I'm appending manually with jsreport.pdfUtils.append in afterRender, I also needed to call postprocess. The href now works, but the PDF outline still links to the TOC instead of page 10.

    I guess I can fix this somehow with postprocess as well, since I can add outlines to this call.

    Could anyone link me to an example on how to repair links in the outline after rendering and appending.



  • I apologize for the delay.
    There were some issues I had to fix, but with the next version of jsreport, you should be able to get the outlines cross-templates working in the script better.
    So this should work in the next update
    https://playground.jsreport.net/w/anon/7ysL9rwu

    It seems that at this moment you can also call postprocess twice as workaround

    res.content = await jsreport.pdfUtils.postprocess(res.content, {})
    
    res.content = await jsreport.pdfUtils.postprocess(res.content, {
            outlines: [{
                id: 'a1',
                title: 'link to another template'
            }]
    })
    

    If you want to test the current jsreport master, you can do git clone on https://github.com/jsreport/jsreport
    and yarn install && yarn start.

    We plan to release this week likely.


Log in to reply
 

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