Skip to content

Commit e1c7889

Browse files
author
SelectPdf
committed
Version 1.4.0
1 parent ee1af93 commit e1c7889

19 files changed

+4825
-2
lines changed

Changes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Revision history for SelectPdf Online API client for Perl.
2+
3+
1.4.0
4+
5+
- Added Pdf Merge client.
6+
- Added Pdf to Text client.
7+
8+
1.3.0
9+
- Modified package structure. Added more documentation.
10+
11+
1.2.2
12+
- Initial version for HtmlToPdfClient.
13+
14+

MANIFEST

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Changes
2+
Makefile.PL
3+
MANIFEST
4+
README
5+
t/SelectPdf.t
6+
samples/html-to-pdf-main.pl
7+
samples/html-to-pdf-headers-and-footers.pl
8+
samples/pdf-merge.pl
9+
samples/pdf-to-text.pl
10+
samples/search-pdf.pl
11+
lib/SelectPdf.pm
12+
lib/SelectPdf/ApiClient.pm
13+
lib/SelectPdf/AsyncJobClient.pm
14+
lib/SelectPdf/HtmlToPdfClient.pm
15+
lib/SelectPdf/UsageClient.pm
16+
lib/SelectPdf/WebElementsClient.pm
17+
lib/SelectPdf/PdfMergeClient.pm
18+
lib/SelectPdf/PdfToTextClient.pm

Makefile.PL

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
use 5.020001;
2+
use ExtUtils::MakeMaker;
3+
WriteMakefile(
4+
NAME => 'SelectPdf',
5+
VERSION_FROM => 'lib/SelectPdf.pm',
6+
PREREQ_PM => {
7+
'LWP::UserAgent' => 0,
8+
'HTTP::Request::Common' => 0,
9+
'HTTP::Status' => 0,
10+
'JSON' => 0
11+
},
12+
ABSTRACT => 'SelectPdf Online REST API Perl Client (HTML to PDF, PDF merge, PDF to text, search PDF)',
13+
AUTHOR => 'SelectPdf <support@selectpdf.com>',
14+
LICENSE => 'perl',
15+
META_ADD => {
16+
provides => {
17+
'SelectPdf' => {
18+
file => 'lib/SelectPdf.pm',
19+
version => '1.4.0',
20+
},
21+
'SelectPdf::ApiClient' => {
22+
file => 'lib/SelectPdf/ApiClient.pm',
23+
version => '1.4.0',
24+
},
25+
'SelectPdf::AsyncJobClient' => {
26+
file => 'lib/SelectPdf/AsyncJobClient.pm',
27+
version => '1.4.0',
28+
},
29+
'SelectPdf::HtmlToPdfClient' => {
30+
file => 'lib/SelectPdf/HtmlToPdfClient.pm',
31+
version => '1.4.0',
32+
},
33+
'SelectPdf::UsageClient' => {
34+
file => 'lib/SelectPdf/UsageClient.pm',
35+
version => '1.4.0',
36+
},
37+
'SelectPdf::WebElementsClient' => {
38+
file => 'lib/SelectPdf/WebElementsClient.pm',
39+
version => '1.4.0',
40+
},
41+
'SelectPdf::PdfMergeClient' => {
42+
file => 'lib/SelectPdf/PdfMergeClient.pm',
43+
version => '1.4.0',
44+
},
45+
'SelectPdf::PdfToTextClient' => {
46+
file => 'lib/SelectPdf/PdfToTextClient.pm',
47+
version => '1.4.0',
48+
},
49+
},
50+
}
51+
);

README

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
SelectPdf version 1.4.0
2+
=======================
3+
4+
This is a Perl version for SelectPdf Online REST API client library.
5+
It contains: HTML to PDF client, PDF Merge client, PDF to Text client.
6+
7+
INSTALLATION
8+
9+
To install this module type the following (use make, dmake or nmake depending on your system):
10+
11+
perl Makefile.PL
12+
make
13+
make test
14+
make install
15+
16+
DEPENDENCIES
17+
18+
This module requires these other modules and libraries:
19+
20+
LWP::UserAgent
21+
HTTP::Request::Common
22+
HTTP::Status
23+
JSON
24+
25+
COPYRIGHT AND LICENCE
26+
27+
Copyright (C) 2021 by SelectPdf
28+
29+
This library is free software; you can redistribute it and/or modify
30+
it under the same terms as Perl itself, either Perl version 5.20.1 or,
31+
at your option, any later version of Perl 5 you may have available.
32+
33+

README.md

