Skip to content

update to 25.6 #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
## Read PDF Formats
MHT, PCL, PS, XSLFO, MD

## Enhancements in Version 25.5
- Add a method for comparing pdf files.
## Enhancements in Version 25.6
- Develop Rotate Document Pages method.
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.

## Requirements
Expand Down
44 changes: 44 additions & 0 deletions UsesCases/Compares/comparePdfDocuments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

require_once __DIR__ . '\comparesHelper.php';

$configParams = [
'LOCAL_FOLDER' => "C:\\Samples\\",
'REMOTE_FOLDER' => "Your_Temp_Pdf_Cloud",
'PDF_DOCUMENT_1' => "sample_compare_1.pdf",
'PDF_DOCUMENT_2' => "sample_compare_2.pdf",
'PDF_OUTPUT' => "output_compare.pdf"
];

$helper = new PdfComparesHelper($pdfApi);

class PdfCompares
{
private $helper;
private $api;
private $config;

public function __construct($helper, $api, $config)
{
$this->helper = $helper;
$this->api = $api;
$this->config = $config;
}

public function comparePdfDocuments($document1, $document2, $outputDocument)
{
$this->helper->uploadFile($document1, $this->config['LOCAL_FOLDER'], $this->config['REMOTE_FOLDER']);
$this->helper->uploadFile($document2, $this->config['LOCAL_FOLDER'], $this->config['REMOTE_FOLDER']);

$remotePdf1 = $this->helper->joinPath($this->config['REMOTE_FOLDER'], $document1);
$remotePdf2 = $this->helper->joinPath($this->config['REMOTE_FOLDER'], $document2);
$remotePdfOut = $this->helper->joinPath($this->config['REMOTE_FOLDER'], $outputDocument);

$response = $this->api->postComparePdf($remotePdf1, $remotePdf2, $remotePdfOut);

if ($response->getCode() == 200) {
echo "Compare was successfully finished in '{$outputDocument}' file.\n";
$this->helper->downloadResult($outputDocument, $this->config['LOCAL_FOLDER'], $this->config['REMOTE_FOLDER']);
}
}
}
46 changes: 46 additions & 0 deletions UsesCases/Compares/comparesHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use Aspose\PDF\Api\PdfApi;

$credentials = json_decode(file_get_contents(__DIR__ . '/../../../Credentials/credentials.json'), true);

$pdfApi = new PdfApi($credentials['id'], $credentials['key']);

class PdfComparesHelper
{
private $pdfApi;

public function __construct($pdfApi)
{
$this->pdfApi = $pdfApi;
}

public function uploadFile($fileName, $localFolder, $remoteFolder)
{
$localFilePath = rtrim($localFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $fileName;
$remoteFilePath = rtrim($remoteFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $fileName;

$fileData = file_get_contents($localFilePath);
$this->pdfApi->uploadFile($remoteFilePath, $fileData);

echo "Uploaded: $fileName\n";
}

public function downloadResult($fileName, $localFolder, $remoteFolder)
{
$remoteFilePath = rtrim($remoteFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $fileName;
$response = $this->pdfApi->downloadFile($remoteFilePath);

$localFilePath = rtrim($localFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $fileName;
file_put_contents($localFilePath, $response['body']);

echo "Downloaded: $localFilePath\n";
}

public function joinPath(...$segments)
{
return join(DIRECTORY_SEPARATOR, array_map(function($s) {
return trim($s, DIRECTORY_SEPARATOR);
}, $segments));
}
}
14 changes: 14 additions & 0 deletions UsesCases/Compares/comparesLaunch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require_once __DIR__ . '\comparePdfDocuments.php';

try {
$comparer = new PdfCompares($helper, $pdfApi, $configParams);
$comparer->comparePdfDocuments(
$configParams['PDF_DOCUMENT_1'],
$configParams['PDF_DOCUMENT_2'],
$configParams['PDF_OUTPUT']
);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
26 changes: 26 additions & 0 deletions docs/PdfApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ Method | HTTP request | Description
*PdfApi* | [**postDocumentImageStamps**](PdfApi.md#postDocumentImageStamps) | **POST** /pdf/\{name}/stamps/image | Add document pages image stamps.
*PdfApi* | [**postDocumentImageStampsPageSpecified**](PdfApi.md#postDocumentImageStampsPageSpecified) | **POST** /pdf/\{name}/stamps/image/pagespecified | Add document image stamps to specified pages.
*PdfApi* | [**postDocumentPageNumberStamps**](PdfApi.md#postDocumentPageNumberStamps) | **POST** /pdf/\{name}/stamps/pagenumber | Add document page number stamps.
*PdfApi* | [**postDocumentPagesRotate**](PdfApi.md#postDocumentPagesRotate) | **POST** /pdf/\{name}/rotate | Rotate PDF document.
*PdfApi* | [**postDocumentTextFooter**](PdfApi.md#postDocumentTextFooter) | **POST** /pdf/\{name}/footer/text | Add document text footer.
*PdfApi* | [**postDocumentTextHeader**](PdfApi.md#postDocumentTextHeader) | **POST** /pdf/\{name}/header/text | Add document text header.
*PdfApi* | [**postDocumentTextReplace**](PdfApi.md#postDocumentTextReplace) | **POST** /pdf/\{name}/text/replace | Document's replace text method.
Expand Down Expand Up @@ -5237,6 +5238,31 @@ Name | Type | Description | Notes

[**\Aspose\PDF\Model\AsposeResponse**](AsposeResponse.md)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

<a name="postDocumentPagesRotate"></a>
## **postDocumentPagesRotate**
> \Aspose\PDF\Model\AsposeResponse postDocumentPagesRotate($name, $rotation_angle, $pages, $storage, $folder, $password)

Rotate PDF document.

### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**$name** | **string** | The document name. |
**$rotation_angle** | [**\Aspose\PDF\Model\Rotation**](Rotation.md) | Rotation Angle (CKW). Can be 90, 180, 270. |
**$pages** | **string** | Comma separated list of pages and page ranges. (Example: 1,3-5,8) |
**$storage** | **string** | The document storage. | [optional]
**$folder** | **string** | The document folder. | [optional]
**$password** | **string** | Base64 encoded password. | [optional]

### Return type

[**\Aspose\PDF\Model\AsposeResponse**](AsposeResponse.md)

### HTTP request headers

- **Content-Type**: application/json
Expand Down
Loading