Skip to content
Permalink
f2e37868de
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
37 lines (34 sloc) 1.06 KB
/* eslint-disable no-magic-numbers */
/* eslint-disable max-lines-per-function */
'use strict'
const pdf = require('/home/cc/Documents/340CT_Project/node_modules/pdf/lib/pdf').pdf
const fs = require('fs')
module.exports = class Order {
createPDF(data) {
console.log('data = ', data)
const doc = new pdf()
doc.text(20, 20, 'Menu')
doc.text(20, 30, 'Name')
doc.text(100, 30, 'Type')
doc.text(140, 30, 'Price')
let line = 40
for(let i = 0; i< data.itemName.length; i++) {
doc.text(20, line, data.itemName[i])
doc.text(100, line, data.itemType[i])
doc.text(140, line,${data.itemPrice[i]}`)
line = line + 10
}
doc.setProperties({
title: 'Menu',
subject: 'Items in the current Menu',
author: 'User',
keywords: 'Menu, Restaurant, Price,',
creator: 'User'})
doc.addPage()
const fileName = `testFile${new Date().getSeconds()}.pdf`
// eslint-disable-next-line handle-callback-err
fs.writeFile(fileName, doc.output(), (err, data) => {
console.log(`${fileName} was created! great success!`)
})
}
}