-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConverter.js
40 lines (33 loc) · 1.29 KB
/
Converter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Reader = require("./modules/Reader.js")
const Processor = require("./modules/Processor.js")
const Table = require("./modules/Table.js")
const HtmlParser = require("./modules/HtmlParser.js")
const Writer = require("./modules/Writer.js")
const PdfWriter = require("./modules/PdfWriter.js")
class Converter {
async ProcessingToHTML(filePath) {
const reader = new Reader()
const data = reader.Read(filePath)
if (data) {
const processedData = Processor.Process(data)
const users = new Table(processedData)
const processedHtml = await HtmlParser.Parse(users)
return processedHtml
}
process.exit()
}
async HTMLConverter(filePath, destinationPath) {
const processedHtml = await this.ProcessingToHTML(filePath)
const writer = new Writer()
writer.Write(destinationPath, processedHtml)
}
async PDFConverter(filePath, destinationPath) {
const processedHtml = await this.ProcessingToHTML(filePath)
PdfWriter.WritePDF(destinationPath, processedHtml)
}
async HTMLAndPDFConverter(filePath, destinationPath) {
await this.HTMLConverter(filePath, destinationPath)
await this.PDFConverter(filePath, destinationPath)
}
}
module.exports = Converter