Header did not be applied to the landscape pages appended by pdfOperation



  • Hi,

    I am doing a pdf with mixed orientation pages, and also header and footer with page number. I am struggling how to work it out.

    Please check the playground link here. The entry page is a portrait one with the following page operations with the right order:

    • appended portrait one page
    • appended landscape one page, inside there is a merged pdfOperation which is a landscape header (with renderToFront set to true)
    • merged one, which is header (for portrait)
    • merged one, which is footer (for portrait)

    In the generated pdf, the observations are:

    • in page 2, there is no header, and the footer is not as wide as the landscape page width

    If I set header and footer before appended landscape pages in pdfOperation, it will end up with wrong page number, meaning the page number is scoped like separated pdfs composed together with its own page numbering.

    Anyone can help? thanks.

    Regards,
    Ron



  • This post is deleted!


  • in page 2, there is no header, and the footer is not as wide as the landscape page width

    Yes, it is limitation that both merged pdf pages should have the same size.
    I submitted issue to github to analyze how we can overcome it.
    https://github.com/jsreport/jsreport-pdf-utils/issues/11

    Unfortunately I don't see a quick fix or workaround to this at this moment.

    If I set header and footer before appended landscape pages in pdfOperation, it will end up with wrong page number, meaning the page number is scoped like separated pdfs composed together with its own page numbering.

    That is expected because of the way how it works.
    We keep one final pdf in memory.
    The pdf operations runs in sequence.
    After every operation we parse the current pdf from memory and provide its information in $pdf data property to the another operatoin.

    This means if you set the merge before the append, the merged header has no clue about the appended pages.



  • I am thinking one solution to walk around like below:

    • Set header and footer after appended landscape pages in pdfOperation;
    • For the appended landscape, set up a merged pdfOperation with a landscape header, and set it to be merge to front;

    Theoretically, the landscape header should sit in the very front and show up, but it is not happening.

    Is this the way to solve the issue?



  • Hm yes, that is good idea. Not sure why it doesn't work after some hours of debugging. The pdf merge is quite complex thing.

    Anyway, even in your solution I am afraid you will get to the landscape header just information about the parent.
    So the page numbers will be relative just to the appended page.

    I will try to find a time to look at it. Unfortunately we are too busy at this moment.
    If you find a time to check the source and search for a solution, I will happily assist you.

    https://github.com/jsreport/jsreport-pdf-utils



  • Thanks for your help. I will try to look into code, and might need your help further. I will discuss it on the github issue.


Log in to reply
 

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