Code Monkey home page Code Monkey logo

Comments (8)

kimmobrunfeldt avatar kimmobrunfeldt commented on May 13, 2024

Thanks, I totally agree. To do that, I can think of three possible options:

  1. Using CSS. https://stackoverflow.com/questions/1360869/how-to-use-html-to-print-header-and-footer-on-every-printed-page-of-a-document

  2. Modify the PDF with a separate library after Chrome has rendered.

  3. Check if Puppeteer/Chrome print protocol would allow injecting headers and footers in a more custom way. I doubt this is supported, but haven't checked.

Out of these options, I'd recommend to investigate the first one. I'm not so excited about the second option.

from url-to-pdf-api.

fabiosussetto avatar fabiosussetto commented on May 13, 2024

@webular assuming you control how the HTML for those pages is generated, why don't you add the header/footer to the HTML using something like a template language (e.g. Jinja, Twig,..), a bit how you would handle email templates.

from url-to-pdf-api.

kojuka avatar kojuka commented on May 13, 2024

@fabiosussetto I do control the html. But I find it nontrivial - at the least I don't have much experience with this. I'm open to direction -- All I really need is to add a logo and project name, and page number at the top of every generated PDF. I'd also need to add a one line footer to each page. Got any examples you can point me to on doing this with email templates like you suggest?

I'm really pleased to see the traction this project has received and would love to make the switch.

from url-to-pdf-api.

SpaceK33z avatar SpaceK33z commented on May 13, 2024

With Puppeteer 1.0.0 it is now possible to add a custom header/footer (source). This repo currently uses ^0.11.0, so after an update it might work :).

from url-to-pdf-api.

SpaceK33z avatar SpaceK33z commented on May 13, 2024

Made a PR #56 to upgrade to v1.0.0, which would fix this issue 😃.

from url-to-pdf-api.

kimmobrunfeldt avatar kimmobrunfeldt commented on May 13, 2024

The support for this is now in master, and also released to the demo Heroku app. However there are some caveats with Chrome's footer and header support. See #77

from url-to-pdf-api.

RayAnti2 avatar RayAnti2 commented on May 13, 2024

I found puppeteer is a good tool for converting from html to pdf.
But the footerTemplate must be the same on all pages?
Now I need, for example, pages' footer like this:

(page 1)
pageNumber of totalNumber---------------------------vocabulary list

(page 2)
vocabulary list-------------------------------------pageNumber of totalNumber

(page 3)
pageNumber of totalNumber---------------------------vocabulary list

I prepare 2 Templates for odd and even num pages
What should i do?

from url-to-pdf-api.

tiotamara avatar tiotamara commented on May 13, 2024

@RayAnti2 you can using page_script, I hope this help u

from url-to-pdf-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.