Skip to content

Commit

Permalink
version 5.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel committed Oct 3, 2022
1 parent e125a8f commit c4dd62f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log
==========

5.9.0
-----

- NEW: getTotalPageCount to get the total page count of the source document
- NEW: readability-v4 mode for setReadabilityEnhancements API method

5.8.0
-----

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pdfcrowd/pdfcrowd",
"type": "library",
"version": "5.8.0",
"version": "5.9.0",
"description": "A client library for the Pdfcrowd API. It lets you convert between HTML, PDF and various image formats",
"keywords": ["html", "pdf", "web service", "api", "client", "convert", "web page"],
"homepage": "https://pdfcrowd.com/api/",
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = 5.8.0
VERSION = 5.9.0
PHP ?= php
DIR_NAME := pdfcrowd-5.8.0
DIR_NAME := pdfcrowd-5.9.0

dist: dist/pdfcrowd-$(VERSION)-php.zip

Expand Down
40 changes: 28 additions & 12 deletions pdfcrowd.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function setTimeout($timeout) {

private $fields, $scheme, $port, $api_prefix, $curlopt_timeout;

public static $client_version = "5.8.0";
public static $client_version = "5.9.0";
public static $http_port = 80;
public static $https_port = 443;
public static $api_host = 'pdfcrowd.com';
Expand Down Expand Up @@ -547,7 +547,7 @@ function __construct($user_name, $api_key){
$this->reset_response_data();
$this->setProxy(null, null, null, null);
$this->setUseHttp(false);
$this->setUserAgent('pdfcrowd_php_client/5.8.0 (https://pdfcrowd.com)');
$this->setUserAgent('pdfcrowd_php_client/5.9.0 (https://pdfcrowd.com)');

$this->retry_count = 1;
$this->converter_version = '20.10';
Expand Down Expand Up @@ -577,6 +577,7 @@ function __construct($user_name, $api_key){
private $consumed_credits;
private $job_id;
private $page_count;
private $total_page_count;

private $proxy_host;
private $proxy_port;
Expand All @@ -592,7 +593,7 @@ function __construct($user_name, $api_key){

private static $SSL_ERRORS = array(35, 51, 53, 54, 58, 59, 60, 64, 66, 77, 80, 82, 83, 90, 91);

const CLIENT_VERSION = '5.8.0';
const CLIENT_VERSION = '5.9.0';
public static $MULTIPART_BOUNDARY = '----------ThIs_Is_tHe_bOUnDary_$';

private function add_file_field($name, $file_name, $data, &$body) {
Expand All @@ -609,6 +610,7 @@ private function reset_response_data() {
$this->consumed_credits = 0;
$this->job_id = '';
$this->page_count = 0;
$this->total_page_count = 0;
$this->output_size = 0;
$this->retry = 0;
}
Expand Down Expand Up @@ -804,6 +806,8 @@ private function parse_response_headers($headers) {
$this->job_id = $matches[1];
} else if(preg_match('/X-Pdfcrowd-Pages:\s+(.*)/i', $header, $matches)) {
$this->page_count = intval($matches[1]);
} else if(preg_match('/X-Pdfcrowd-Total-Pages:\s+(.*)/i', $header, $matches)) {
$this->total_page_count = intval($matches[1]);
} else if(preg_match('/X-Pdfcrowd-Output-Size:\s+(.*)/i', $header, $matches)) {
$this->output_size = intval($matches[1]);
} else if(preg_match('/X-Pdfcrowd-Remaining-Credits:\s+(.*)/i', $header, $matches)) {
Expand Down Expand Up @@ -904,6 +908,10 @@ function getPageCount() {
return $this->page_count;
}

function getTotalPageCount() {
return $this->total_page_count;
}

function getOutputSize() {
return $this->output_size;
}
Expand Down Expand Up @@ -2026,12 +2034,12 @@ function setAutoDetectElementToConvert($value) {
/**
* The input HTML is automatically enhanced to improve the readability.
*
* @param enhancements Allowed values are none, readability-v1, readability-v2, readability-v3.
* @param enhancements Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.
* @return The converter object.
*/
function setReadabilityEnhancements($enhancements) {
if (!preg_match("/(?i)^(none|readability-v1|readability-v2|readability-v3)$/", $enhancements))
throw new Error(create_invalid_value_message($enhancements, "setReadabilityEnhancements", "html-to-pdf", "Allowed values are none, readability-v1, readability-v2, readability-v3.", "set_readability_enhancements"), 470);
if (!preg_match("/(?i)^(none|readability-v1|readability-v2|readability-v3|readability-v4)$/", $enhancements))
throw new Error(create_invalid_value_message($enhancements, "setReadabilityEnhancements", "html-to-pdf", "Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.", "set_readability_enhancements"), 470);

$this->fields['readability_enhancements'] = $enhancements;
return $this;
Expand Down Expand Up @@ -2590,13 +2598,21 @@ function getJobId() {
}

/**
* Get the total number of pages in the output document.
* Get the number of pages in the output document.
* @return The page count.
*/
function getPageCount() {
return $this->helper->getPageCount();
}

/**
* Get the total number of pages in the original output document, including the pages excluded by <a href='#set_print_page_range'>setPrintPageRange()</a>.
* @return The total page count.
*/
function getTotalPageCount() {
return $this->helper->getTotalPageCount();
}

/**
* Get the size of the output in bytes.
* @return The count of bytes.
Expand Down Expand Up @@ -3417,12 +3433,12 @@ function setAutoDetectElementToConvert($value) {
/**
* The input HTML is automatically enhanced to improve the readability.
*
* @param enhancements Allowed values are none, readability-v1, readability-v2, readability-v3.
* @param enhancements Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.
* @return The converter object.
*/
function setReadabilityEnhancements($enhancements) {
if (!preg_match("/(?i)^(none|readability-v1|readability-v2|readability-v3)$/", $enhancements))
throw new Error(create_invalid_value_message($enhancements, "setReadabilityEnhancements", "html-to-image", "Allowed values are none, readability-v1, readability-v2, readability-v3.", "set_readability_enhancements"), 470);
if (!preg_match("/(?i)^(none|readability-v1|readability-v2|readability-v3|readability-v4)$/", $enhancements))
throw new Error(create_invalid_value_message($enhancements, "setReadabilityEnhancements", "html-to-image", "Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.", "set_readability_enhancements"), 470);

$this->fields['readability_enhancements'] = $enhancements;
return $this;
Expand Down Expand Up @@ -4761,7 +4777,7 @@ function getJobId() {
}

/**
* Get the total number of pages in the output document.
* Get the number of pages in the output document.
* @return The page count.
*/
function getPageCount() {
Expand Down Expand Up @@ -5721,7 +5737,7 @@ function getJobId() {
}

/**
* Get the total number of pages in the output document.
* Get the number of pages in the output document.
* @return The page count.
*/
function getPageCount() {
Expand Down

0 comments on commit c4dd62f

Please sign in to comment.