npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@generaloutsource/ksef-pdf-preview

v0.1.0

Published

Podgląd PDF faktur KSeF (FA1/FA2/FA3/FA_RR) i UPO. API dla Angulara + web component <ksef-pdf-preview> dla czystego HTML. Wrapper na oficjalny generator MF (CIRFMF/ksef-pdf-generator).

Readme

@generaloutsource/ksef-pdf-preview

Podgląd PDF faktur KSeF (FA(1)/FA(2)/FA(3)/FA_RR(1)) oraz UPO (v4_2/4_3) z plików XML — w Angularze (przez API) i w czystym HTML (przez web component <ksef-pdf-preview>). Jeden pakiet, dwa wejścia.

Renderowanie po stronie klienta, bez backendu: XML → PDF (Blob) → blob: URL wpięty w <iframe> (natywny renderer PDF przeglądarki, bez pdf.js).

Wrapper na oficjalny generator MF CIRFMF/ksef-pdf-generator (@akmf/ksef-fe-invoice-converter). Generator jest vendorowany (zbudowany dist w vendor/generator/, nietknięty) i bundlowany do outputu. Licencja MIT (zob. atrybucja niżej).

Instalacja

npm install @generaloutsource/ksef-pdf-preview

Angular (API)

Importujesz funkcję, dostajesz blob: URL, renderujesz po swojemu. Ładuj dynamicznie (import()), bo bundle generatora jest ciężki (~3 MB, fonty pdfmake w środku) — nie chcesz go w głównym bundlu.

const { createInvoicePreviewUrl } = await import('@generaloutsource/ksef-pdf-preview');
const url = await createInvoicePreviewUrl(file, { nrKSeF: 'PODGLĄD', watermark: 'PODGLĄD' });
// url → <iframe [src]="sanitizer.bypassSecurityTrustResourceUrl(url)">
// po zniszczeniu komponentu: URL.revokeObjectURL(url)

Gotowy serwis i komponent: examples/angular/ (ksef-preview.service.ts, preview.component.ts).

Czysty HTML (web component)

<script type="module" src="https://cdn.jsdelivr.net/npm/@generaloutsource/ksef-pdf-preview/dist/element.js"></script>

<ksef-pdf-preview id="p" nr-ksef="PODGLĄD" watermark="PODGLĄD"></ksef-pdf-preview>
<script type="module">
  document.getElementById('p').xml = '<Faktura>...</Faktura>';   // albo .file = inputEl.files[0]
</script>

Działający przykład: examples/html/index.html (npm run example).

API web componentu

| | | |---|---| | Atrybuty | nr-ksef, watermark, type (invoice | upo) | | Property | file (File/Blob), xml (string), data (nadpisuje atrybuty) | | Zdarzenia | rendered (detail.url), error (detail.error), loading | | CSS parts | iframe, status |

Element pokrywa też Angulara (przez CUSTOM_ELEMENTS_SCHEMA + import '@generaloutsource/ksef-pdf-preview/element'), ale w Angularze typowane API jest zwykle wygodniejsze.

API (wejście .)

generateInvoicePdf(input, data)            // → Promise<Blob>   (FA1/FA2/FA3/FA_RR, wersja wykrywana auto)
generateInvoicePdf(input, data, 'base64')  // → Promise<string>
generateUpoPdf(input)                      // → Promise<Blob>   (UPO 4_2/4_3)
createInvoicePreviewUrl(input, data?)      // → Promise<string> (blob: URL do <iframe>)
createUpoPreviewUrl(input)                 // → Promise<string>
revokePreviewUrl(url)                      // zwolnij URL

input: File | Blob | string (XML). data: { nrKSeF: string; qrCode?; qr2Code?; isMobile?; watermark? }nrKSeF wymagane przez generator; do podglądu roboczego podaj wartość zastępczą (PREVIEW_DEFAULTS). Re-eksportowane są też niskopoziomowe generateInvoice / generatePDFUPO z generatora.

Obsługiwane dokumenty

FA(1), FA(2), FA(3), FA_RR(1), UPO v4_2 i v4_3 — zgodnie z aktualnym vendorowanym generatorem MF (vendor/generator/package.json → pole version).

Utrzymanie / aktualizacja generatora

Nasze dodatki (API + web component) to cienka warstwa nad nietkniętym upstreamem. Aktualizacja generatora to jedno polecenie:

npm run update:generator        # klonuje, buduje upstream, podmienia vendor/generator
npm run build                   # przebudowuje bibliotekę

Uwagi

  • Tylko przeglądarka. Generator używa FileReader/pdfmake — nie zadziała w czystym Node/SSR. W Angular SSR ładuj wyłącznie po stronie klienta.
  • Rozmiar. dist/index.js ≈ 3 MB (fonty pdfmake wbudowane). dist/element.js jest mały i dociąga index.js jako moduł — zero duplikacji.
  • Zarządzanie pamięcią. Każdy create*PreviewUrl tworzy obiektowy URL — zwalniaj go (revokePreviewUrl / URL.revokeObjectURL), gdy podgląd znika. Web component robi to sam.

Atrybucja i licencja

Fork/wrapper CIRFMF/ksef-pdf-generator (Copyright © 2025 CIRF, MIT). Zachowano oryginalną notę licencyjną. Ten pakiet nie jest oficjalnym produktem Ministerstwa Finansów — to niezależny wrapper publikowany pod własną nazwą. Licencja: MIT.