This commit is contained in:
Michał Chudy
2025-10-31 16:13:30 +01:00
parent d1d9b956c5
commit df0ef23857
13 changed files with 53729 additions and 0 deletions

File diff suppressed because one or more lines are too long

19
src/app/index.html Normal file
View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>KSEF PDF GENERATOR</title>
</head>
<body>
<h1 style="margin: auto;width: fit-content">📄 KSEF PDF GENERATOR</h1>
<h1> Wygeneruj wizualizacje faktury PDF </h1>
<input accept=".xml" id="xmlInput" type="file" />
<h1> Wygeneruj wizualizacje UPO PDF</h1>
<input accept=".xml" id="xmlInputUPO" type="file" />
<script src="./main.ts" type="module"></script>
</body>
</html>

54
src/app/main.ts Normal file
View File

@@ -0,0 +1,54 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import { generateInvoice, generatePDFUPO } from './build/ksef-pdf-generator.es.js';
const input = document.getElementById('xmlInput') as HTMLInputElement;
const inputUPO = document.getElementById('xmlInputUPO') as HTMLInputElement;
input.addEventListener('change', async () => {
const file = input.files?.[0];
if (!file) {
return;
}
const additionalData: any = {
nrKSeF: '5265877635-20250808-9231003CA67B-BE',
qrCode:
'https://ksef-te.mf.gov.pl/client-app/invoice/5265877635/26-10-2025/HS5E1zrA8WVjDNq_xMVIN5SD6nyRymmQ-BcYHReUAa0',
}; // Example data
generateInvoice(file, additionalData, 'blob').then((data: any) => {
const url = URL.createObjectURL(data);
const a = document.createElement('a');
a.href = url;
a.download = 'test.pdf'; // nazwa pobieranego pliku
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
});
});
inputUPO.addEventListener('change', async () => {
const file = inputUPO.files?.[0];
if (!file) {
return;
}
generatePDFUPO(file).then((blob: any) => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'test.pdf'; // nazwa pobieranego pliku
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
});
});