Lines changed: 140 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,140 @@
1-
# selectpdf-api-perl-client
2-
Perl client for SelectPdf Online REST API
1+
# SelectPdf Online REST API - Perl Client
2+
3+
## HTML To PDF API - Perl Client
4+
5+
SelectPdf HTML To PDF Online REST API is a professional solution that lets you create PDF from web pages and raw HTML code in your applications. The API is easy to use and the integration takes only a few lines of code.
6+
7+
## Features
8+
9+
* Create PDF from any web page or html string.
10+
* Full html5/css3/javascript support.
11+
* Set PDF options such as page size and orientation, margins, security, web page settings.
12+
* Set PDF viewer options and PDF document information.
13+
* Create custom headers and footers for the pdf document.
14+
* Hide web page elements during the conversion.
15+
* Automatically generate bookmarks during the html to pdf conversion.
16+
* Support for partial page conversion.
17+
* Easy integration, no third party libraries needed.
18+
* Works in all programming languages.
19+
* No installation required.
20+
21+
Sign up for for free to get instant API access to SelectPdf [HTML to PDF API](https://selectpdf.com/html-to-pdf-api/).
22+
23+
## Pdf Merge API
24+
25+
SelectPdf offers a REST API that can be used to merge PDF documents from local disk or remote url.
26+
27+
## Pdf To Text API
28+
29+
SelectPdf offers a REST API that can be used to extract text from local or remote PDF documents and search in existing PDF documents.
30+
31+
32+
## Installation
33+
34+
Download [selectpdf-api-perl-client-1.4.0.zip](https://github.com/selectpdf/selectpdf-api-perl-client/releases/download/1.4.0/selectpdf-api-python-client-1.4.0.zip), unzip it and run:
35+
36+
```
37+
cd selectpdf-api-perl-client-1.4.0
38+
perl Makefile.PL
39+
make
40+
make test
41+
make install
42+
```
43+
44+
OR
45+
46+
Install SelectPdf Perl Client for Online API via CPAN: [SelectPdf on CPAN](https://metacpan.org/dist/SelectPdf).
47+
48+
```
49+
cpanm SelectPdf
50+
```
51+
52+
OR
53+
54+
Clone [selectpdf-api-perl-client](https://github.com/selectpdf/selectpdf-api-perl-client) from Github and install the library.
55+
56+
```
57+
git clone https://github.com/selectpdf/selectpdf-api-perl-client
58+
cd selectpdf-api-perl-client
59+
perl Makefile.PL
60+
make
61+
make test
62+
make install
63+
```
64+
65+
## Sample Code
66+
67+
```
68+
local $| = 1;
69+
70+
use strict;
71+
use JSON;
72+
use SelectPdf;
73+
74+
print "This is SelectPdf-$SelectPdf::VERSION.\n";
75+
76+
my $url = "https://selectpdf.com/";
77+
my $local_file = "Test.pdf";
78+
my $apiKey = "Your API key here";
79+
80+
eval {
81+
my $client = new SelectPdf::HtmlToPdfClient($apiKey);
82+
83+
# set parameters - see full list at https://selectpdf.com/html-to-pdf-api/
84+
$client
85+
# main properties
86+
87+
->setPageSize("A4") # PDF page size
88+
->setPageOrientation("Portrait") # PDF page orientation
89+
->setMargins(0) # PDF page margins
90+
->setRenderingEngine('WebKit') # rendering engine
91+
->setConversionDelay(1) # conversion delay
92+
->setNavigationTimeout(30) # navigation timeout
93+
->setShowPageNumbers('False') # page numbers
94+
->setPageBreaksEnhancedAlgorithm('True') # enhanced page break algorithm
95+
96+
# additional properties
97+
98+
#->setUseCssPrint('True') # enable CSS media print
99+
#->setDisableJavascript('True') # disable javascript
100+
#->setDisableInternalLinks('True') # disable internal links
101+
#->setDisableExternalLinks('True') # disable external links
102+
#->setKeepImagesTogether('True') # keep images together
103+
#->setScaleImages('True') # scale images to create smaller pdfs
104+
#->setSinglePagePdf('True') # generate a single page PDF
105+
#->setUserPassword('password') # secure the PDF with a password
106+
107+
# generate automatic bookmarks
108+
109+
#->setPdfBookmarksSelectors("H1, H2") # create outlines (bookmarks) for the specified elements
110+
#->setViewerPageMode(1) # 1 (Use Outlines) - display outlines (bookmarks) in viewer
111+
;
112+
113+
print "Starting conversion ...\n";
114+
115+
# convert url to file
116+
$client->convertUrlToFile($url, $local_file);
117+
118+
# convert url to memory
119+
# my $pdf = $client->convertUrl($url);
120+
121+
# convert html string to file
122+
# $client->convertHtmlStringToFile("This is some <b>html</b>.", $local_file);
123+
124+
# convert html string to memory
125+
# my $pdf = $client->convertHtmlString("This is some <b>html</b>.");
126+
127+
print "Finished! Number of pages: " . $client->getNumberOfPages() . ".\n";
128+
129+
# get API usage
130+
my $usageClient = new SelectPdf::UsageClient($apiKey);
131+
my $usage = $usageClient->getUsage();
132+
print("Usage: " . encode_json($usage) . "\n");
133+
print("Conversions remained this month: ". $usage->{"available"});
134+
};
135+
136+
if ($@) {
137+
print "An error occurred: $@\n";
138+
}
139+
140+
```

0 commit comments

Comments
 (0)