Skip to content

Instantly share code, notes, and snippets.

@f9n
Last active January 1, 2019 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f9n/f3024deb4e910b162875460de3abd6d6 to your computer and use it in GitHub Desktop.
Save f9n/f3024deb4e910b162875460de3abd6d6 to your computer and use it in GitHub Desktop.
Generate pdf for websites

Generate Pdf for Websites

Wkhtmltopdf

$ sudo pacman -S wkhtmltopdf
$ wkhtmltopdf  http://www.google.com google.pdf
qt5ct: using qt5ct plugin
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
qt5ct: D-Bus system tray: yes
Loading page (1/2)
QNetworkReplyHttpImplPrivate::_q_startOperation was called more than once QUrl("http://www.google.com/")
Printing pages (2/2)                                               
Warning: Received createRequest signal on a disposed ResourceObject \'s NetworkAccessManager. This might be an indication of an iframe taking too long to load.
Done                                                           
$ file google.pdf 
google.pdf: PDF document, version 1.4
$ pdfinfo google.pdf 
Title:          
Creator:        wkhtmltopdf 0.12.5
Producer:       Qt 5.12.0
CreationDate:   Tue Jan  1 13:23:13 2019 +03
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      595 x 842 pts (A4)
Page rot:       0
File size:      75437 bytes
Optimized:      no
PDF version:    1.4
$ evince google.pdf 

Chromium Headless

$ chromium --headless --disable-gpu --print-to-pdf=google.pdf http://www.google.com
[0101/132611.259210:ERROR:gpu_process_transport_factory.cc(967)] Lost UI shared context.
[0101/132612.521526:INFO:headless_shell.cc(546)] Written to file google.pdf.
$ file google.pdf 
google.pdf: PDF document, version 1.4
$ pdfinfo google.pdf 
Creator:        Chromium
Producer:       Skia/PDF m71
CreationDate:   Tue Jan  1 13:26:12 2019 +03
ModDate:        Tue Jan  1 13:26:12 2019 +03
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      612 x 792 pts (letter)
Page rot:       0
File size:      90888 bytes
Optimized:      no
PDF version:    1.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment