Skip to content

Commit 9daeeb9

Browse files
authored
Merge pull request #99 from aspose-pdf-cloud/develop
update to 24.11
2 parents da94d79 + 984d909 commit 9daeeb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2513
-201
lines changed

Examples/deleteImage.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { PdfApi } = require("asposepdfcloud");
2+
const fs = require("fs");
3+
4+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
5+
6+
// The document name.
7+
const fileName = "PdfWithImages2.pdf";
8+
// Use default storage.
9+
const storage = null;
10+
// Set document folder.
11+
const folder = "Documents";
12+
// Set extracted image folder.
13+
const destFolder = "testOutput";
14+
15+
async function main()
16+
{
17+
// Read document images.
18+
const result = await api.getImages(fileName, 1, null, null);
19+
const imageId = result.body.images.list[0].id;
20+
// Swagger method definition available at
21+
// https://reference.aspose.cloud/pdf/#/Images/DeleteImage
22+
// Delete image from document page.
23+
const response = await api.deleteImage(fileName, imageId, storage, folder);
24+
console.log(response.body.status);
25+
}
26+
27+
main();

Examples/getImage.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const { PdfApi } = require("asposepdfcloud");
2+
const fs = require("fs");
3+
4+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
5+
6+
// The document name.
7+
const fileName = "PdfWithImages2.pdf";
8+
// Use default storage.
9+
const storage = null;
10+
// Set document folder.
11+
const folder = "Documents";
12+
// Set extracted image folder.
13+
const destFolder = "testOutput";
14+
15+
async function main()
16+
{
17+
// Read document images.
18+
const imagesResult = await api.getImages(fileName, 1, null, null);
19+
const imageId = imagesResult.body.images.list[0].id;
20+
// Swagger method definition available at
21+
// https://reference.aspose.cloud/pdf/#/Images/DeleteImage
22+
// Delete image from document page.
23+
const result = await api.getImage(fileName, imageId, storage, folder);
24+
// todo: parse response
25+
console.log(result.body.status);
26+
}
27+
28+
main();

Examples/getImageExtractAsGif.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const { PdfApi } = require("asposepdfcloud");
2+
const fs = require("fs");
3+
4+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
5+
6+
// The document name.
7+
const fileName = "PdfWithImages2.pdf";
8+
// Use default storage.
9+
const storage = null;
10+
// Width of coverted image.
11+
const width = 100;
12+
// Heigth of coverted image.
13+
const heigth = 100;
14+
// Set document folder.
15+
const folder = "Documents";
16+
// Set extracted image folder.
17+
const destFolder = "testOutput";
18+
19+
async function main()
20+
{
21+
// Read document images.
22+
const result = await api.getImages(fileName, 1, null, null);
23+
const imageId = result.body.images.list[0].id;
24+
// Swagger method definition available at
25+
// https://reference.aspose.cloud/pdf/#/Images/GetImageExtractAsJpeg
26+
// Extract document image in PNG format.
27+
const response = await api.getImageExtractAsGif(fileName, imageId, width, heigth, storage, folder);
28+
if (response.response.statusCode == 200)
29+
{
30+
console.log("OK");
31+
// Write extracted image on disk.
32+
fs.writeFileSync(destFolder + "/" + fileName + ".gif", response.body);
33+
}
34+
}
35+
36+
main();

Examples/getImageExtractAsJpeg.js

+31-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
const { PdfApi } = require("asposepdfcloud");
2-
const { PdfAType } = require("asposepdfcloud/src/models/fieldType");
2+
const fs = require("fs");
33

4+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
45

6+
// The document name.
7+
const fileName = "PdfWithImages2.pdf";
8+
// Use default storage.
9+
const storage = null;
10+
// Width of coverted image.
11+
const width = 100;
12+
// Heigth of coverted image.
13+
const heigth = 100;
14+
// Set document folder.
15+
const folder = "Documents";
16+
// Set extracted image folder.
17+
const destFolder = "testOutput";
518

