Skip to content

Support of <header> and <footer> elements #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2014

Conversation

woolfg
Copy link
Contributor

@woolfg woolfg commented May 20, 2014

Support of

and elements which are rendered on each page. Footer additionally supports special span tags "pageCounter" and "totalPages" which are replaced by the current page number or the total page count (see example below).

<footer>
    <div style='text-align:center;'>Page <span class="pageCounter"></span>/<span class="totalPages"></span></div>
</footer>

diegocr added a commit that referenced this pull request May 21, 2014
fromHTML PlugIn Support of <header> and <footer> elements.
@diegocr diegocr merged commit b38a73b into parallax:master May 21, 2014
@diegocr
Copy link
Contributor

diegocr commented May 21, 2014

Looking good, thank you!

diegocr added a commit that referenced this pull request May 21, 2014
@diegocr
Copy link
Contributor

diegocr commented May 21, 2014

Btw, i've just finished reindenting jspdf.plugin.from_html.js on 84b6204 so don't forget to merge the master before doing any further improvements, just in case of :)

@fireholster
Copy link

Is there a way to add images in header an footer here?

@didschai
Copy link

didschai commented Jul 22, 2022

Hi all,
it seems that this feature didn't make it into the html() method/plugin. Or am I missing something?
When I use <footer> in the latest version, nothing is rendered.
Can you provide any info, please?

Regards, Denis

@pacsent
Copy link

pacsent commented Jul 25, 2022

Yes. Any way to add header/footer in HTML and not text?

@speedDaemonAmber
Copy link

I am trying to accomplish this as well. Is there a way to add a header/footer in html?

@kundanashish
Copy link

I am still struggling with this. Has anybody found any solution?

@RyDVi
Copy link

RyDVi commented Apr 18, 2024

My solution for adding page number with html(...). Perhaps this will help you.


const jspdf = new jsPDF('l', 'mm', 'a4', true);
jspdf.html(document.body, {
  callback(doc) {
    const totalPages = doc.getNumberOfPages();
    for (let pageNumber = 1; pageNumber <= totalPages; pageNumber++) {
      doc.setPage(pageNumber);
      doc.setFontSize(8);
      doc.setTextColor("black");
      doc.text(`${pageNumber}/${totalPages}`, 297 / 2 - 15, 210 - 5);
    }

    doc.save();
  },
  width: 297 - 15 - 5,
  windowWidth: document.getElementsByTagName('html')[0].getBoundingClientRect().width,
  autoPaging: 'text',
  margin: [5,15,10,5],
  x: 0,
  y: 0,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants