Convert HTML to PDF with Wget

We've made some easy to follow examples that show you how to use the PDFmyURL converter API with Wget on the command line. They will show you how to convert a URL to PDF on the command line or (if you prefer) raw HTML to PDF. These examples should be pretty much copy/paste, but if you find you need more help - please send us an email.

Below is our tutorial video that shows how you can convert URLs to PDF with Wget on the command line.

Example for Wget URL to PDF conversion

Our HTML to PDF API is very easy to use. It takes a license and either a URL or raw HTML as input and returns a PDF.

In this examples we'll use a URL and then in the next one we'll do the same for raw HTML. For URLs the API basically works by sending a request similar to this to our converter service, which converts http://www.example.com to PDF:

https://pdfmyurl.com/api?license=yourlicensekey&url=http://www.example.com

You can use a lot of additional parameters in the API call, which give you access to all the features for conversion. These are all specified in the API conversion documentation.

Here we're converting the example URL to PDF and storing it in a file called "result.pdf".

wget -O result.pdf --post-data="license=yourlicensekey&url=https://www.example.com" https://pdfmyurl.com/api

Note that Wget doesn't have the ability to URL encode any data by itself (unlike cURL for example). Therefore you'd need to do this by yourself. So it would be better to use the following Wget command:

wget -O result.pdf --post-data="license=yourlicensekey&url=https%3A%2F%2Fwww.example.com" https://pdfmyurl.com/api

In the case of https://www.example.com this doesn't matter so much, but in case your URL contains special characters (such as ? or & etc) then this is very important.

Example for Wget HTML to PDF conversion

If you want to convert HTML to PDF with Wget then our API takes a license and the raw HTML as input and returns a PDF.

It basically works by sending a request similar to this to our converter service, which converts the text Hello (in bold) to PDF:

https://pdfmyurl.com/api?license=yourlicensekey&html=%3Cb%3EHello%3C%2Fb%3E

Note that we URL encoded the HTML so that it is passed correctly to our service. This is actually better for all parameters, but most parameters wouldn't normally contain special characters that make this important.

Here we're converting the example HTML to PDF and storing it in a file called "result.pdf". Note that in this case we're passing a file "data.txt", which contains all the parameters. The file should have the data in URL encoded format like this:

license=yourlicensekey&html=%3Cb%3EHello%3C%2Fb%3E

Then you can use the Wget command as follows, which will use the file as input:

wget -O result.pdf --post-file="data.txt" https://pdfmyurl.com/api

These examples should get you right on your way to convert URL to PDF or HTML to PDF with our converter API!

In many cases you'll also have cURL access when you want to use Wget. Since cURL has more options and is able to URL encode for you, we recommend using that. You can find the cURL examples at our cURL conversion example page.

If you'd like to see more examples or have any specific questions then please contact us via email.