[PDF Header and Footer] Inconsistent Header

Forge Component
(5)
Published on 2016-05-18 by Fábio Fantato
5 votes
Published on 2016-05-18 by Fábio Fantato

Hey there,

I am using the PDF header footer, and when I use this functionality to download a PDF of multiple pages, the header is inconsistent - for example, if I download a PDF of the same screen 3 times in a row, the first PDF may have a header on pages 1 and 3, and the second PDF may have a header only on page 4.

Any idea what may be causing this inconsistency in the header?

Solution

Hey Stephanie,

I had the same problem!

For the header and the footer you are probably loading in from an external page right? (or are you inputting the html directly into the options?).

Sometimes Outsystems isn't that quickly with loading your pages, thus leaving them to be empty.

What I did to solve this was the following:

- On my header and footer page, I added caching of 3 minutes orso
- I tried to generate a PDF for my header and if the binary was empty, I'd know the page was not loaded, in this case I'd retry to generate a PDF until I got a binary for my header.
- I repeat this with the footer
- Then I generate the actual full PDF, since I used caching for the header and footer they should now load consistently.
- I also added --javascript-delay 700 to the OtherArgs input, this causes the Generator to wait 700ms for the page to finish loading.

Apperantly html2pdf does not wait until the header and footer are finished loading, but it does for the actual pdf page, I'm not sure if they will ever fix this though.... best would be to get the html directly in the OtherArgs, but I can imagine the hassle of that.

Solution

Joey Moree wrote: Thank you Joey! This fixed the issue I was having :) 

Hey Stephanie,

I had the same problem!

For the header and the footer you are probably loading in from an external page right? (or are you inputting the html directly into the options?).

Sometimes Outsystems isn't that quickly with loading your pages, thus leaving them to be empty.

What I did to solve this was the following:

- On my header and footer page, I added caching of 3 minutes orso
- I tried to generate a PDF for my header and if the binary was empty, I'd know the page was not loaded, in this case I'd retry to generate a PDF until I got a binary for my header.
- I repeat this with the footer
- Then I generate the actual full PDF, since I used caching for the header and footer they should now load consistently.
- I also added --javascript-delay 700 to the OtherArgs input, this causes the Generator to wait 700ms for the page to finish loading.

Apperantly html2pdf does not wait until the header and footer are finished loading, but it does for the actual pdf page, I'm not sure if they will ever fix this though.... best would be to get the html directly in the OtherArgs, but I can imagine the hassle of that.