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

@moatamed-sce/pdf-builder

v0.1.5

Published

A4 paged HTML-to-PDF raster export, page geometry, and RTL-safe formatters for the SCE Platform.

Readme

@moatamed-sce/pdf-builder

A4 document primitives and HTML-to-PDF export for the SCE Platform. A document is composed from Angular components that already know about page geometry, then rasterised page-by-page into a PDF that paginates where you said it should — not wherever the browser's print engine happened to break.

Like the form platform, it has a declarative half and a runtime half: a PdfDefinition is a serializable document description, compilePdfDefinition turns it into a PdfDocumentModel, and the view components render that model.

Status — not published

This package is not currently on npmjs.org. It exists in the SCE monorepo and in the build output, and resolves through a TypeScript path alias inside it.

What's in it

Page primitivessce-pdf-page (an A4 sheet with real margins), sce-pdf-section, sce-pdf-field-grid, sce-pdf-data-table, sce-pdf-numbered-list, sce-pdf-image, sce-pdf-signature, sce-pdf-qr-code, sce-pdf-footer, sce-pdf-watermark, plus sce-pdf-export-text and sce-pdf-export-stack for text that must survive rasterisation intact.

GeometryPDF_PX_PER_MM, PDF_PAGE_SIZE_NAMES, DEFAULT_PDF_PAGE_CONFIG. Page size is expressed in millimetres and converted once, so a component never guesses at pixels.

The document schemaPdfDefinition and the element types beneath it (PdfDocumentPage, PdfDocumentSection, PdfDocumentField, PdfDocumentTableSection, PdfDocumentQr, PdfDocumentSignature, PdfDocumentCover …), compiled by compilePdfDefinition(definition, context) into a PdfDocumentModel.

Data bindingcreatePdfRenderContext, withPdfDataScope, resolvePdfPath. Paths are resolved against a data scope, and isValidPdfPath refuses __proto__, constructor and prototype segments: a document that can name a path is a document that could otherwise walk onto the prototype chain.

The trust boundaryparsePdfDefinition is where an untrusted JSON template is accepted or refused. Compile still never throws; the parser is what keeps a stored data: image or a prototype bind out of the designer.

ExportexportPagedHtmlPdfBlob(options) rasterises the rendered pages (via @zumer/snapdom) and assembles them with jsPDF; downloadPagedHtmlPdf(blob, fileName) hands the result to the user, falling back to opening a tab where a download is blocked.

RTL and formattersisPdfRtl plus the number, date and currency formatters, so an Arabic document does not silently render Western digits or a mirrored table.

Peer dependencies

@moatamed-sce/core, @zumer/snapdom, jspdf, qrcode and RxJS 7.8.

Quick start

The views are driven by a compiled model, not by loose props: each component takes the model node it renders ([page], [section], [table]), which is what keeps a stored definition and a hand-composed document rendering through exactly the same code.

Compile a definition against its data:

import { compilePdfDefinition, createPdfRenderContext } from '@moatamed-sce/pdf-builder';

const context = createPdfRenderContext({ locale: 'ar', data: contract });
const model = compilePdfDefinition(definition, context);

Render the pages it produced:

@for (page of model.pages; track page.id; let i = $index) {
<sce-pdf-page [page]="page" [pageIndex]="i" [totalPages]="model.pages.length">
  @for (section of page.sections; track section.id) {
  <sce-pdf-section [section]="section" />
  }
</sce-pdf-page>
}

Then export what was rendered. The exporter captures the DOM, so it needs the element wrapping the page stack and the selector matching one element per page — plus the page box in both CSS pixels (what the DOM was laid out at) and millimetres (what jsPDF writes):

import { exportPagedHtmlPdfBlob, downloadPagedHtmlPdf, PDF_PX_PER_MM } from '@moatamed-sce/pdf-builder';

const blob = await exportPagedHtmlPdfBlob({
  rootElement: this.stack().nativeElement,
  pageSelector: '.sce-pdf-page',
  fileName: 'contract.pdf',
  widthPx: 210 * PDF_PX_PER_MM,
  heightPx: 297 * PDF_PX_PER_MM,
  widthMm: 210,
  heightMm: 297,
  onProgress: (current, total) => this.progress.set(current / total),
});

downloadPagedHtmlPdf(blob, 'contract.pdf');

MINIMAL_INVOICE_PDF_DEFINITION is exported as a worked example of the schema.

Why rasterised, and what that costs

Pages are captured as images and placed into the PDF. That is what makes the output match the screen exactly — Arabic shaping, custom fonts, CSS grid, chart canvases all survive, which a text-drawing PDF library cannot promise. The cost is that body text is not selectable or searchable in the result. Where text must stay real, use sce-pdf-export-text / sce-pdf-export-stack, which are drawn as text rather than captured.

Physical CSS properties (left, top) are correct inside PDF rendering and are an explicit exception to the repo's logical-properties rule: a page being rasterised at a fixed size is not a responsive layout.

Docs

License

MIT