6-
pdfApi = new PdfApi("XXXX", "XXXXXXX")
19+
async function main()
20+
{
21+
// Read document images.
22+
const result = await api.getImages(fileName, 1, null, null);
23+
const imageId = result.body.images.list[0].id;
24+
// Swagger method definition available at
25+
// https://reference.aspose.cloud/pdf/#/Images/GetImageExtractAsJpeg
26+
// Extract document image in PNG format.
27+
const response = await api.getImageExtractAsJpeg(fileName, imageId, width, heigth, storage, folder);
28+
if (response.response.statusCode == 200)
29+
{
30+
console.log("OK");
31+
// Write extracted image on disk.
32+
fs.writeFileSync(destFolder + "/" + fileName + ".jpeg", response.body);
33+
}
34+
}
735

8-
console.log('running example');
9-
10-
const result = await pdfApi.getImages("PdfWithImages2.pdf", 1, null, null);
11-
imageId = result.body.images.list[0].id;
12-
13-
pdfApi.putImageExtractAsJpeg("PdfWithImages2.pdf", imageId, null, null, null, null, null)
14-
.then((result) => {
15-
console.log(result.response);
16-
});
36+
main();

Examples/getImageExtractAsPng.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const { PdfApi } = require("asposepdfcloud");
2+
const fs = require("fs");
3+
4+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
5+
6+
// The document name.
7+
const fileName = "PdfWithImages2.pdf";
8+
// Use default storage.
9+
const storage = null;
10+
// Width of coverted image.
11+
const width = 100;
12+
// Heigth of coverted image.
13+
const heigth = 100;
14+
// Set document folder.
15+
const folder = "Documents";
16+
// Set extracted image folder.
17+
const destFolder = "testOutput";
18+
19+
async function main()
20+
{
21+
// Read document images.
22+
const result = await api.getImages(fileName, 1, null, null);
23+
const imageId = result.body.images.list[0].id;
24+
// Swagger method definition available at
25+
// https://reference.aspose.cloud/pdf/#/Images/GetImageExtractAsPng
26+
// Extract document image in PNG format.
27+
const response = await api.getImageExtractAsPng(fileName, imageId, width, heigth, storage, folder);
28+
if (response.response.statusCode == 200)
29+
{
30+
console.log("OK");
31+
// Write extracted image on disk.
32+
fs.writeFileSync(destFolder + "/" + fileName + ".png", response.body);
33+
}
34+
}
35+
36+
main();

Examples/getImageExtractAsTiff.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const { PdfApi } = require("asposepdfcloud");
2+
const fs = require("fs");
3+
4+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
5+
6+
// The document name.
7+
const fileName = "PdfWithImages2.pdf";
8+
// Use default storage.
9+
const storage = null;
10+
// Width of coverted image.
11+
const width = 100;
12+
// Heigth of coverted image.
13+
const heigth = 100;
14+
// Set document folder.
15+
const folder = "Documents";
16+
// Set extracted image folder.
17+
const destFolder = "testOutput";
18+
19+
async function main()
20+
{
21+
// Read document images.
22+
const result = await api.getImages(fileName, 1, null, null);
23+
const imageId = result.body.images.list[0].id;
24+
// Swagger method definition available at
25+
// https://reference.aspose.cloud/pdf/#/Images/GetImageExtractAsJpeg
26+
// Extract document image in PNG format.
27+
const response = await api.getImageExtractAsTiff(fileName, imageId, width, heigth, storage, folder);
28+
if (response.response.statusCode == 200)
29+
{
30+
console.log("OK");
31+
// Write extracted image on disk.
32+
fs.writeFileSync(destFolder + "/" + fileName + ".tiff", response.body);
33+
}
34+
}
35+
36+
main();

Examples/getImages.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
const { PdfApi } = require("asposepdfcloud");
2-
const { PdfAType } = require("asposepdfcloud/src/models/freeTextAnnotation");
32

3+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
44

5+
// The document name.
6+
const fileName = "PdfWithImages2.pdf";
7+
// Use default storage.
8+
const storage = null;
9+
// Set document folder.
10+
const folder = "Documents";
511

6-
pdfApi = new PdfApi("XXXX", "XXXXXXX")
12+
async function main()
13+
{
14+
// Swagger method definition available at
15+
// https://reference.aspose.cloud/pdf/#/Images/GetImages
16+
// Read document images.
17+
const result = await api.getImages(fileName, 1, storage, folder);
18+
console.log(result.body.status);
19+
}
720

