All Projects → AmirTugi → Tea School

AmirTugi / Tea School

Simplified HTML + CSS --> PDF Generator for Nodejs

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Tea School

Md To Pdf
Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
Stars: ✭ 374 (+14.72%)
Mutual labels:  pdf, pdf-generation, puppeteer
Asciidoctor Web Pdf
Convert AsciiDoc documents to PDF using web technologies
Stars: ✭ 219 (-32.82%)
Mutual labels:  pdf, pdf-generation, puppeteer
Percollate
A command-line tool to turn web pages into beautiful, readable PDF, EPUB, or HTML docs.
Stars: ✭ 3,535 (+984.36%)
Mutual labels:  pdf, puppeteer
Pdfgen
Simple C PDF Writer/Generation library
Stars: ✭ 200 (-38.65%)
Mutual labels:  pdf, pdf-generation
Gotenberg
A Docker-powered stateless API for PDF files.
Stars: ✭ 3,272 (+903.68%)
Mutual labels:  pdf, puppeteer
Chrome Headless Render Pdf
Stars: ✭ 164 (-49.69%)
Mutual labels:  pdf, pdf-generation
Resumake.io
📝 A website for automatically generating elegant LaTeX resumes.
Stars: ✭ 2,277 (+598.47%)
Mutual labels:  pdf, pdf-generation
Pdf Lib
Create and modify PDF documents in any JavaScript environment
Stars: ✭ 3,426 (+950.92%)
Mutual labels:  pdf, pdf-generation
Reportbro Designer
Javascript plugin to visually design report layouts (for pdf and Excel) which can be created with reportbro-lib (a Python package) on the server.
Stars: ✭ 160 (-50.92%)
Mutual labels:  pdf, pdf-generation
Dhalang
Generate PDFs and make screenshots of HTML using Puppeteer in Ruby
Stars: ✭ 41 (-87.42%)
Mutual labels:  pdf-generation, puppeteer
Android Pdfmyxml
convert android xml layouts into PDF document, works on all versions of Android.
Stars: ✭ 231 (-29.14%)
Mutual labels:  pdf, pdf-generation
aws-lambda-pdf-generator-puppeteer
PDF generator for AWS lambda with puppeteer
Stars: ✭ 52 (-84.05%)
Mutual labels:  pdf-generation, puppeteer
Pandoc Latex Template
A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
Stars: ✭ 3,750 (+1050.31%)
Mutual labels:  pdf, pdf-generation
Wasm Pdf
Generate PDF files with JavaScript and WASM (WebAssembly)
Stars: ✭ 163 (-50%)
Mutual labels:  pdf, pdf-generation
Markdown Pdf
📄 Markdown to PDF converter
Stars: ✭ 2,365 (+625.46%)
Mutual labels:  pdf, pdf-generation
Openpdf
OpenPDF is a free Java library for creating and editing PDF files with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository. ⛺
Stars: ✭ 2,174 (+566.87%)
Mutual labels:  pdf, pdf-generation
Hummusrecipe
A powerful PDF tool for NodeJS based on HummusJS.
Stars: ✭ 274 (-15.95%)
Mutual labels:  pdf, pdf-generation
Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (-57.36%)
Mutual labels:  pdf, pdf-generation
Doctron
Docker-powered html convert to pdf(html2pdf), html to image(html2image like jpeg,png),which using chrome(golang) kernel, add watermarks to pdf, convert pdf to images etc.
Stars: ✭ 141 (-56.75%)
Mutual labels:  pdf, pdf-generation
Pdf Bot
🤖 A Node queue API for generating PDFs using headless Chrome. Comes with a CLI, S3 storage and webhooks for notifying subscribers about generated PDFs
Stars: ✭ 2,551 (+682.52%)
Mutual labels:  pdf, pdf-generation

Tea-School

Simplified HTML + CSS --> PDF Generator for Nodejs
Basically just a method combining PugJS, Node-Sass, and Puppeteer.

Read More

Read more about the package in my medium post

Install

Using npm

> npm install tea-school

Using yarn

> yarn add tea-school

What Do We Have Here?

The library doesn't really do anything special.
It just combines 3 libraries for:

Usage

We will generate the following PDF:

For further inspection look at the examples folder

*The example will be in TypeScript, but can work in JavaScript in a matter of removing just a few words.

import {GeneratePdfOptions, generatePdf} from 'tea-school';
import * as path from 'path';

const options: GeneratePdfOptions = {
    htmlTemplatePath: path.resolve(__dirname, 'pdf-template.pug'),

    // Here you put an object according to https://github.com/sass/node-sass#options 
    styleOptions: {
        file: path.resolve(__dirname, 'pdf-template.scss')
    },

    // Here you put an object according to https://pugjs.org/api/reference.html#options
    // You can add any additional key to be used as a variable in the template.
    htmlTemplateOptions: {
        name: 'Timothy'
    },

    // Here you put an object according to https://github.com/GoogleChrome/puppeteer/blob/v1.18.1/docs/api.md#pagepdfoptions
    pdfOptions: {
        // Ignore `path` to get the PDF as buffer only
        path: 'pdf-file.pdf',
        format: 'A4',
        printBackground: true
    }
}

(async () => {
    const pdfBuffer: Buffer = await generatePdf(options);
})();
template.pug
// Use !{var} to use unescaped conent
style(type="text/css") !{compiledStyle}

div#banner-message
    p Hello, #{name}
    button My god, this is amazing
template.scss
$blue: #0084ff;
$blue-darker: darken($blue, 5);

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#banner-message {
  background: #e0e0e0;
  border-radius: 4px;
  padding: 20px;
  font-size: 25px;
  text-align: center;
  transition: all 0.2s;
  margin: 0 auto;
  width: 300px;

  button {
    background: $blue-darker;
    border: none;
    border-radius: 5px;
    padding: 8px 14px;
    font-size: 15px;
    color: #fff;
  }
}

Running the examples in the package

> npm run example

// OR

> npm run example:invoice

The examples run using ts-node to run without compiling the tests to JavaScript first.

Important

The key compiledStyle is reserved on the Pug options for the compiled style to be attached to the html.
Please do not use this key (or use at your own risk)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].