Skip to content

Commit 8d9ac96

Browse files
committed
Updated sources
1 parent d88be87 commit 8d9ac96

File tree

8 files changed

+268
-116
lines changed

8 files changed

+268
-116
lines changed

package-lock.json

Lines changed: 8 additions & 8 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": "groupdocs-viewer-cloud",
3-
"version": "24.2.0",
3+
"version": "24.3.0",
44
"description": "GroupDocs.Viewer Cloud SDK for Node.js",
55
"homepage": "https://products.groupdocs.cloud/viewer",
66
"author": {

src/model.ts

Lines changed: 157 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,95 @@
2222
* SOFTWARE.
2323
*/
2424

25+
export class ApiError {
26+
27+
/**
28+
* Attribute type map
29+
*/
30+
public static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
31+
{
32+
name: "code",
33+
baseName: "code",
34+
type: "string",
35+
},
36+
{
37+
name: "message",
38+
baseName: "message",
39+
type: "string",
40+
},
41+
{
42+
name: "description",
43+
baseName: "description",
44+
type: "string",
45+
},
46+
{
47+
name: "dateTime",
48+
baseName: "dateTime",
49+
type: "Date",
50+
},
51+
{
52+
name: "innerError",
53+
baseName: "innerError",
54+
type: "ApiError",
55+
} ];
56+
57+
/**
58+
* Returns attribute type map
59+
*/
60+
public static getAttributeTypeMap() {
61+
return ApiError.attributeTypeMap;
62+
}
63+
64+
public code: string;
65+
66+
public message: string;
67+
68+
public description: string;
69+
70+
public dateTime: Date;
71+
72+
public innerError: ApiError;
73+
74+
public constructor(init?: Partial<ApiError>) {
75+
76+
Object.assign(this, init);
77+
}
78+
}
79+
80+
export class ApiErrorResponse {
81+
82+
/**
83+
* Attribute type map
84+
*/
85+
public static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
86+
{
87+
name: "requestId",
88+
baseName: "requestId",
89+
type: "string",
90+
},
91+
{
92+
name: "error",
93+
baseName: "error",
94+
type: "ApiError",
95+
} ];
96+
97+
/**
98+
* Returns attribute type map
99+
*/
100+
public static getAttributeTypeMap() {
101+
return ApiErrorResponse.attributeTypeMap;
102+
}
103+
104+
public requestId: string;
105+
106+
public error: ApiError;
107+
108+
public constructor(init?: Partial<ApiErrorResponse>) {
109+
110+
Object.assign(this, init);
111+
}
112+
}
113+
25114
/**
26115
* Provides options for rendering archive files
27116
*/
@@ -1446,6 +1535,21 @@ export class PdfDocumentOptions {
14461535
name: "renderTextAsImage",
14471536
baseName: "renderTextAsImage",
14481537
type: "boolean",
1538+
},
1539+
{
1540+
name: "fixedLayout",
1541+
baseName: "fixedLayout",
1542+
type: "boolean",
1543+
},
1544+
{
1545+
name: "wrapImagesInSvg",
1546+
baseName: "wrapImagesInSvg",
1547+
type: "boolean",
1548+
},
1549+
{
1550+
name: "disableFontLicenseVerifications",
1551+
baseName: "disableFontLicenseVerifications",
1552+
type: "boolean",
14491553
} ];
14501554

14511555
/**
@@ -1485,6 +1589,21 @@ export class PdfDocumentOptions {
14851589
*/
14861590
public renderTextAsImage: boolean;
14871591

