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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@protacon/pdf-template-builder

v1.0.0

Published

[![npm version](https://badge.fury.io/js/%40protacon%2Fpdf-template-builder.svg)](https://badge.fury.io/js/%40protacon%2Fpdf-template-builder) [![Build Status](https://jenkins.protacon.cloud/buildStatus/icon?job=www.github.com/pdf-template-builder/master)

Downloads

2

Readme

What is this

npm version Build Status

Template builder for pdf-storage

Table of contents

Usage

The pdf-template-builder is designed to be used as a embedded tool inside other applications communicating with the pdf-storage service. This repo contains the builder as a pure React component which can be used in React app in React way.

See working example with full configuration at https://github.com/protacon/how-to-react-pdf-template-builder

  1. Install module
npm i @protacon/pdf-template-builder
  1. Require it in your app
import PdfTemplateBuilder from '@protacon/pdf-template-builder';
  1. Use the component
<PdfTemplateBuilder
  language={this.state.language}
  template={this.state.template}
  schema={new Schema().forExample()}
  onPreview={this.handlePreview}
  onSaveTemplate={this.handleSave}
/>

Configuration

Language (string, optional)

Embedded builder language. Supported options are en and fi. Defaults to en.

Template (object, optional)

Template you want to modify. This template object should be in proper template object format. Absolutely best way to create one is to save template from the builder and take object from that output. Defaults to undefined which means we are creating a new template.

Schema (array, optional)

The object configuration which allows you to configure certain keys to be binded to the template. For example you may want to bind invoice's number to the invoice, so you configure a schema object with key invoiceNumber which you can bind to certain element in your template. Later template will be populated using the proper invoice data and the invoiceNumber placeholder will be filled up with the invoice's number. Defaults to empty array.

[
  {
    type: 'text|group|image',
    tag: 'invoiceNumber',
    text: 'Invoice Number',
    example: '12345'
  }
]

onPreview (function, optional)

Enables the preview button to the builder. When preview button is clicked, the callback defined will be called with the templateHtml, templateData and pageOptions parameters which you can utilize in any way you want, usually just create a preview of the PDF using these parameters. Parameters are straightly compatible with the pdf-storage API. Defaults to undefined, no preview button is shown.

...
onPreview={(templateHtml, templateData, pageOptions) => console.log(templateHtml, templateData, pageOptions))}
...

onSaveTemplate (function, optional)

Enables the save button to the builder. When save button is clicked, the callback defined will be called with the template and templateHtml parameters. Using the template object the builder can be repopulated and the template can be opened under edit again later. Maybe store the template as JSON string to database? Defaults to undefined, no save button is shown.

Development

Requirements

You'd better to have node.js installed.

Getting started

To get started with the development run following commands

npm install
npm start

and navigate to the http://localhost:3000 with your favourite browser.