I think that it would be well worth your time to explore the Python Sphinx-Doc infrastructure but for just what you asked for you could simply use Pygments & rst2pdf:
With a python 3 installation you can simply pip install rst2pdf Pygmments rst2pdf will also install ReportLab.
Pygments is a syntax highlighting package written in Python.
It is a generic ...
have you tried : FreePDF for Windows - A simply and free virtual PDF printer
I have been using this for >10 years.
It will install a printer service(i.e. virtual printer) and if you click on menu-> printer(e.g. word or any), it will pop-up as a real printer and print your content ...
You can use the command line tool, docx2pdf to batch convert word documents to pdf on Windows or macOS: https://github.com/AlJohri/docx2pdf
pip install docx2pdf
Disclaimer: I wrote this tool.
I tried Chrome itself successfully.
This is the command line specimen I used:
chrome.exe --headless --print-to-pdf=out.pdf file:///input.html
Actual command line example (Windows):
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --print-to-pdf=C:\reports\example.pdf file:///C:\reports\example.html
As usual you have to wrap ...