Fixed pdf generation

This commit is contained in:
Patrick Alvin Alcala 2025-10-16 10:09:51 +08:00
parent 6b651b8958
commit b11fcdb236

View file

@ -1,7 +1,7 @@
import jsPDF from 'jspdf' import jsPDF from 'jspdf'
// @ts-ignore // @ts-ignore
import jspdfBarcode from 'jspdf-barcode' import jspdfBarcode from 'jspdf-barcode'
import { _optn, _applicationNo, _date, _name, _type, _location, _assessor, _feeList, _codeList, _amountList, _signature, _assessorid } from '../../stores/pdfinfo' import { _optn, _applicationNo, _date, _name, _type, _location, _assessor, _feeList, _codeList, _amountList, _signatureAssessor, _signatureApprover, _assessorid, _approvedDate } from '../../stores/pdfinfo'
import dayjs from 'dayjs' import dayjs from 'dayjs'
// @ts-ignore // @ts-ignore
import QRCode from 'qrcode' import QRCode from 'qrcode'
@ -22,7 +22,7 @@ export default async () => {
const CODES = _codeList.get() const CODES = _codeList.get()
const AMOUNTS = _amountList.get() const AMOUNTS = _amountList.get()
const ASSESSORID = _assessorid.get() const ASSESSORID = _assessorid.get()
const APPROVERID = 176 const APPROVERID = 276
const doc = new jsPDF({ const doc = new jsPDF({
orientation: 'l', orientation: 'l',
@ -48,17 +48,17 @@ export default async () => {
const pageWidth = doc.internal.pageSize.getWidth() const pageWidth = doc.internal.pageSize.getWidth()
const lungsod = new Image() const lungsod = new Image()
lungsod.src = 'src/assets/images/lungsod.png' lungsod.src = 'lungsod.png'
const ocbo = new Image() const ocbo = new Image()
ocbo.src = 'src/assets/images/ocbologo.png' ocbo.src = 'ocbologo.png'
jspdfBarcode(doc, APPLICATION, { jspdfBarcode(doc, APPLICATION, {
fontSize: 32, fontSize: 32,
textColor: '#000000', textColor: '#000000',
x: pageWidth - 35, x: pageWidth - 35,
y: 40, y: 40,
textOptions: { align: 'center' }, // optional text options textOptions: { align: 'center' },
}) })
const generateQR = async (text: string) => { const generateQR = async (text: string) => {
@ -229,17 +229,17 @@ 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) 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.text(note, 16, 144)
doc.addImage(_signature.get(), 'PNG', 30, 110, 10, 5.9, 'signature', 'NONE', 0) doc.addImage(_signatureAssessor.get(), 'PNG', 30, 110, 10, 5.9, 'signatureAssessor', 'NONE', 0)
doc.setFont('arial', 'normal') doc.setFont('arial', 'normal')
doc.setFontSize(4) doc.setFontSize(4)
doc.text('Digitally signed by :', 30, 118) doc.text('Digitally signed by :', 30, 118)
doc.text(ASSESSOR, 30, 120) doc.text(ASSESSOR, 30, 120)
doc.text('Date: ' + dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'), 30, 122) doc.text('Date: ' + dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'), 30, 122)
doc.addImage(_signature.get(), 'PNG', 156, 110, 10, 5.9, 'signature', 'NONE', 0) doc.addImage(_signatureApprover.get(), 'PNG', 156, 110, 41.4, 5.9, 'signatureApprover', 'NONE', 0)
doc.text('Digitally signed by :', 156, 118) doc.text('Digitally signed by :', 156, 118)
doc.text(APPROVER, 156, 120) doc.text(APPROVER, 156, 120)
doc.text('Date: ' + dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'), 156, 122) doc.text('Date: ' + dayjs(_approvedDate.get()).format('YYYY-MM-DD HH:mm:ss'), 156, 122)
doc.addImage(assessorQr, 'PNG', 16, 110, 14, 14, 'assessorQr', 'NONE', 0) doc.addImage(assessorQr, 'PNG', 16, 110, 14, 14, 'assessorQr', 'NONE', 0)
doc.addImage(approverQr, 'PNG', 142, 110, 14, 14, 'approverQr', 'NONE', 0) doc.addImage(approverQr, 'PNG', 142, 110, 14, 14, 'approverQr', 'NONE', 0)