Skip to content

Commit b69764d

Browse files
authored
Merge pull request #132 from aspose-pdf-cloud/develop
update to 25.6
2 parents b5dfb2d + f9f83d2 commit b69764d

File tree

11 files changed

+194
-7
lines changed

11 files changed

+194
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
3030
## Read PDF Formats
3131
MHT, PCL, PS, XSLFO, MD
3232

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

3737
## Installation
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import path from 'node:path';
2+
import { pdfComparesHelper, pdfApi } from "../Compares/comparesHelper.js";
3+
4+
export const configParams = {
5+
LOCAL_FOLDER: "C:\\Samples\\",
6+
REMOTE_FOLDER: "Your_Temp_Pdf_Cloud",
7+
PDF_DOCUMENT_1: "sample_compare_1.pdf",
8+
PDF_DOCUMENT_2: "sample_compare_2.pdf",
9+
PDF_OUTPUT: "output_compare.pdf",
10+
REMOTE_FOLDER: "Your_Temp_Pdf_Cloud",
11+
};
12+
13+
export const pdfCompares = {
14+
async comparePdfDocuments(document1, document2, output_document) {
15+
await pdfComparesHelper.uploadFile(document1, configParams.LOCAL_FOLDER, configParams.REMOTE_FOLDER);
16+
await pdfComparesHelper.uploadFile(document2, configParams.LOCAL_FOLDER, configParams.REMOTE_FOLDER);
17+
18+
const remotePdf1 = path.join(configParams.REMOTE_FOLDER, document1);
19+
const remotePdf2 = path.join(configParams.REMOTE_FOLDER, document2);
20+
var remotePdfOut = path.join(configParams.REMOTE_FOLDER, output_document);
21+
22+
const response = await pdfApi.postComparePdf(remotePdf1, remotePdf2, remotePdfOut);
23+
24+
if (response.body.code != 200) {
25+
console.log("Unexpected error!");
26+
}
27+
else{
28+
console.log("Compare was successful!y finished in '" + output_document + "' file.");
29+
await pdfComparesHelper.downloadResult(output_document, configParams.LOCAL_FOLDER, configParams.REMOTE_FOLDER);
30+
}
31+
32+
}
33+
34+
};

UsesCases/Compares/comparesHelper.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import credentials from "../../../Credentials/credentials.json" with { type: "json" };
2+
import fs from 'node:fs/promises';
3+
import path from 'node:path';
4+
import { PdfApi } from "../../src/api/api.js";
5+
6+
export const pdfApi = new PdfApi(credentials.id, credentials.key);
7+
8+
export const pdfComparesHelper = {
9+
async uploadFile (fileName, localFolder, remoteFolder) {
10+
const localFilePath = path.join(localFolder, fileName);
11+
const fileData = await fs.readFile(localFilePath);
12+
const remoteFilePath = path.join(remoteFolder, fileName);
13+
await pdfApi.uploadFile(remoteFilePath, fileData);
14+
console.log("Uploaded: " + fileName);
15+
},
16+
17+
async downloadResult (fileName, localFolder, remoteFolder) {
18+
const remoteFilePath = path.join(remoteFolder, fileName);
19+
const changedPdfData = await pdfApi.downloadFile(remoteFilePath);
20+
const localFilePath = path.join(localFolder, fileName);
21+
await fs.writeFile(localFilePath, changedPdfData.body);
22+
console.log("Downloaded: " + localFilePath);
23+
},
24+
25+
};

UsesCases/Compares/comparesLaunch.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { pdfCompares, configParams } from "../Compares/comparePdfDocuments.js";
2+
3+
async function main() {
4+
try {
5+
await pdfCompares.comparePdfDocuments(configParams.PDF_DOCUMENT_1, configParams.PDF_DOCUMENT_2, configParams.PDF_OUTPUT);
6+
} catch (error) {
7+
console.error("Error:", error.message);
8+
}
9+
}
10+
11+
await main();

