12

I have a folder with this structure:

/main-folder
 /index.html
 /subfolder1
    /index1.html
    /file1.html

with many sub folder and only html files... i want to convert all them to pdf using only one command or a simple script that doesn't require all file names.

Do you know one

enzotib
  • 92,255
  • 11
  • 164
  • 178
Matteo Pagliazzi
  • 2,763
  • 7
  • 25
  • 33

2 Answers2

15

I would suggest installing the WKHtmlToPDF tool from http://wkhtmltopdf.org/ (moved from: http://code.google.com/p/wkhtmltopdf/).

You can then change to the root folder and use find and xargs to convert them:

cd /main-folder
find . -name \*.html | sed 's/.html$//g' | xargs -n 1 --replace=X wkhtmltopdf X.html X.pdf

This will then build a PDF with each HTML file.

dan_linder
  • 990
  • 5
  • 15
5

The following command should do the job for one link:

gnome-web-print http://www.ubuntu.com ubuntu.pdf

For multiple links, it shouldn't be difficult to write a loop that handles each link one by one.

Jorge Castro
  • 70,934
  • 124
  • 466
  • 653
jcollado
  • 9,498
  • 2
  • 27
  • 26