Skip to content

Commit 7187a61

Browse files
authored
Merge pull request #125 from aspose-pdf-cloud/develop
update to 25.4
2 parents 3c383c4 + 18addea commit 7187a61

14 files changed

+553
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +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.3
33+
## Enhancements in Version 25.4
34+
- Add method for adding Stamp per page in batch.
3435
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
3536

3637
## Installation
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import credentials from "../../../Credentials/credentials.json" with { type: "json" }; // json-file in this format: { "id": "*****", "key": "*******" }
2+
import fs from 'node:fs/promises';
3+
import path from 'node:path';
4+
import { PdfApi } from "../../src/api/api.js";
5+
6+
const configParams = {
7+
LOCAL_FOLDER: "C:\\Samples\\",
8+
PDF_DOCUMENT_NAME: "sample_encrypted.pdf",
9+
LOCAL_RESULT_DOCUMENT_NAME: "output_sample.pdf",
10+
DOCUMENT_PASSWORD: "Owner-Password"
11+
};
12+
13+
const pdfApi = new PdfApi(credentials.id, credentials.key);
14+
15+
const pdfEncoder = {
16+
async uploadDocument () {
17+
const fileNamePath = path.join(configParams.LOCAL_FOLDER, configParams.PDF_DOCUMENT_NAME);
18+
const pdfFileData = await fs.readFile(fileNamePath);
19+
await pdfApi.uploadFile(configParams.PDF_DOCUMENT_NAME, pdfFileData)
20+
.then(() => console.log("File: '" + configParams.PDF_DOCUMENT_NAME +"' successfully uploaded."));
21+
},
22+
23+
async downloadResult() {
24+
const changedPdfData = await pdfApi.downloadFile(configParams.PDF_DOCUMENT_NAME);
25+
const filePath = path.join(configParams.LOCAL_FOLDER, configParams.LOCAL_RESULT_DOCUMENT_NAME);
26+
await fs.writeFile(filePath, changedPdfData.body);
27+
console.log("Downloaded: " + filePath);
28+
},
29+
30+
async decrypt_document() {
31+
const password_encoded = btoa(configParams.DOCUMENT_PASSWORD)
32+
33+
const response = await pdfApi.postDecryptDocumentInStorage(configParams.PDF_DOCUMENT_NAME, password_encoded);
34+
35+
if (response.body.code == 200)
36+
console.log("decrypt_document(): Document #'" + configParams.PDF_DOCUMENT_NAME + "' successfully decrypted.")
37+
else
38+
throw new Error("decrypt_document(): Failed to decrypt document #'" + configParams.PDF_DOCUMENT_NAME + "'. Response code: {" + response.code + "}")
39+
},
40+
41+
}
42+
43+
async function main() {
44+
try {
45+
await pdfEncoder.uploadDocument();
46+
await pdfEncoder.decrypt_document();
47+
await pdfEncoder.downloadResult();
48+
} catch (error) {
49+
console.error("Error:", error.message);
50+
}
51+
}
52+
53+
main();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import credentials from "../../../Credentials/credentials.json" with { type: "json" }; // json-file in this format: { "id": "*****", "key": "*******" }
2+
import fs from 'node:fs/promises';
3+
import path from 'node:path';
4+
import { PdfApi } from "../../src/api/api.js";
5+
import { CryptoAlgorithm } from "../../src/models/cryptoAlgorithm.js";
6+
7+
const configParams = {
8+
LOCAL_FOLDER: "C:\\Samples\\",
9+
PDF_DOCUMENT_NAME: "sample.pdf",
10+
LOCAL_RESULT_DOCUMENT_NAME: "output_sample.pdf",
11+
ENCRYPT_ALGORITHM: CryptoAlgorithm.AESx256,
12+
USER_PASSWORD: "User-Password",
13+
OWNER_PASSWORD: "Owner-Password",
14+
};
15+
16+
const pdfApi = new PdfApi(credentials.id, credentials.key);
17+
18+
const pdfEncoder = {
19+
async uploadDocument () {
20+
const fileNamePath = path.join(configParams.LOCAL_FOLDER, configParams.PDF_DOCUMENT_NAME);
21+
const pdfFileData = await fs.readFile(fileNamePath);
22+
await pdfApi.uploadFile(configParams.PDF_DOCUMENT_NAME, pdfFileData)
23+
.then(() => console.log("File: '" + configParams.PDF_DOCUMENT_NAME +"' successfully uploaded."));
24+
},
25+
26+
async downloadResult() {
27+
const changedPdfData = await pdfApi.downloadFile(configParams.PDF_DOCUMENT_NAME);
28+
const filePath = path.join(configParams.LOCAL_FOLDER, configParams.LOCAL_RESULT_DOCUMENT_NAME);
29+
await fs.writeFile(filePath, changedPdfData.body);
30+
console.log("Downloaded: " + filePath);
31+
},
32+
33+
async encrypt_document() {
34+
const user_password_encoded = btoa(configParams.USER_PASSWORD)
35+
36+
const owner_password_encoded = btoa(configParams.OWNER_PASSWORD)
37+
38+
const response = await pdfApi.postEncryptDocumentInStorage(configParams.PDF_DOCUMENT_NAME, user_password_encoded, owner_password_encoded, configParams.ENCRYPT_ALGORITHM);
39+
40+
if (response.body.code == 200)
41+
console.log("encrypt_document(): Document #'" + configParams.PDF_DOCUMENT_NAME + "' successfully encrypted.")
42+
else
43+
throw new Error("encrypt_document(): Failed to encrypt document #'" + configParams.PDF_DOCUMENT_NAME + "'. Response code: {" + response.code + "}")
44+
},
45+
46+
}
47+
48+
async function main() {
49+
try {
50+
await pdfEncoder.uploadDocument();
51+
await pdfEncoder.encrypt_document();
52+
await pdfEncoder.downloadResult();
53+
} catch (error) {
54+
console.error("Error:", error.message);
55+
}
56+
}
57+
58+
main();

