@noveltyking/pdf-templates
v0.0.2
Published
PDF Templtes for POS
Readme
pdf-formats
A small collection of PDF document formats and helpers built on @react-pdf/renderer. Provides multiple pre-defined visual formats (format1..format4) and a simple loader to pick the right document component and optional data transformer.
Quick Links
- Code: src/main.js
- Format map: src/format-map.js
- Font registration helper: utils/register-pdf-fonts.js
Features
- Multiple visual PDF formats:
format1,format2,format3,format4 - Standard document types supported:
invoice,invoice-docket,payment-receipt,purchase-order,purchase-order-report,customer-statement,close-shift-report - Simple loader
main()to resolve a format’s data transformer and document component - Font registration helper for consistent typography across documents
Quick Start
- Install dependencies
npm install- Build the bundle
npm run build
# or
npm run build:distThe build uses Rollup and outputs to dist/ (see package.json scripts).
Usage
The entry utilities are in src/main.js. Use the main default export or loadPdfFormatModules to resolve modules for a given formatType and pdfFile.
Example:
import main from './src/main.js';
const modules = main({ formatType: 'format2', pdfFile: 'invoice' });
// modules => { formatDataTransformer?, documentComponent }
if (modules) {
const { formatDataTransformer, documentComponent } = modules;
// If a transformer exists, call it to get data for the document
// Then render `documentComponent` with @react-pdf/renderer
}Notes:
formatTypeacceptsformat1..format4or numeric aliases1..4.pdfFileaccepts the supported names (e.g.invoice,invoice-docket). See src/main.js for normalization rules.
Formats
All formats are wired in src/format-map.js. Each entry maps to:
formatDataTransformer(optional): a function that converts incoming data to the document's expected shapedocumentComponent: the React PDF component used to render the document
You can add or override formats by editing or extending FORMAT_MAP in src/format-map.js.
Fonts
Call registerPdfFonts() from utils/register-pdf-fonts.js before rendering documents to ensure the TASAExplorer font family is registered.
Building / Publishing
- Library entry points are configured in
package.jsonviamainandmodulefields. The published package (if applicable) will export the built files fromdist/. - Use
npm run buildto produce development bundles andnpm run build:distfor a distribution build.
Contributing
- Keep formats self-contained under
src/format{n}/. - Add transformers when a document requires non-trivial data mapping.
License
No license specified — add a LICENSE file if you intend to publish.