docs/PdfApi.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Method | HTTP request | Description
212212
*PdfApi* | [**postDocumentImageStamps**](PdfApi.md#postDocumentImageStamps) | **POST** /pdf/\{name}/stamps/image | Add document pages image stamps.
213213
*PdfApi* | [**postDocumentImageStampsPageSpecified**](PdfApi.md#postDocumentImageStampsPageSpecified) | **POST** /pdf/\{name}/stamps/image/pagespecified | Add document image stamps to specified pages.
214214
*PdfApi* | [**postDocumentPageNumberStamps**](PdfApi.md#postDocumentPageNumberStamps) | **POST** /pdf/\{name}/stamps/pagenumber | Add document page number stamps.
215+
*PdfApi* | [**postDocumentPagesRotate**](PdfApi.md#postDocumentPagesRotate) | **POST** /pdf/\{name}/rotate | Rotate PDF document.
215216
*PdfApi* | [**postDocumentTextFooter**](PdfApi.md#postDocumentTextFooter) | **POST** /pdf/\{name}/footer/text | Add document text footer.
216217
*PdfApi* | [**postDocumentTextHeader**](PdfApi.md#postDocumentTextHeader) | **POST** /pdf/\{name}/header/text | Add document text header.
217218
*PdfApi* | [**postDocumentTextReplace**](PdfApi.md#postDocumentTextReplace) | **POST** /pdf/\{name}/text/replace | Document's replace text method.
@@ -5237,6 +5238,31 @@ Name | Type | Description | Notes
52375238

52385239
[**AsposeResponse**](AsposeResponse.md)
52395240

5241+
### HTTP request headers
5242+
5243+
- **Content-Type**: application/json
5244+
- **Accept**: application/json
5245+
5246+
<a name="postDocumentPagesRotate"></a>
5247+
## **postDocumentPagesRotate**
5248+
> postDocumentPagesRotate(name, rotationAngle, pages, storage, folder, password)
5249+
5250+
Rotate PDF document.
5251+
5252+
### Parameters
5253+
Name | Type | Description | Notes
5254+
------------- | ------------- | ------------- | -------------
5255+
**name** | **string** | The document name. |
5256+
**rotationAngle** | [**Rotation**](Rotation.md) | Rotation Angle (CKW). Can be 90, 180, 270. |
5257+
**pages** | **string** | Comma separated list of pages and page ranges. (Example: 1,3-5,8) |
5258+
**storage** | **string** | The document storage. | [optional]
5259+
**folder** | **string** | The document folder. | [optional]
5260+
**password** | **string** | Base64 encoded password. | [optional]
5261+
5262+
### Return type
5263+
5264+
[**AsposeResponse**](AsposeResponse.md)
5265+
52405266
### HTTP request headers
52415267

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

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asposepdfcloud",
3-
"version": "25.5.0",
3+
"version": "25.6.0",
44
"description": "Aspose.PDF Cloud is a REST API for creating and editing PDF files. Most popular features proposed by Aspose.PDF Cloud: PDF to Word, Convert PDF to Image, Merge PDF, Split PDF, Add Images to PDF, Rotate PDF. It can also be used to convert PDF files to different formats like DOC, HTML, XPS, TIFF and many more. Aspose.PDF Cloud gives you control: create PDFs from scratch or from HTML, XML, template, database, XPS or an image. Render PDFs to image formats such as JPEG, PNG, GIF, BMP, TIFF and many others. Aspose.PDF Cloud helps you manipulate elements of a PDF file like text, annotations, watermarks, signatures, bookmarks, stamps and so on. Its REST API also allows you to manage PDF pages by using features like merging, splitting, and inserting. Add images to a PDF file or convert PDF pages to images.",
55
"homepage": "https://products.aspose.cloud/pdf/cloud",
66
"author": {

src/api/api.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13005,6 +13005,83 @@ export class PdfApi {
1300513005
}
1300613006

1300713007

13008+
/**
13009+
*
13010+
* @summary Rotate PDF document.
13011+
* @param name The document name.
13012+
* @param rotationAngle Rotation Angle (CKW). Can be 90, 180, 270.
13013+
* @param pages Comma separated list of pages and page ranges. (Example: 1,3-5,8)
13014+
* @param storage The document storage.
13015+
* @param folder The document folder.
13016+
* @param password Base64 encoded password.
13017+
*/
13018+
public async postDocumentPagesRotate (name: string, rotationAngle: string, pages: string, storage?: string, folder?: string, password?: string) : Promise<{ response: http.IncomingMessage; body: AsposeResponse; }> {
13019+
const localVarPath = this.basePath + '/pdf/{name}/rotate'
13020+
.replace('{' + 'name' + '}', encodeURIComponent(String(name)).replace('%2F', '/'));
13021+
let localVarQueryParameters: any = {};
13022+
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
13023+
let localVarFormParams: any = {};
13024+
13025+
// verify required parameter 'name' is not null or undefined
13026+
if (name === null || name === undefined) {
13027+
throw new Error('Required parameter name was null or undefined when calling postDocumentPagesRotate.');
13028+
}
13029+
13030+
// verify required parameter 'rotationAngle' is not null or undefined
13031+
if (rotationAngle === null || rotationAngle === undefined) {
13032+
throw new Error('Required parameter rotationAngle was null or undefined when calling postDocumentPagesRotate.');
13033+
}
13034+
13035+
// verify required parameter 'pages' is not null or undefined
13036+
if (pages === null || pages === undefined) {
13037+
throw new Error('Required parameter pages was null or undefined when calling postDocumentPagesRotate.');
13038+
}
13039+
13040+
if (rotationAngle !== undefined && null !== rotationAngle) {
13041+
localVarQueryParameters['rotationAngle'] = ObjectSerializer.serialize(rotationAngle, "string");
13042+
}
13043+
13044+
if (pages !== undefined && null !== pages) {
13045+
localVarQueryParameters['pages'] = ObjectSerializer.serialize(pages, "string");
13046+
}
13047+
13048+
if (storage !== undefined && null !== storage) {
13049+
localVarQueryParameters['storage'] = ObjectSerializer.serialize(storage, "string");
13050+
}
13051+
13052+
if (folder !== undefined && null !== folder) {
13053+
localVarQueryParameters['folder'] = ObjectSerializer.serialize(folder, "string");
13054+
}
13055+
13056+
if (password !== undefined && null !== password) {
13057+
localVarQueryParameters['password'] = ObjectSerializer.serialize(password, "string");
13058+
}
13059+
13060+
13061+
let localVarUseFormData = false;
13062+
let fileData = null;
13063+
let localVarRequestOptions: localVarRequest.Options = {
13064+
method: 'POST',
13065+
qs: localVarQueryParameters,
13066+
headers: localVarHeaderParams,
13067+
uri: localVarPath,
13068+
useQuerystring: this._useQuerystring,
13069+
json: true,
13070+
};
13071+
13072+
if (Object.keys(localVarFormParams).length) {
13073+
if (localVarUseFormData) {
13074+
(<any>localVarRequestOptions).formData = localVarFormParams;
13075+
} else {
13076+
localVarRequestOptions.form = localVarFormParams;
13077+
}
13078+
}
13079+
const response = await invokeApiMethod(localVarRequestOptions, this.configuration, false, fileData);
13080+
const result = ObjectSerializer.deserialize(response.body, "AsposeResponse");
13081+
return Promise.resolve({body: result, response});
13082+
}
13083+
13084+
1300813085
/**
1300913086
*
1301013087
* @summary Add document text footer.

src/requestHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function invokeApiMethodInternal(requestOptions: request.Options, confgura
9595
//headers
9696
sa.set("User-Agent", "pdf nodejs sdk");
9797
sa.set("x-aspose-client", "nodejs sdk");
98-
sa.set("x-aspose-client-version", "25.5.0");
98+
sa.set("x-aspose-client-version", "25.6.0");
9999

100100
if (!requestOptions.headers) {
101101
requestOptions.headers = {};

test/testDocument.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { Direction } from "../src/models/direction";
3232
import { PageMode } from "../src/models/pageMode";
3333
import { PageLayout } from "../src/models/pageLayout";
3434
import { OrganizeDocumentRequest } from "../src/models/organizeDocumentRequest";
35+
import { Rotation } from "../src/models/rotation"
3536

3637
var assert = require('assert');
3738

@@ -226,4 +227,12 @@ describe("Document Tests", () => {
226227
});
227228
});
228229

230+
describe("PostDocumentPagesRotate Test", () => {
231+
it("should return response with code 200", async () => {
232+
const name = "4pages.pdf";
233+
await BaseTest.uploadFile(name);
234+
const result = await BaseTest.getPdfApi().postDocumentPagesRotate(name, Rotation.on90, "2-3", null, BaseTest.remoteTempFolder)
235+
assert.equal(result.response.statusCode, 200);
236+
});
237+
});
229238
});

0 commit comments

Comments
 (0)