docs/ImageStampPageSpecified.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ImageStampPageSpecified
2+
Represents Pdf stamps.
3+
4+
*Inherited from [ImageStamp](ImageStamp.md)*
5+
## Properties
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
**pageNumber** | **number** | Page number. |
9+
**fileName** | **string** | Gets or sets the file name.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
10+
**width** | **number** | Gets or sets image width. Setting this property allos to scal image horizontally.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
11+
**height** | **number** | Gets or sets image height. Setting this image allows to scale image vertically.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
12+
**verticalAlignment** | [**VerticalAlignment**](VerticalAlignment.md) | Gets or sets vertical alignment of stamp on page.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
13+
**bottomMargin** | **number** | Gets or sets bottom margin of stamp.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
14+
**leftMargin** | **number** | Gets or sets left margin of stamp.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
15+
**topMargin** | **number** | Gets or sets top margin of stamp.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
16+
**rightMargin** | **number** | Gets or sets right margin of stamp.<br />*Inherited from [ImageStamp](ImageStamp.md)* | [optional]
17+
**background** | **boolean** | Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
18+
**horizontalAlignment** | [**HorizontalAlignment**](HorizontalAlignment.md) | Gets or sets Horizontal alignment of stamp on the page. <br />*Inherited from [StampBase](StampBase.md)* | [optional]
19+
**opacity** | **number** | Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
20+
**rotate** | [**Rotation**](Rotation.md) | Sets or gets the rotation of stamp content according Rotation values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property. If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
21+
**rotateAngle** | **number** | Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle. <br />*Inherited from [StampBase](StampBase.md)* | [optional]
22+
**xIndent** | **number** | Horizontal stamp coordinate, starting from the left.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
23+
**yIndent** | **number** | Vertical stamp coordinate, starting from the bottom.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
24+
**zoom** | **number** | Zooming factor of the stamp. Allows to scale stamp.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
25+
**links** | [**Array&lt;Link&gt;**](Link.md) | Link to the document.<br />*Inherited from [LinkElement](LinkElement.md)* | [optional]
26+
27+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[View Source]](../src/models/imageStampPageSpecified.ts)
28+

