8
8
// 8. Perform some action after successful addition
9
9
// All values of variables starting with "YOUR_****" should be replaced by real user values
10
10
11
- import credentials from "../../../Credentials /credentials.json" with { type : "json" } ;
11
+ import credentials from "./credentials.json" with { type : "json" } ;
12
12
import fs from 'node:fs/promises' ;
13
13
import path from 'node:path' ;
14
- import { PdfApi } from "../../src/api/api.js" ;
15
- import { TextHeader } from "../../src/models/textHeader.js" ;
16
- import { TextFooter } from "../../src/models/textFooter.js" ;
17
-
18
- import { HorizontalAlignment } from "../../src/models/horizontalAlignment.js" ;
14
+ import { PdfApi } from "asposepdfcloud" ;
15
+ import { TextFooter } from "asposepdfcloud/src/models/textFooter.js" ;
16
+ import { HorizontalAlignment } from "asposepdfcloud/src/models/horizontalAlignment.js" ;
19
17
20
18
const configParams = {
21
19
LOCAL_FOLDER : "C:\\Samples\\" ,
@@ -27,9 +25,10 @@ const configParams = {
27
25
const pdfApi = new PdfApi ( credentials . id , credentials . key ) ;
28
26
29
27
const pdfHederFooter = {
30
- async uploadFile ( fileName ) {
31
- const pdfFileData = await fs . readFile ( configParams . LOCAL_FOLDER + fileName ) ;
32
- await pdfApi . uploadFile ( fileName , pdfFileData ) ;
28
+ async uploadDocument ( ) {
29
+ const pdfFilePath = path . join ( configParams . LOCAL_FOLDER , configParams . PDF_DOCUMENT_NAME ) ;
30
+ const pdfFileData = await fs . readFile ( pdfFilePath ) ;
31
+ await pdfApi . uploadFile ( configParams . PDF_DOCUMENT_NAME , pdfFileData ) ;
33
32
} ,
34
33
35
34
async downloadResult ( ) {
@@ -39,10 +38,6 @@ const pdfHederFooter = {
39
38
console . log ( "Downloaded: " + filePath ) ;
40
39
} ,
41
40
42
- async uploadDocument ( ) {
43
- await pdfHederFooter . uploadFile ( configParams . PDF_DOCUMENT_NAME ) ;
44
- } ,
45
-
46
41
async adddTextFooter ( ) {
47
42
const textFooter = new TextFooter ( ) ;
48
43
textFooter . background = true ;
@@ -63,4 +58,4 @@ async function main() {
63
58
}
64
59
}
65
60
66
- main ( ) ;
61
+ main ( ) ;
0 commit comments