Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: PDF generator(#1w3w78x) #10

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions changelogs/unreleased/-1w3w78x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: 'Implemented: PDF generator'
ticket_id: "#1w3w78x"
merge_request: 10
author: Disha
type: added
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
"axios-cache-adapter": "^2.7.3",
"core-js": "^3.6.5",
"file-saver": "^2.0.5",
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
"html-to-pdfmake": "^2.3.7",
"http-status-codes": "^2.1.4",
"jspdf": "^2.4.0",
"mitt": "^2.1.0",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"pdfmake": "^0.2.4",
"vue": "^3.0.0-0",
"vue-i18n": "^9.0.0",
"vue-router": "^4.0.0-0",
Expand Down
3 changes: 2 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RouteRecordRaw } from 'vue-router';
import Home from '@/views/Home.vue'
import Login from '@/views/Login.vue'
import Settings from "@/views/Settings.vue"
import PdfGenerator from "@/views/PdfGenerator.vue"
import store from '@/store'

const authGuard = (to: any, from: any, next: any) => {
Expand Down Expand Up @@ -43,7 +44,7 @@ const routes: Array<RouteRecordRaw> = [
name: "Settings",
component: Settings,
beforeEnter: authGuard
}
},
]

const router = createRouter({
Expand Down
27 changes: 27 additions & 0 deletions src/views/PdfGenerator.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<PdfTemplate v-show="false" />
<button @click="generatePdf">PDF</button>
</template>
<script>
import PdfTemplate from "@/views/PdfTemplate.vue"
export default {
components: {
PdfTemplate
},
methods: {
generatePdf() {
pdfMake.vfs = pdfFonts.pdfMake.vfs;
const pdfDocument = document.getElementById('PDF');
const html = htmlToPdfmake(pdfDocument.innerHTML);
const docDefinition = {
content: [html],
defaultStyle: {
fontSize: 15,
bold: true,
}
}
pdfMake.createPdf(docDefinition).open();
}
},
}
</script>
5 changes: 5 additions & 0 deletions src/views/PdfTemplate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div id="PDF">
<!-- Template of the PDF -->
</div>
</template>