Skip to content

Commit 4f703f6

Browse files
authored
Merge pull request #90 from aspose-pdf-cloud/develop
update to 24.3
2 parents bba6e01 + 7fbed66 commit 4f703f6

File tree

8 files changed

+50
-26
lines changed

8 files changed

+50
-26
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ 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 24.2
34-
- Memory leak when converting PDF to DOCX.
33+
## Enhancements in Version 24.3
3534
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
3635

3736
## Installation
@@ -44,7 +43,6 @@ From the command line:
4443
$ npm install asposepdfcloud --save
4544
```
4645
## Get PDF Page Annotations in Node.Js
47-
4846
```js
4947
// Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).
5048
const pdfApi = new PdfApi("MY_CLIENT_ID", "MY_CLIENT_SECRET");
@@ -60,6 +58,11 @@ $ npm install asposepdfcloud --save
6058
});
6159
```
6260

61+
## SelfHost Aspose.PDF Cloud
62+
Create *PdfApi* object with one **baseUrl** parameter:
63+
```js
64+
const pdfApi = new PdfApi("MY_SELFHOST_URL");
65+
```
6366

6467
## Unit Tests
6568
Aspose PDF SDK includes a suite of unit tests within the "test" subdirectory. These Unit Tests also serves as examples of how to use the Aspose PDF SDK.

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": "24.2.0",
3+
"version": "24.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/api/api.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -327,17 +327,23 @@ export class PdfApi {
327327
*/
328328
public configuration: Configuration;
329329

330+
/**
331+
* @param baseUrl SelfHost Base api Url.
332+
*/
333+
constructor(baseUrl: string);
334+
330335
/**
331336
* @param appSID App SID.
332337
* @param appKey App key.
333-
* @param baseUrl Base api Url.
334338
*/
335-
constructor(appSID: string, appKey: string, baseUrl?: string) {
336-
if (baseUrl === null || baseUrl === undefined)
337-
{
338-
baseUrl = defaultBasePath;
339-
}
340-
this.configuration = new Configuration(appSID, appKey, baseUrl);
339+
constructor(appSID: string, appKey: string);
340+
341+
constructor(...arr: string[]){
342+
if (arr.length === 1) {
343+
this.configuration = new Configuration(true, "", "", arr[0]);
344+
} else if (arr.length === 2) {
345+
this.configuration = new Configuration(false, arr[0], arr[1], defaultBasePath);
346+
}
341347
}
342348

343349
set useQuerystring(value: boolean) {

src/auth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright (c) 2023 Aspose.PDF Cloud
3+
* Copyright (c) 2024 Aspose.PDF Cloud
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
66
* in the Software without restriction, including without limitation the rights

src/configuration.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright (c) 2023 Aspose.PDF Cloud
3+
* Copyright (c) 2024 Aspose.PDF Cloud
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
66
* in the Software without restriction, including without limitation the rights
@@ -25,6 +25,11 @@ import { IAuthentication, OAuth } from "./auth";
2525
* Pdf API configuration
2626
*/
2727
export class Configuration {
28+
/**
29+
* SelfHost.
30+
*/
31+
public selfHost: boolean;
32+
2833
/**
2934
* Authentication.
3035
*/
@@ -50,15 +55,14 @@ export class Configuration {
5055
*/
5156
public debugMode: boolean;
5257

53-
constructor(appSID: string, appKey: string, baseUrl?: string, debugMode?: boolean) {
58+
constructor(selfHost: boolean, appSID: string, appKey: string, baseUrl?: string, debugMode?: boolean) {
5459
if (baseUrl) {
5560
this.baseUrl = baseUrl;
5661
}
57-
62+
this.selfHost = selfHost;
5863
this.appSID = appSID;
5964
this.appKey = appKey;
6065
this.debugMode = debugMode;
61-
6266
this.authentication = new OAuth() as IAuthentication;
6367
}
6468

src/requestHelper.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright (c) 2023 Aspose.PDF Cloud
3+
* Copyright (c) 2024 Aspose.PDF Cloud
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
66
* in the Software without restriction, including without limitation the rights
@@ -72,9 +72,11 @@ async function invokeApiMethodInternal(requestOptions: request.Options, confgura
7272
let sa = superagent(requestOptions.method, requestOptions["uri"]);
7373

7474
const auth = confguration.authentication;
75-
if (!notApplyAuthToRequest) {
76-
await auth.applyToRequest(requestOptions, confguration);
77-
}
75+
if (!confguration.selfHost) {
76+
if (!notApplyAuthToRequest) {
77+
await auth.applyToRequest(requestOptions, confguration);
78+
}
79+
}
7880

7981
if (requestOptions.form) {
8082
sa.type('form');
@@ -93,14 +95,16 @@ async function invokeApiMethodInternal(requestOptions: request.Options, confgura
9395
//headers
9496
sa.set("User-Agent", "pdf nodejs sdk");
9597
sa.set("x-aspose-client", "nodejs sdk");
96-
sa.set("x-aspose-client-version", "24.2.0");
98+
sa.set("x-aspose-client-version", "24.3.0");
9799

98100
if (!requestOptions.headers) {
99101
requestOptions.headers = {};
100102
}
101103

102-
if (!notApplyAuthToRequest) {
103-
sa.set("Authorization", requestOptions.headers.Authorization);
104+
if (!confguration.selfHost) {
105+
if (!notApplyAuthToRequest) {
106+
sa.set("Authorization", requestOptions.headers.Authorization);
107+
}
104108
}
105109

106110
if (requestOptions.json){

test/baseTestPdfApi.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ export function getPdfApi() {
3838
if (!pdfApi) {
3939
let servercreds_json = fs.readFileSync('../../Settings/servercreds.json', 'utf8')
4040
let creds = JSON.parse(servercreds_json)
41-
pdfApi = new PdfApi(creds.AppSID, creds.AppKey, creds.ProductUri);
41+
if (!creds.SelfHost) {
42+
creds.SelfHost = false
43+
}
44+
if (creds.SelfHost){
45+
pdfApi = new PdfApi(creds.ProductUri);
46+
} else {
47+
pdfApi = new PdfApi(creds.AppSID, creds.AppKey);
48+
}
4249
pdfApi.configuration.debugMode = true;
4350
}
4451
return pdfApi;

0 commit comments

Comments
 (0)