|
| 1 | +import path from 'node:path'; |
| 2 | +import { pdfComparesHelper, pdfApi } from "../Compares/comparesHelper.js"; |
| 3 | + |
| 4 | +export const configParams = { |
| 5 | + LOCAL_FOLDER: "C:\\Samples\\", |
| 6 | + REMOTE_FOLDER: "Your_Temp_Pdf_Cloud", |
| 7 | + PDF_DOCUMENT_1: "sample_compare_1.pdf", |
| 8 | + PDF_DOCUMENT_2: "sample_compare_2.pdf", |
| 9 | + PDF_OUTPUT: "output_compare.pdf", |
| 10 | + REMOTE_FOLDER: "Your_Temp_Pdf_Cloud", |
| 11 | +}; |
| 12 | + |
| 13 | +export const pdfCompares = { |
| 14 | + async comparePdfDocuments(document1, document2, output_document) { |
| 15 | + await pdfComparesHelper.uploadFile(document1, configParams.LOCAL_FOLDER, configParams.REMOTE_FOLDER); |
| 16 | + await pdfComparesHelper.uploadFile(document2, configParams.LOCAL_FOLDER, configParams.REMOTE_FOLDER); |
| 17 | + |
| 18 | + const remotePdf1 = path.join(configParams.REMOTE_FOLDER, document1); |
| 19 | + const remotePdf2 = path.join(configParams.REMOTE_FOLDER, document2); |
| 20 | + var remotePdfOut = path.join(configParams.REMOTE_FOLDER, output_document); |
| 21 | + |
| 22 | + const response = await pdfApi.postComparePdf(remotePdf1, remotePdf2, remotePdfOut); |
| 23 | + |
| 24 | + if (response.body.code != 200) { |
| 25 | + console.log("Unexpected error!"); |
| 26 | + } |
| 27 | + else{ |
| 28 | + console.log("Compare was successful!y finished in '" + output_document + "' file."); |
| 29 | + await pdfComparesHelper.downloadResult(output_document, configParams.LOCAL_FOLDER, configParams.REMOTE_FOLDER); |
| 30 | + } |
| 31 | + |
| 32 | + } |
| 33 | + |
| 34 | +}; |
0 commit comments