Skip to content

Commit 3c383c4

Browse files
authored
Merge pull request #118 from aspose-pdf-cloud/develop
update to 25.3
2 parents 0312063 + 6bd6b60 commit 3c383c4

File tree

9 files changed

+156
-15
lines changed

9 files changed

+156
-15
lines changed

.devcontainer/devcontainer.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "Node.js & TypeScript",
3+
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
4+
"postCreateCommand": "npm install --no-bin-links",
5+
"workspaceFolder": "/SDKs/Node.JS",
6+
"workspaceMount": "source=${localWorkspaceFolder},target=/SDKs/Node.JS,type=bind,consistency=cached",
7+
"customizations": {
8+
"vscode": {
9+
"settings": {
10+
"mochaExplorer.files": "test/*.ts",
11+
"mochaExplorer.require": "ts-node/register",
12+
"mochaExplorer.timeout": 60000
13+
},
14+
"extensions": [
15+
"hbenl.vscode-mocha-test-adapter"
16+
]
17+
}
18+
},
19+
"mounts": [
20+
"source=${localWorkspaceFolder}/../../Settings,target=/Settings,type=bind,consistency=cached"
21+
]
22+
23+
}

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ 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.2
33+
## Enhancements in Version 25.3
3434
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
35+
3536
## Installation
3637

3738
### NPM

UsesCases/Split/splitPages.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
const configParams = {
7+
LOCAL_FOLDER: "C:\\Samples\\",
8+
PDF_DOCUMENT_NAME: "sample.pdf",
9+
};
10+
11+
const pdfApi = new PdfApi(credentials.id, credentials.key);
12+
13+
const pdfSplitter = {
14+
async uploadDocument () {
15+
const fileNamePath = path.join(configParams.LOCAL_FOLDER, configParams.PDF_DOCUMENT_NAME);
16+
const pdfFileData = await fs.readFile(fileNamePath);
17+
await pdfApi.uploadFile(configParams.PDF_DOCUMENT_NAME, pdfFileData);
18+
console.log("Source document uploaded!");
19+
},
20+
21+
async downloadPages (pageHref, index) {
22+
const changedPdfData = await pdfApi.downloadFile(pageHref);
23+
const filePath = path.join(configParams.LOCAL_FOLDER, 'Page_' + index +'_' + pageHref);
24+
await fs.writeFile(filePath, changedPdfData.body);
25+
console.log("Downloaded: " + filePath);
26+
},
27+
28+
async splitPages () {
29+
const resultPages = await pdfApi.postSplitDocument(configParams.PDF_DOCUMENT_NAME, "pdf");
30+
31+
if (resultPages.body.code == 200 && resultPages.body.result.documents) {
32+
resultPages.body.result.documents.forEach(async (docPage, index) => {
33+
await this.downloadPages(docPage.href, index);
34+
})
35+
}
36+
else
37+
console.error("Unexpected error : can't get splitted documents!!!");
38+
},
39+
40+
41+
}
42+
43+
async function main() {
44+
try {
45+
await pdfSplitter.uploadDocument();
46+
await pdfSplitter.splitPages();
47+
} catch (error) {
48+
console.error("Error:", error.message);
49+
}
50+
}
51+
52+
main();

UsesCases/Split/splitRange.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
import { SplitRangePdfOptions } from "../../src/models/splitRangePdfOptions.js";
6+
import { PageRange } from "../../src/models/pageRange.js";
7+
8+
const configParams = {
9+
LOCAL_FOLDER: "C:\\Samples\\",
10+
PDF_DOCUMENT_NAME: "sample.pdf",
11+
};
12+
13+
const range_1 = new PageRange();
14+
range_1.from = 1;
15+
range_1.to = 3;
16+
17+
const range_2 = new PageRange();
18+
range_2.from = 4;
19+
range_2.to = 7;
20+
21+
const splitRangesArray = new SplitRangePdfOptions();
22+
splitRangesArray.pageRanges = [ range_1, range_2 ];
23+
24+
const pdfApi = new PdfApi(credentials.id, credentials.key);
25+
26+
const pdfSplitter = {
27+
async uploadDocument () {
28+
const fileNamePath = path.join(configParams.LOCAL_FOLDER, configParams.PDF_DOCUMENT_NAME);
29+
const pdfFileData = await fs.readFile(fileNamePath);
30+
await pdfApi.uploadFile(configParams.PDF_DOCUMENT_NAME, pdfFileData);
31+
console.log("Source document uploaded!");
32+
},
33+
34+
async downloadPages (pageHref, index) {
35+
const changedPdfData = await pdfApi.downloadFile(pageHref);
36+
const filePath = path.join(configParams.LOCAL_FOLDER, 'Page_' + index +'_' + pageHref);
37+
await fs.writeFile(filePath, changedPdfData.body);
38+
console.log("Downloaded: " + filePath);
39+
},
40+
41+
async splitRanges () {
42+
const resultPages = await pdfApi.postSplitRangePdfDocument(configParams.PDF_DOCUMENT_NAME, splitRangesArray);
43+
44+
if (resultPages.body.code == 200 && resultPages.body.result.documents) {
45+
resultPages.body.result.documents.forEach(async (docPage, index) => {
46+
await this.downloadPages(docPage.href, index);
47+
})
48+
}
49+
else
50+
console.error("Unexpected error : can't get splitted documents!!!");
51+
},
52+
53+
54+
}
55+
56+
async function main() {
57+
try {
58+
await pdfSplitter.uploadDocument();
59+
await pdfSplitter.splitRanges();
60+
} catch (error) {
61+
console.error("Error:", error.message);
62+
}
63+
}
64+
65+
main();

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asposepdfcloud",
3-
"version": "25.2.0",
3+
"version": "25.3.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/requestHelper.ts

+1-1
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.2.0");
98+
sa.set("x-aspose-client-version", "25.3.0");
9999

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

test/testImages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ describe("Images Tests", () => {
278278

279279
it("should return response with code 200", async () => {
280280

281-
return BaseTest.getPdfApi().getImagesExtractSvg("Alfa.pdf", pageNumber, null, BaseTest.remoteTempFolder, null)
281+
return BaseTest.getPdfApi().getImagesExtractSvg("alfa.pdf", pageNumber, null, BaseTest.remoteTempFolder, null)
282282
.then((result) => {
283283
assert.equal(result.response.statusCode, 200);
284284
assert.equal(13, result.body.list.length);

typings.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{
2-
"ambientDependencies": {
3-
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
4-
"node": "registry:dt/node#4.0.0+20160423143914"
5-
},
6-
"dependencies": {
7-
"bluebird": "registry:npm/bluebird#3.3.4+20160515010139",
8-
"request": "registry:npm/request#2.69.0+20160304121250"
9-
}
1+
{
2+
"ambientDependencies": {
3+
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
4+
"node": "registry:dt/node#4.0.0+20160423143914"
5+
},
6+
"dependencies": {
7+
"bluebird": "registry:npm/bluebird#3.3.4+20160515010139",
8+
"request": "registry:npm/request#2.69.0+20160304121250"
9+
}
1010
}

0 commit comments

Comments
 (0)