8-
console.log('running example');
9-
10-
pdfApi.getImages("PdfWithImages2.pdf", 1, null, null);
11-
const imageId = result.body.images.list[0].id;
12-
13-
pdfApi.getImage("PdfWithImages2.pdf", imageId, null, null)
14-
.then((result) => {
15-
console.log(result.response);
16-
});
21+
main();

Examples/getPageConvertToPng.js

+32-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
const { PdfApi } = require("asposepdfcloud");
2-
const { PdfAType } = require("asposepdfcloud/src/models/movieAnnotation");
2+
const fs = require("fs");
33

4+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
45

6+
// Set the document name.
7+
const fileName = "4pages.pdf";
8+
// Set the page number.
9+
const pageNumber = 1;
10+
// Set the width of coverted image.
11+
const width = (595 / 2) | 0;
12+
// Set the heigth of coverted image.
13+
const heigth = (842 / 2) | 0;
14+
// Use default storage.
15+
const storage = null;
16+
// Set document folder.
17+
const folder = "Documents";
18+
// Set no password.
19+
const password = null;
20+
// Set an extracted image folder.
21+
const destFolder = "testOutput";
522

6-
pdfApi = new PdfApi("XXXX", "XXXXXXX")
23+
async function main()
24+
{
25+
// Swagger method definition available at
26+
// https://reference.aspose.cloud/pdf/#/Pages/GetPageConvertToPng
27+
// Convert document page to Png image and return resulting file in response..
28+
const response = await api.getPageConvertToPng(fileName, pageNumber, width, heigth, folder, storage, password);
29+
if (response.response.statusCode == 200)
30+
{
31+
console.log("OK");
32+
// Write extracted image on disk.
33+
fs.writeFileSync(destFolder + "/" + fileName + ".png", response.body);
34+
}
35+
}
736

8-
console.log('running example');
9-
10-
11-
12-
pdfApi.getPageConvertToPng("4pages.pdf", 1, null, null, null)
13-
.then((result) => {
14-
console.log(result.response);
15-
});
37+
main();

Examples/getPageText.js

+44-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
11
const { PdfApi } = require("asposepdfcloud");
2-
const { PdfAType } = require("asposepdfcloud/src/models/stamp");
32

3+
const api = new PdfApi("http://172.17.0.1:5000/v3.0");
44

5-
pdfApi = new PdfApi("XXXX", "XXXXXXX")
6-
7-
console.log('running example');
8-
const name = "4pages.pdf";
9-
const x = 0;
10-
const y = 0;
11-
const width = 0;
12-
const height = 0;
5+
// Set the document name.
6+
const fileName = "4pages.pdf";
7+
// Set the page number.
138
const pageNumber = 1;
9+
// Set the X-coordinate of lower-left corner.
10+
const llx = 0;
11+
// Set an Y-coordinate of lower-left corner.
12+
const lly = 0;
13+
// Set the X-coordinate of upper-right corner.
14+
const urx = 0;
15+
// Set an Y-coordinate of upper-right corner.
16+
const ury = 0;
17+
// Set list of formats for search.
1418
const format = ["First Page", "Second Page"];
19+
// Set formats are specified as a regular expression.
20+
const regex = null;
21+
// Set split result fragments (default is true).
22+
const splitRects = true;
23+
// Use default storage.
24+
const storage = null;
25+
// Set document folder.
26+
const folder = "Documents";
27+
28+
async function main()
29+
{
30+
// Swagger method definition available at
31+
// https://reference.aspose.cloud/pdf/#/Text/GetPageText
32+
// Read page text items.
33+
const result = await api.getPageText(
34+
fileName,
35+
pageNumber,
36+
llx,
37+
lly,
38+
urx,
39+
ury,
40+
format,
41+
regex,
42+
splitRects,
43+
folder,
44+
storage);
45+
46+
// todo: parse response
47+
console.log(result.body.status);
48+
}
1549

16-
pdfApi.getPageText(name, pageNumber, x, y, width, height, format, null, null, null)
17-
.then((result) => {
18-
console.log(result.response);
19-
});
50+
main();

0 commit comments

Comments
 (0)