1592+
/**
1593+
* Enables rendering the PDF and EPUB documents to HTML with a fixed layout.
1594+
*/
1595+
public fixedLayout: boolean;
1596+
1597+
/**
1598+
* Enables wrapping each image in the output HTML document in SVG tag to improve the output quality.
1599+
*/
1600+
public wrapImagesInSvg: boolean;
1601+
1602+
/**
1603+
* Disables any license restrictions for all fonts in the current XPS/OXPS document.
1604+
*/
1605+
public disableFontLicenseVerifications: boolean;
1606+
14881607
public constructor(init?: Partial<PdfDocumentOptions>) {
14891608

14901609
Object.assign(this, init);
@@ -3440,22 +3559,22 @@ export class PdfOptions extends RenderOptions {
34403559
public pdfOptimizationOptions: PdfOptimizationOptions;
34413560

34423561
/**
3443-
* Max width of an output image in pixels. (When converting single image to HTML only)
3562+
* Max width of an output image in pixels. (When converting single image to PDF only)
34443563
*/
34453564
public imageMaxWidth: number;
34463565

34473566
/**
3448-
* Max height of an output image in pixels. (When converting single image to HTML only)
3567+
* Max height of an output image in pixels. (When converting single image to PDF only)
34493568
*/
34503569
public imageMaxHeight: number;
34513570

34523571
/**
3453-
* The width of the output image in pixels. (When converting single image to HTML only)
3572+
* The width of the output image in pixels. (When converting single image to PDF only)
34543573
*/
34553574
public imageWidth: number;
34563575

34573576
/**
3458-
* The height of an output image in pixels. (When converting single image to HTML only)
3577+
* The height of an output image in pixels. (When converting single image to PDF only)
34593578
*/
34603579
public imageHeight: number;
34613580

@@ -3511,6 +3630,8 @@ const enumsMap = {
35113630
};
35123631

35133632
const typeMap = {
3633+
ApiError,
3634+
ApiErrorResponse,
35143635
ArchiveOptions,
35153636
ArchiveViewInfo,
35163637
AttachmentInfo,
@@ -3943,6 +4064,38 @@ export class StorageExistsRequest {
39434064
}
39444065
}
39454066

4067+
/**
4068+
* Request model for ConvertAndDownload operation.
4069+
*/
4070+
export class ConvertAndDownloadRequest {
4071+
/**
4072+
* Requested conversion format: HTML, JPG, PNG or PDF
4073+
*/
4074+
public format: string;
4075+
4076+
/**
4077+
* Input file to convert
4078+
*/
4079+
public file: Buffer;
4080+
4081+
/**
4082+
* Pages range to render, like \"1,2\" or \"3-5,10\"
4083+
*/
4084+
public pages: string;
4085+
4086+
/**
4087+
* Input document password
4088+
*/
4089+
public password: string;
4090+
4091+
public constructor(format: string, file: Buffer, pages?: string, password?: string) {
4092+
this.format = format;
4093+
this.file = file;
4094+
this.pages = pages;
4095+
this.password = password;
4096+
}
4097+
}
4098+
39464099
/**
39474100
* Request model for CreateView operation.
39484101
*/

src/package_version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
/**
2626
* Package version
2727
*/
28-
export const PackageVersion: string = "24.2.0";
28+
export const PackageVersion: string = "24.3.0";

src/viewer_api.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,50 @@ export class ViewApi {
786786
this.configuration = config;
787787
}
788788

789+
/**
790+
* Converts input document file to format specified
791+
* @param requestObj contains request parameters
792+
*/
793+
public async convertAndDownload(requestObj: model.ConvertAndDownloadRequest): Promise<Buffer> {
794+
if (requestObj === null || requestObj === undefined) {
795+
throw new Error('Required parameter "requestObj" was null or undefined when calling convertAndDownload.');
796+
}
797+
798+
let localVarPath = this.configuration.getServerUrl() + "/viewer/convertAndDownload";
799+
const queryParameters: any = {};
800+
const formParams = new FormData();
801+
802+
// verify required parameter 'requestObj.format' is not null or undefined
803+
if (requestObj.format === null || requestObj.format === undefined) {
804+
throw new Error('Required parameter "requestObj.format" was null or undefined when calling convertAndDownload.');
805+
}
806+
807+
// verify required parameter 'requestObj.file' is not null or undefined
808+
if (requestObj.file === null || requestObj.file === undefined) {
809+
throw new Error('Required parameter "requestObj.file" was null or undefined when calling convertAndDownload.');
810+
}
811+
812+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "format", requestObj.format);
813+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "pages", requestObj.pages);
814+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "password", requestObj.password);
815+
if (requestObj.file !== undefined) {
816+
formParams.append("File", requestObj.file, { filename: "file.name" });
817+
}
818+
819+
const requestOptions: axios.AxiosRequestConfig = {
820+
method: "PUT",
821+
params: queryParameters,
822+
url: localVarPath,
823+
responseType: "arraybuffer",
824+
responseEncoding: null,
825+
data: formParams,
826+
};
827+
828+
const response = await invokeApiMethod(requestOptions, this.configuration);
829+
const result = Serializer.deserialize(response.data, "Buffer");
830+
return Promise.resolve(result);
831+
}
832+
789833
/**
790834
* Render document pages
791835
* @param requestObj contains request parameters
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2003-2024 Aspose Pty Ltd
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
import { expect } from "chai";
26+
import "mocha";
27+
28+
import { ConvertAndDownloadRequest} from "../../src/model";
29+
30+
import * as TestContext from "../test_context";
31+
import { TestFile } from "../test_file";
32+
33+
describe("test_convert_and_download_api", () => {
34+
35+
before(async () => {
36+
});
37+
38+
afterEach(async function() {
39+
});
40+
41+
describe("TestConvertAndDownload", () => {
42+
43+
it("TestConvertAndDownloadJpg", () => {
44+
45+
const api = TestContext.getViewerApi();
46+
var format = "jpg";
47+
let filebuf = TestContext.getTestFileBuffer(TestFile.OnePageDocx);
48+
49+
var request = new ConvertAndDownloadRequest(format, filebuf);
50+
return api.convertAndDownload(request)
51+
.then((result) => {
52+
expect(result.length).greaterThan(0);
53+
});
54+
});
55+
});
56+
});

0 commit comments

Comments
 (0)