0

I tried the options in Is there a script or tool that converts HTML to PDF? with command:

pandoc documentation.html -o test.pdf --pdf-engine=xelatex 

but unfortunately they do not preserve the CSS formatting. For example I have this document that looks like this:

enter image description here


but the resulting pdf output looks plain like this without css formatting. Notice that the header with blue background is gone and all the other formatted texts no background css.

enter image description here

2
  • Try chromium --headless --disable-gpu --print-to-pdf=out.pdf documentation.html
    – Devon
    CommentedApr 11, 2024 at 7:03
  • @Devon thanks for the suggestion. chromium not found so i sudo apt-get install chromium-browser and tried again then it suggested i need to install snap install chromium but then it gives me error: cannot communicate with server: Post "http://localhost/v2/snaps/chromium": dial unix /run/snapd.socket: connect: no such file or directory maybe because im running ubuntu app WSL on windows 11 :(CommentedApr 11, 2024 at 7:17

1 Answer 1

1

There are multiple options, including paged.js, WeasyPrint, and wkhtmltopdf (which is outdated, but easy to install on most distros. You might also want to checkout speedata, and there are many closed-source offerings like PrinceXML.

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.