Friday,
1st February 2013
Article in Spanish

How to convert a website to PDF format


Sometimes the need arises to capture a website appearance so that we can check it later or maybe to include the image in some document or presentation. For instance:

  • Searching for inspiration web designing a new website
  • Saving an article to read it later in an ebook

We have different options for this:

1. Making a screenshot

We can make a screenshot. (in Mac OS with

Cmd+shift+3

). This has some disadvantges: if the site has scrollbars we will only capture the part visible on screen. We will have to capture different sections and join them using an external program like Photoshop.

2. Print to PDF

save as pdf

In some systems we can install a virtual device for printing. In Mac OS we have that for free. We can print any site and select the option "save as PDF". With this option we will have a print version of the page, which will probably not show exactly like we see in the browser.

3. Use a web service to convert the webpage to PDF

convert web to pdf

At digitocero we have created the service gratis convertir web a pdf to make the mentoned task easy. It is only necessary to paste the url and a PDF will be generated. The page appears exactly as it would show in a browser. This is a free service. We recommend you to try it.

4. Use the comand-line... (Luke)

There exist different command-line utilities to generate PDFs. In Mac OS we can use Terminal to execute the following script. We can use it to convert many files to PDF documents.

genpdf.sh

        #!/bin/sh
        for f in "$@"
        do
            OUTPUT=$@".pdf";
        /usr/sbin/cupsfilter $@ >> $OUTPUT
        done
    

We can execute it over some types of files with

files with .php extension

find *.php -type f -exec ./genpdf.sh {} \;
    

files with .py extension

find . *.py -type f -exec ./genpdf.sh {} \;
    

Well, you get the idea

find *.js -type f -exec ./genpdf.sh {} \;

blog comments powered by Disqus
Bookmark and Share