Updated creation of pdf
This commit is contained in:
parent
8b575d2926
commit
34619a65c8
1 changed files with 42 additions and 6 deletions
|
|
@ -1,11 +1,14 @@
|
|||
import jsPDF from 'jspdf'
|
||||
// @ts-ignore
|
||||
import jspdfBarcode from 'jspdf-barcode'
|
||||
import { _optn, _applicationNo, _date, _name, _type, _location, _assessor, _feeList, _codeList, _amountList } from '../../stores/pdfinfo'
|
||||
import { _optn, _applicationNo, _date, _name, _type, _location, _assessor, _feeList, _codeList, _amountList, _signature, _assessorid } from '../../stores/pdfinfo'
|
||||
import dayjs from 'dayjs'
|
||||
// @ts-ignore
|
||||
import QRCode from 'qrcode'
|
||||
import { SHA3, MD5 } from 'crypto-js'
|
||||
|
||||
export default async () => {
|
||||
const PESO = import.meta.env.VITE_PESO
|
||||
const API = import.meta.env.VITE_API
|
||||
|
||||
const OPTN = _optn.get()
|
||||
const APPLICATION = _applicationNo.get()
|
||||
|
|
@ -13,13 +16,13 @@ export default async () => {
|
|||
const NAME = _name.get()
|
||||
const LOCATION = _location.get()
|
||||
const TYPE = _type.get()
|
||||
const CODE = '40201010-5-3'
|
||||
const AMOUNT = 100
|
||||
const ASSESSOR = _assessor.get()
|
||||
const APPROVER = 'AR. KHASHAYAR L. TOGHYANI'
|
||||
const FEES = _feeList.get()
|
||||
const CODES = _codeList.get()
|
||||
const AMOUNTS = _amountList.get()
|
||||
const ASSESSORID = _assessorid.get()
|
||||
const APPROVERID = 176
|
||||
|
||||
const doc = new jsPDF({
|
||||
orientation: 'l',
|
||||
|
|
@ -58,6 +61,24 @@ export default async () => {
|
|||
textOptions: { align: 'center' }, // optional text options
|
||||
})
|
||||
|
||||
const generateQR = async (text: string) => {
|
||||
try {
|
||||
return await QRCode.toDataURL(text)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
const assessorFirstHash = SHA3(ASSESSOR)
|
||||
const assessorSecondHash = MD5(assessorFirstHash.toString().substring(9))
|
||||
const assessorQrText = `Use OCBO e-Sign Validator - scanid=${assessorSecondHash.toString().substring(24)}`
|
||||
const assessorQr = await generateQR(assessorQrText)
|
||||
|
||||
const approverHash = SHA3(APPROVER)
|
||||
const approverSecondHash = MD5(approverHash.toString().substring(9))
|
||||
const approverQrText = `Use OCBO e-Sign Validator - scanid=${approverSecondHash.toString().substring(24)}`
|
||||
const approverQr = await generateQR(approverQrText)
|
||||
|
||||
// const lungsodItem = document.getElementById('lungsod')
|
||||
// const lungsodSrc = lungsodItem?.getAttribute('src')
|
||||
// const lungsodLink = document.createElement('a')
|
||||
|
|
@ -191,8 +212,8 @@ export default async () => {
|
|||
})
|
||||
|
||||
doc.setFont('arial-bold', 'bold')
|
||||
doc.text('Assessed By :', 16, 112)
|
||||
doc.text('Approved By :', 142, 112)
|
||||
doc.text('Assessed By :', 16, 108)
|
||||
doc.text('Approved By :', 142, 108)
|
||||
|
||||
doc.text(ASSESSOR, 16, 128)
|
||||
doc.text(APPROVER, 142, 128)
|
||||
|
|
@ -208,5 +229,20 @@ export default async () => {
|
|||
const note = doc.splitTextToSize('Note: The 72 Hours Transaction Policy of the City Mayor, shall commence upon submission of the Bureau of Fire Protection clearance/certificate and other requirement stated in the notice to comply to be issued by this office.', 185)
|
||||
doc.text(note, 16, 144)
|
||||
|
||||
doc.addImage(_signature.get(), 'PNG', 30, 112, 10, 5.9, 'signature', 'NONE', 0)
|
||||
doc.setFont('arial', 'normal')
|
||||
doc.setFontSize(4)
|
||||
doc.text('Digitally signed by :', 30, 120)
|
||||
doc.text(ASSESSOR, 30, 122)
|
||||
doc.text('Date: ' + dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'), 30, 124)
|
||||
|
||||
doc.addImage(_signature.get(), 'PNG', 156, 112, 10, 5.9, 'signature', 'NONE', 0)
|
||||
doc.text('Digitally signed by :', 156, 120)
|
||||
doc.text(APPROVER, 156, 122)
|
||||
doc.text('Date: ' + dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'), 156, 124)
|
||||
|
||||
doc.addImage(assessorQr, 'PNG', 16, 110, 14, 14, 'assessorQr', 'NONE', 0)
|
||||
doc.addImage(approverQr, 'PNG', 142, 110, 14, 14, 'approverQr', 'NONE', 0)
|
||||
|
||||
doc.save(`OP-${APPLICATION}`)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue