add addImageToWord

master
shoaib 4 years ago
parent f769911540
commit 2fcc9c97f2
  1. 1
      package.json
  2. 5
      services/user.js
  3. 16
      tools/addImageToWord.js
  4. 2
      tools/docxtemp.js

@ -6,6 +6,7 @@
"start": "node ./bin/www"
},
"dependencies": {
"child-process-promise": "^2.2.1",
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"docxtemplater": "^3.21.1",

@ -3,6 +3,7 @@ const jalali = require("jalali-moment");
const persianjs = require('persianjs')
const docxTemp = require('../tools/docxtemp')
const imageResizer = require('../tools/imageResizer')
const addImageToWord = require('../tools/addImageToWord')
let methods = {}
@ -85,9 +86,9 @@ methods.completeForm =(userId)=>{
return docxTemp(userInfo, userInfo.fileName)
}).then(link=>{
}).then(docxFileName=>{
resolve(link)
addImageToWord(docxFileName, userInfo.fileName + '.png')
}).catch(err => {
if (err.eText) {

@ -0,0 +1,16 @@
const exec = require('child-process-promise').exec;
module.exports = function (docxFile, image){
return new Promise ((resolve, reject)=>{
exec('mkdir word/media')
.then(function (result) {
var stdout = result.stdout;
var stderr = result.stderr;
console.log('stdout: ', stdout);
console.log('stderr: ', stderr);
})
.catch(function (err) {
console.error('ERROR: ', err);
});
}
)}

@ -107,7 +107,7 @@ module.exports = function (templateInfo, fileName) {
type: 'nodebuffer'
});
fs.writeFileSync(path.resolve(__dirname, `../public/files/${templateInfo.firstName}-${templateInfo.lastName}-${fileName}`), buf);
resolve(`http://localhost:3000/users/download/${templateInfo.firstName}-${templateInfo.lastName}-${fileName}`)
resolve(`${templateInfo.firstName}-${templateInfo.lastName}-${fileName}`)
.catch(err => {
reject({

Loading…
Cancel
Save