docs/PdfApi.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,13 @@ Method | HTTP request | Description
209209
*PdfApi* | [**postDocumentImageFooter**](PdfApi.md#postDocumentImageFooter) | **POST** /pdf/\{name}/footer/image | Add document image footer.
210210
*PdfApi* | [**postDocumentImageHeader**](PdfApi.md#postDocumentImageHeader) | **POST** /pdf/\{name}/header/image | Add document image header.
211211
*PdfApi* | [**postDocumentImageStamps**](PdfApi.md#postDocumentImageStamps) | **POST** /pdf/\{name}/stamps/image | Add document pages image stamps.
212+
*PdfApi* | [**postDocumentImageStampsPageSpecified**](PdfApi.md#postDocumentImageStampsPageSpecified) | **POST** /pdf/\{name}/stamps/image/pagespecified | Add document image stamps to specified pages.
212213
*PdfApi* | [**postDocumentPageNumberStamps**](PdfApi.md#postDocumentPageNumberStamps) | **POST** /pdf/\{name}/stamps/pagenumber | Add document page number stamps.
213214
*PdfApi* | [**postDocumentTextFooter**](PdfApi.md#postDocumentTextFooter) | **POST** /pdf/\{name}/footer/text | Add document text footer.
214215
*PdfApi* | [**postDocumentTextHeader**](PdfApi.md#postDocumentTextHeader) | **POST** /pdf/\{name}/header/text | Add document text header.
215216
*PdfApi* | [**postDocumentTextReplace**](PdfApi.md#postDocumentTextReplace) | **POST** /pdf/\{name}/text/replace | Document's replace text method.
216217
*PdfApi* | [**postDocumentTextStamps**](PdfApi.md#postDocumentTextStamps) | **POST** /pdf/\{name}/stamps/text | Add document pages text stamps.
218+
*PdfApi* | [**postDocumentTextStampsPageSpecified**](PdfApi.md#postDocumentTextStampsPageSpecified) | **POST** /pdf/\{name}/stamps/text/pagespecified | Add document text stamps to specified pages.
217219
*PdfApi* | [**postEncryptDocumentInStorage**](PdfApi.md#postEncryptDocumentInStorage) | **POST** /pdf/\{name}/encrypt | Encrypt document in storage.
218220
*PdfApi* | [**postFlattenDocument**](PdfApi.md#postFlattenDocument) | **POST** /pdf/\{name}/flatten | Flatten the document.
219221
*PdfApi* | [**postHtmlToPdf**](PdfApi.md#postHtmlToPdf) | **POST** /pdf/create/html | Convert HTML file (zip archive in request content) to PDF format and return resulting file in response.
@@ -5155,6 +5157,30 @@ Name | Type | Description | Notes
51555157

51565158
[**AsposeResponse**](AsposeResponse.md)
51575159

5160+
### HTTP request headers
5161+
5162+
- **Content-Type**: application/json
5163+
- **Accept**: application/json
5164+
5165+
<a name="postDocumentImageStampsPageSpecified"></a>
5166+
## **postDocumentImageStampsPageSpecified**
5167+
> postDocumentImageStampsPageSpecified(name, stamps, storage, folder, password)
5168+
5169+
Add document image stamps to specified pages.
5170+
5171+
### Parameters
5172+
Name | Type | Description | Notes
5173+
------------- | ------------- | ------------- | -------------
5174+
**name** | **string** | The document name. |
5175+
**stamps** | [**Array&lt;ImageStampPageSpecified&gt;**](ImageStampPageSpecified.md) | The array of stamps. |
5176+
**storage** | **string** | The document storage. | [optional]
5177+
**folder** | **string** | The document folder. | [optional]
5178+
**password** | **string** | Base64 encoded password. | [optional]
5179+
5180+
### Return type
5181+
5182+
[**AsposeResponse**](AsposeResponse.md)
5183+
51585184
### HTTP request headers
51595185

51605186
- **Content-Type**: application/json
@@ -5278,6 +5304,30 @@ Name | Type | Description | Notes
52785304

52795305
[**AsposeResponse**](AsposeResponse.md)
52805306

5307+
### HTTP request headers
5308+
5309+
- **Content-Type**: application/json
5310+
- **Accept**: application/json
5311+
5312+
<a name="postDocumentTextStampsPageSpecified"></a>
5313+
## **postDocumentTextStampsPageSpecified**
5314+
> postDocumentTextStampsPageSpecified(name, stamps, storage, folder, password)
5315+
5316+
Add document text stamps to specified pages.
5317+
5318+
### Parameters
5319+
Name | Type | Description | Notes
5320+
------------- | ------------- | ------------- | -------------
5321+
**name** | **string** | The document name. |
5322+
**stamps** | [**Array&lt;TextStampPageSpecified&gt;**](TextStampPageSpecified.md) | The array of stamps. |
5323+
**storage** | **string** | The document storage. | [optional]
5324+
**folder** | **string** | The document folder. | [optional]
5325+
**password** | **string** | Base64 encoded password. | [optional]
5326+
5327+
### Return type
5328+
5329+
[**AsposeResponse**](AsposeResponse.md)
5330+
52815331
### HTTP request headers
52825332

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

docs/TextStampPageSpecified.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# TextStampPageSpecified
2+
Represents Pdf stamps.
3+
4+
*Inherited from [TextStamp](TextStamp.md)*
5+
## Properties
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
**pageNumber** | **number** | Page number. |
9+
**textAlignment** | [**HorizontalAlignment**](HorizontalAlignment.md) | Alignment of the text inside the stamp.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
10+
**value** | **string** | Gets or sets string value which is used as stamp on the page.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
11+
**textState** | [**TextState**](TextState.md) | Gets text properties of the stamp. See TextState for details.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
12+
**verticalAlignment** | [**VerticalAlignment**](VerticalAlignment.md) | Gets or sets vertical alignment of stamp on page.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
13+
**bottomMargin** | **number** | Gets or sets bottom margin of stamp.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
14+
**leftMargin** | **number** | Gets or sets left margin of stamp.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
15+
**topMargin** | **number** | Gets or sets top margin of stamp.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
16+
**rightMargin** | **number** | Gets or sets right margin of stamp.<br />*Inherited from [TextStamp](TextStamp.md)* | [optional]
17+
**background** | **boolean** | Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
18+
**horizontalAlignment** | [**HorizontalAlignment**](HorizontalAlignment.md) | Gets or sets Horizontal alignment of stamp on the page. <br />*Inherited from [StampBase](StampBase.md)* | [optional]
19+
**opacity** | **number** | Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
20+
**rotate** | [**Rotation**](Rotation.md) | Sets or gets the rotation of stamp content according Rotation values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property. If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
21+
**rotateAngle** | **number** | Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle. <br />*Inherited from [StampBase](StampBase.md)* | [optional]
22+
**xIndent** | **number** | Horizontal stamp coordinate, starting from the left.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
23+
**yIndent** | **number** | Vertical stamp coordinate, starting from the bottom.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
24+
**zoom** | **number** | Zooming factor of the stamp. Allows to scale stamp.<br />*Inherited from [StampBase](StampBase.md)* | [optional]
25+
**links** | [**Array&lt;Link&gt;**](Link.md) | Link to the document.<br />*Inherited from [LinkElement](LinkElement.md)* | [optional]
26+
27+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[View Source]](../src/models/textStampPageSpecified.ts)
28+

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.3.0",
3+
"version": "25.4.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": {

0 commit comments

Comments
 (0)