Skip to content

Convert a URL of a web page into a PDF. Best for downloading and printing.

License

Notifications You must be signed in to change notification settings

vinyll/HTML2PDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert a Web Page Into a PDF

aka easily download print a web page as a PDF.

Quickstart

  1. Start the server: docker compose up
  2. Print the example.org page: http://localhost:3000/?url=http://example.org&name=mysite.pdf

Manual Setup

Bun and WeasyPrint should be installed on your system.

Run the server on port 3000:

bun index.ts

You can change the port by passing it as argument: bun index.ts 1234 to run on port 1234.

Now generate a PDF from a web page and call it "example.pdf": http://localhost:3000/?url=https://www.iana.org/help/example-domains&name=example.pdf

Why This Script

I needed a PDF printer that could be simple, light and quick to run.

This script on only 20 lines of code with no lib dependency!

License

This software is free and provided with an MIT license attached.