Skip to content

Commit 22bd881

Browse files
Update replaceTable.js
1 parent e862c9c commit 22bd881

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

UsesCases/Tables/replace/replaceTable.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@
55
// 5. Append new Link Annotation to the document using postPageLinkAnnotations() function
66
// 6. Perform some action after successful addition
77
// All values of variables starting with "YOUR_****" should be replaced by real user values
8-
import credentials from "./credentials.json" with { type: "json" };
8+
9+
import credentials from "../../../../Credentials/credentials.json" with { type: "json" };
910
import fs from 'node:fs/promises';
1011
import path from 'node:path';
11-
import { PdfApi } from "asposepdfcloud";
12-
import { Table } from "asposepdfcloud/src/models/table.js";
13-
import { Cell } from "asposepdfcloud/src/models/cell.js";
14-
import { FontStyles } from "asposepdfcloud/src/models/fontStyles.js";
15-
import { GraphInfo } from "asposepdfcloud/src/models/graphInfo.js";
16-
import { Row } from "asposepdfcloud/src/models/row.js";
17-
import { TextRect } from "asposepdfcloud/src/models/textRect.js";
12+
import { PdfApi } from "../../../src/api/api.js";
13+
import { Table } from "../../../src/models/table.js";
14+
import { Cell } from "../../../src/models/cell.js";
15+
import { FontStyles } from "../../../src/models/fontStyles.js";
16+
import { GraphInfo } from "../../../src/models/graphInfo.js";
17+
import { Row } from "../../../src/models/row.js";
18+
import { TextRect } from "../../../src/models/textRect.js";
1819

1920
const configParams = {
2021
LOCAL_FOLDER: "C:\\Samples\\",
2122
PDF_DOCUMENT_NAME: "sample.pdf",
2223
LOCAL_RESULT_DOCUMENT_NAME: "output_sample.pdf",
23-
PAGE_NUMBER: 2, // Your document page number...
24-
TABLE_ID: "GE5TCOZSGAYCYNRQGUWDINZVFQ3DGMA",
24+
PAGE_NUMBER: 2, // Your document page number...
25+
TABLE_ID: "GE5TCOZSGAYCYNRQGUWDINZVFQ3DGMA", // Your table id...
26+
TABLE_ROWS: 5,
27+
TABLE_COLUMNS: 5,
2528
};
2629

2730
const pdfApi = new PdfApi(credentials.id, credentials.key);
@@ -31,6 +34,7 @@ const pdfTables = {
3134
const fileNamePath = path.join(configParams.LOCAL_FOLDER, configParams.PDF_DOCUMENT_NAME);
3235
const pdfFileData = await fs.readFile(fileNamePath);
3336
await pdfApi.uploadFile(configParams.PDF_DOCUMENT_NAME, pdfFileData);
37+
console.log("File '" + configParams.PDF_DOCUMENT_NAME + "' successfully uploaded!");
3438
},
3539

3640
async downloadResult () {
@@ -41,8 +45,8 @@ const pdfTables = {
4145
},
4246

4347
initTable () {
44-
const numOfCols = 5;
45-
const numOfRows = 5;
48+
const numOfCols = configParams.TABLE_COLUMNS;
49+
const numOfRows = configParams.TABLE_ROWS;
4650

4751
const headerTextState = {
4852
font: "Arial Bold",

0 commit comments

Comments
 (0)