diff --git a/README.md b/README.md index ac0f463..24250e8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Project setup -1. Install npm +1. Install npm (My npm version is 6.14.15) Please refer to this [guide](https://phoenixnap.com/kb/install-node-js-npm-on-windows). 2. Download this repository / folder @@ -46,6 +46,8 @@ npm install npm run electron:serve ``` +**Note: sometimes all inputs are unresponsive, then you need to click select file from email tab and click cancel.** + ![image](https://user-images.githubusercontent.com/55322546/136893827-ccb22f22-6d89-41fd-b259-80f57e80683c.png) ## App features @@ -57,8 +59,9 @@ npm run electron:serve ![image](https://user-images.githubusercontent.com/55322546/136894958-1703f309-d9d6-47df-8878-c89e8651c637.png) - - Select a csv file, if you wish to, you can change the separator + - Select a csv file, if you wish to, ~~you can change the separator~~ - Select the people whom you wish to email to + - Remember not to select any empty rows at the end if there are any ![image](https://user-images.githubusercontent.com/55322546/136895028-20437009-aba3-4abd-a836-4647eea96497.png) @@ -90,7 +93,12 @@ npm run electron:serve - Sometimes if the pdf is not updating, click any of the slider. - Due to unknown issue, the fonts are kinda above 0, so you must set Y to bigger than 0 to start seeing the words - The words in the file will be replaced with name column as specified in email setting + - You can set align center to true, then the X position will be used as the center of the texts. + - Note: Sometimes the cert will be unresponsive, then you need to drag the X & Y slider and you'll see +the preview being updated.
+ + * This app is made for APAC, but is free to be used & adapted by others. diff --git a/design.json b/design.json index c822ad5..323d18a 100644 --- a/design.json +++ b/design.json @@ -1 +1 @@ -{"counters":{"u_column":3,"u_row":3,"u_content_heading":1,"u_content_image":1,"u_content_text":1},"body":{"rows":[{"cells":[1],"columns":[{"contents":[{"type":"heading","values":{"containerPadding":"10px","headingType":"h1","fontFamily":{"label":"Arial","value":"arial,helvetica,sans-serif"},"fontSize":"22px","textAlign":"left","lineHeight":"140%","linkStyle":{"inherit":true,"linkColor":"#0000ee","linkHoverColor":"#0000ee","linkUnderline":true,"linkHoverUnderline":true},"hideDesktop":false,"_meta":{"htmlID":"u_content_heading_1","htmlClassNames":"u_content_heading"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true,"text":"Hello brainy girl"}}],"values":{"backgroundColor":"","padding":"0px","border":{},"_meta":{"htmlID":"u_column_1","htmlClassNames":"u_column"}}}],"values":{"displayCondition":null,"columns":false,"backgroundColor":"","columnsBackgroundColor":"","backgroundImage":{"url":"","fullWidth":true,"repeat":false,"center":true,"cover":false},"padding":"0px","hideDesktop":false,"_meta":{"htmlID":"u_row_1","htmlClassNames":"u_row"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true}},{"cells":[1],"columns":[{"contents":[{"type":"text","values":{"containerPadding":"10px","textAlign":"left","lineHeight":"140%","linkStyle":{"inherit":true,"linkColor":"#0000ee","linkHoverColor":"#0000ee","linkUnderline":true,"linkHoverUnderline":true},"hideDesktop":false,"_meta":{"htmlID":"u_content_text_1","htmlClassNames":"u_content_text"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true,"text":"

Hi :D

"}}],"values":{"backgroundColor":"","padding":"0px","border":{},"_meta":{"htmlID":"u_column_2","htmlClassNames":"u_column"}}}],"values":{"displayCondition":null,"columns":false,"backgroundColor":"","columnsBackgroundColor":"","backgroundImage":{"url":"","fullWidth":true,"repeat":false,"center":true,"cover":false},"padding":"0px","hideDesktop":false,"_meta":{"htmlID":"u_row_2","htmlClassNames":"u_row"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true}}],"values":{"textColor":"#000000","backgroundColor":"#e7e7e7","backgroundImage":{"url":"","fullWidth":true,"repeat":false,"center":true,"cover":false},"contentWidth":"900px","contentAlign":"center","fontFamily":{"label":"Arial","value":"arial,helvetica,sans-serif"},"preheaderText":"","linkStyle":{"body":true,"linkColor":"#0000ee","linkHoverColor":"#0000ee","linkUnderline":true,"linkHoverUnderline":true},"_meta":{"htmlID":"u_body","htmlClassNames":"u_body"}}},"schemaVersion":6} \ No newline at end of file +{"counters":{"u_column":1,"u_row":1,"u_content_text":2,"u_content_image":1},"body":{"id":"jKajbI6ZU7","rows":[{"id":"6MxIU7ekZa","cells":[1],"columns":[{"id":"5jNH9aVH7d","contents":[{"id":"0Oaot5ExzM","type":"text","values":{"containerPadding":"10px","textAlign":"left","lineHeight":"140%","linkStyle":{"inherit":true,"linkColor":"#0000ee","linkHoverColor":"#0000ee","linkUnderline":true,"linkHoverUnderline":true},"hideDesktop":false,"displayCondition":null,"_meta":{"htmlID":"u_content_text_1","htmlClassNames":"u_content_text"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true,"text":"

Hi ^*name*^,

\n

 

\n

Thank you for your interest in becoming a part of APAC committee. 

\n

 

\n

We regret to inform you that your profile does not match the requirements we are looking for at this time so your application was REJECTED. We appreciate you for taking your time to apply for this recruitment drive and we wish you better luck next time. 🙂

\n

 

\n

Yours Sincerely,

\n

 

\n

APAC

\n

 

"}},{"id":"kP8PBQZ0Tu","type":"image","values":{"containerPadding":"10px","src":{"url":"https://s3.amazonaws.com/unroll-images-production/projects%2F0%2F1645716067964-apaclogo.png","width":259,"height":96},"textAlign":"left","altText":"","action":{"name":"web","values":{"href":"","target":"_blank"}},"hideDesktop":false,"displayCondition":null,"_meta":{"htmlID":"u_content_image_1","htmlClassNames":"u_content_image"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true}},{"id":"ie50Mj0umP","type":"text","values":{"containerPadding":"10px","textAlign":"left","lineHeight":"140%","linkStyle":{"inherit":true,"linkColor":"#0000ee","linkHoverColor":"#0000ee","linkUnderline":true,"linkHoverUnderline":true},"hideDesktop":false,"displayCondition":null,"_meta":{"htmlID":"u_content_text_2","htmlClassNames":"u_content_text"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true,"text":"

Asia Pacific University of Technology and Innovation (APU/APIIT)

\n

Jalan Teknologi 5, Taman Teknologi Malaysia,

\n

57000 Kuala Lumpur, Wilayah Persekutuan Kuala Lumpur

\n

📩 asiapacificanalyticsclub@outlook.com

\n

🌏 http://facebook.com/asiapacificanalyticsclub/

\n

🌏https://www.instagram.com/apu.apac/

"}}],"values":{"backgroundColor":"","padding":"0px","border":{},"_meta":{"htmlID":"u_column_1","htmlClassNames":"u_column"}}}],"values":{"displayCondition":null,"columns":false,"backgroundColor":"","columnsBackgroundColor":"","backgroundImage":{"url":"","fullWidth":true,"repeat":false,"center":true,"cover":false},"padding":"0px","hideDesktop":false,"_meta":{"htmlID":"u_row_1","htmlClassNames":"u_row"},"selectable":true,"draggable":true,"duplicatable":true,"deletable":true,"hideable":true}}],"values":{"textColor":"#000000","backgroundColor":"#e7e7e7","backgroundImage":{"url":"","fullWidth":true,"repeat":false,"center":true,"cover":false},"contentWidth":"500px","contentAlign":"center","fontFamily":{"label":"Arial","value":"arial,helvetica,sans-serif"},"preheaderText":"","linkStyle":{"body":true,"linkColor":"#0000ee","linkHoverColor":"#0000ee","linkUnderline":true,"linkHoverUnderline":true},"_meta":{"htmlID":"u_body","htmlClassNames":"u_body"}}},"schemaVersion":7} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f4f098a..69054de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1192,6 +1192,27 @@ } } }, + "@fast-csv/parse": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/@fast-csv/parse/-/parse-4.3.6.tgz", + "integrity": "sha512-uRsLYksqpbDmWaSmzvJcuApSEe38+6NQZBUsuAyMZKqHxH0g1wcJgsKUvN3WC8tewaqFjBMMGrkHmC+T7k8LvA==", + "requires": { + "@types/node": "^14.0.1", + "lodash.escaperegexp": "^4.1.2", + "lodash.groupby": "^4.6.0", + "lodash.isfunction": "^3.0.9", + "lodash.isnil": "^4.0.0", + "lodash.isundefined": "^3.0.1", + "lodash.uniq": "^4.5.0" + }, + "dependencies": { + "@types/node": { + "version": "14.18.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz", + "integrity": "sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==" + } + } + }, "@gar/promisify": { "version": "1.1.2", "resolved": "https://registry.nlark.com/@gar/promisify/download/@gar/promisify-1.1.2.tgz", @@ -2096,6 +2117,63 @@ "integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=", "dev": true }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "optional": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "optional": true + }, + "loader-utils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz", + "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==", + "dev": true, + "optional": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, "ssri": { "version": "8.0.1", "resolved": "https://registry.nlark.com/ssri/download/ssri-8.0.1.tgz", @@ -2104,6 +2182,28 @@ "requires": { "minipass": "^3.1.1" } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "optional": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "vue-loader-v16": { + "version": "npm:vue-loader@16.8.3", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz", + "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==", + "dev": true, + "optional": true, + "requires": { + "chalk": "^4.1.0", + "hash-sum": "^2.0.0", + "loader-utils": "^2.0.0" + } } } }, @@ -9278,6 +9378,31 @@ "integrity": "sha1-US6b1yHSctlOPTpjZT+hdRZ0HKY=", "dev": true }, + "lodash.escaperegexp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", + "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" + }, + "lodash.groupby": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz", + "integrity": "sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E=" + }, + "lodash.isfunction": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz", + "integrity": "sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==" + }, + "lodash.isnil": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/lodash.isnil/-/lodash.isnil-4.0.0.tgz", + "integrity": "sha1-SeKM1VkBNFjIFMVHnTxmOiG/qmw=" + }, + "lodash.isundefined": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz", + "integrity": "sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g=" + }, "lodash.kebabcase": { "version": "4.1.1", "resolved": "https://registry.nlark.com/lodash.kebabcase/download/lodash.kebabcase-4.1.1.tgz", @@ -9311,8 +9436,7 @@ "lodash.uniq": { "version": "4.5.0", "resolved": "https://registry.npm.taobao.org/lodash.uniq/download/lodash.uniq-4.5.0.tgz", - "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=", - "dev": true + "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" }, "log-symbols": { "version": "2.2.0", @@ -10399,6 +10523,11 @@ "integrity": "sha1-bJWZ00DVTf05RjgCUqNXBaa5kr8=", "dev": true }, + "papaparse": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.1.tgz", + "integrity": "sha512-Dbt2yjLJrCwH2sRqKFFJaN5XgIASO9YOFeFP8rIBRG2Ain8mqk5r1M6DkfvqEVozVcz3r3HaUGw253hA1nLIcA==" + }, "parallel-transform": { "version": "1.2.0", "resolved": "https://registry.nlark.com/parallel-transform/download/parallel-transform-1.2.0.tgz", @@ -15768,87 +15897,6 @@ } } }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.8.1", - "resolved": "https://registry.npmmirror.com/vue-loader/download/vue-loader-16.8.1.tgz?cache=0&sync_timestamp=1632349808529&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fvue-loader%2Fdownload%2Fvue-loader-16.8.1.tgz", - "integrity": "sha1-NU8SvAiXlUFYtxWQ+AApVxOneS0=", - "dev": true, - "optional": true, - "requires": { - "chalk": "^4.1.0", - "hash-sum": "^2.0.0", - "loader-utils": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.nlark.com/ansi-styles/download/ansi-styles-4.3.0.tgz?cache=0&sync_timestamp=1618995651629&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fansi-styles%2Fdownload%2Fansi-styles-4.3.0.tgz", - "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", - "dev": true, - "optional": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.nlark.com/chalk/download/chalk-4.1.2.tgz?cache=0&sync_timestamp=1627646655305&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fchalk%2Fdownload%2Fchalk-4.1.2.tgz", - "integrity": "sha1-qsTit3NKdAhnrrFr8CqtVWoeegE=", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz", - "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", - "dev": true, - "optional": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npm.taobao.org/color-name/download/color-name-1.1.4.tgz", - "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", - "dev": true, - "optional": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.nlark.com/has-flag/download/has-flag-4.0.0.tgz", - "integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=", - "dev": true, - "optional": true - }, - "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npm.taobao.org/loader-utils/download/loader-utils-2.0.0.tgz", - "integrity": "sha1-5MrOW4FtQloWa18JfhDNErNgZLA=", - "dev": true, - "optional": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.nlark.com/supports-color/download/supports-color-7.2.0.tgz", - "integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=", - "dev": true, - "optional": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "vue-router": { "version": "3.5.2", "resolved": "https://registry.nlark.com/vue-router/download/vue-router-3.5.2.tgz", diff --git a/package.json b/package.json index 8324df4..3f06bef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apac-mailer", - "version": "0.1.0", + "version": "0.2.0", "private": true, "scripts": { "serve": "vue-cli-service serve", @@ -13,11 +13,13 @@ }, "main": "background.js", "dependencies": { + "@fast-csv/parse": "^4.3.6", "core-js": "^3.6.5", "dns": "^0.2.2", "jspdf": "^2.4.0", "nodemailer": "^6.6.5", "nodemailer-smtp-transport": "^2.7.4", + "papaparse": "^5.3.1", "roboto-fontface": "*", "vue": "^2.6.11", "vue-email-editor": "^0.9.0", diff --git a/src/App.vue b/src/App.vue index ce6d8a3..d42a8ab 100644 --- a/src/App.vue +++ b/src/App.vue @@ -46,7 +46,7 @@ - @@ -96,10 +96,10 @@ export default { console.log(design); this.html = design; }, - changeProgress(n, t) { + changeProgress({cur, total}) { this.sending = true; - this.progress = n + " / " + t; - this.cur = n / t; + this.progress = cur + " / " + total; + this.cur = cur / total; }, completed(e) { console.log("Completed2"); diff --git a/src/background.js b/src/background.js index c3717e4..891f488 100644 --- a/src/background.js +++ b/src/background.js @@ -6,6 +6,7 @@ import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer"; const isDevelopment = process.env.NODE_ENV !== "production"; const nodemailer = require("nodemailer"); const { ipcMain } = require('electron'); + // Scheme must be registered before the app is ready protocol.registerSchemesAsPrivileged([ { scheme: "app", privileges: { secure: true, standard: true } }, diff --git a/src/views/CertDesign.vue b/src/views/CertDesign.vue index 0c2c375..6a5136b 100644 --- a/src/views/CertDesign.vue +++ b/src/views/CertDesign.vue @@ -161,6 +161,13 @@ v-model="names.name" @input="createPdf"> + + +
Save @@ -188,7 +195,7 @@ export default { this.pdf.addImage(this.imgPath, this.imgType, 0, 0, 298, 210); } - this.pdf.text(this.names.name, this.names.x, this.names.y); + this.pdf.text(this.names.name, this.names.x, this.names.y, this.alignCenter ? "center" : "left"); document.getElementById("cert").src = this.pdf.output('bloburl') }, loadImg(e) { @@ -228,8 +235,9 @@ export default { y: this.names.y, width: width, height: height, - color: this.color - } + color: this.color, + alignCenter: this.alignCenter + }; }, }, data() { @@ -249,7 +257,8 @@ export default { "g": 0, "b": 0, "a": 1 - } + }, + alignCenter: false } }, created() { diff --git a/src/views/Home.vue b/src/views/Home.vue index 8137fde..d27ace4 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -164,6 +164,7 @@ const {ipcRenderer} = window.require('electron'); const { shell } = require('electron'); import { jsPDF } from "jspdf"; +import * as Papa from 'papaparse'; export default { name: "Home", @@ -220,7 +221,8 @@ export default { return; } } - this.$emit('progress', this.currentId); + this.$emit('progress', {cur:this.currentId, total:this.selected.length}); + this.failed = []; this.sendEmail(); }, emailListener(evt, message) { @@ -229,7 +231,7 @@ export default { this.failed.push(this.selected[this.currentId]); } if (++this.currentId < this.selected.length) { - this.$emit('progress', this.currentId, this.selected.length); + this.$emit('progress', {cur:this.currentId, total:this.selected.length}); setTimeout(() => this.sendEmail(), 500); } else { this.currentId = 0; @@ -256,13 +258,15 @@ export default { } }, formatCSV(csv) { - let tmp = csv.split("\n"); + let output = Papa.parse(csv.trim()); this.headers = []; this.recipients = []; - for (let i = 0; i < tmp.length; i++) { - let line = tmp[i].trim().split(this.separator == "" ? "," : this.separator); + + this.headers = []; + this.recipients = []; + for (let i = 0; i < output.data.length; i++) { if (i == 0) { - for (let val of line) { + for (let val of output.data[i]) { this.headers.push({ text: val, value: val @@ -271,12 +275,13 @@ export default { this.emailCol = this.headers[0].value; } else { let newLine = {}; - for (let val in line) { - newLine[this.headers[val].value] = line[val]; + for (let val in output.data[i]) { + newLine[this.headers[val].value] = output.data[i][val]; } this.recipients.push(newLine); } } + console.log(this.recipients); }, setAttachments(e) { this.attachments = []; @@ -312,7 +317,7 @@ export default { pdf.setFontSize(this.cert.fontSize); pdf.addImage(this.cert.imgPath, this.cert.imgType, 0, 0, this.cert.width, this.cert.height); pdf.setTextColor(this.cert.color.r, this.cert.color.g, this.cert.color.b); - pdf.text(this.selected[this.currentId][this.nameCol], this.cert.x, this.cert.y); + pdf.text(this.selected[this.currentId][this.nameCol], this.cert.x, this.cert.y, this.cert.alignCenter ? "center" : "left"); let data = pdf.output('dataurl'); obj.attachments.push({ filename: (this.cert.fileName == '' ? 'attachment' : this.cert.fileName) + '.pdf',