Web/HTML To PDF REST API for Perl Samples

perl_logoPerl is a general-purpose programming language originally developed for text manipulation and now used for a wide range of tasks including system administration, web development, network programming, GUI development, and more.

Perl is a family of high-level, general-purpose, interpreted, dynamic programming languages. The languages in this family include Perl 5 and Perl 6.

Though Perl is not officially an acronym, there are various backronyms in use, the most well-known being “Practical Extraction and Reporting Language”. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions. Perl 6, which began as a redesign of Perl 5 in 2000, eventually evolved into a separate language. Both languages continue to be developed independently by different development teams and liberally borrow ideas from one another.

In this post, SelectPdf team has put together a few Perl samples for our Html To Pdf API to make your life a little easier if you need to convert from web pages to pdf in your Perl applications.

Exemple #1 – How to use Perl to convert a webpage to PDF and save it on the disk

This code converts an url to pdf in Perl using SelectPdf HTML To PDF API through a GET request. The content is saved into a file on the disk.

Exemple #2 – How to use Perl to convert a webpage to PDF with a POST API request and save it on the disk

This code converts an url to pdf in Perl using SelectPdf HTML To PDF REST API through a POST request. The parameters are url encoded (default). The content is saved into a file on the disk.

Exemple #3 – How to use Perl to convert a web page to PDF with a POST API request and save it on the disk

This code converts an url to pdf in Perl using SelectPdf HTML To PDF REST API through a POST request. The parameters are JSON encoded. The content is saved into a file on the disk.

The above samples use only the 2 mandatory parameters (key and url or html) for the html to pdf conversion. For the full list of optional parameters, take a look at SelectPdf HTML To PDF API page. Using the API optional parameters, you can control the page size, orientation and margins in the pdf document, the document information and security, the headers and footers and a lot more.

Hopefully these examples will help you to be on your way using the API for URL to PDF conversion in Perl.

The above Perl samples can also be found in the following GitHub repository:
https://github.com/selectpdf/selectpdf-api-perl-samples