0.1.6 • Published 1 month ago

dynamic-html-to-pdf v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

dynamic-html-to-pdf

What is dynamic-html-to-pdf ?

dynamic-html-to-pdf is a small package used to create pdf from edge template.

Edge transform edge template into html string.

Playwright transform html string into pdf file.

Installation

npm install dynamic-html-to-pdf --save

How to use dynamic-html-to-pdf

const pdf = require('dynamic-html-to-pdf')

const template = '/absolute/path/to/file/template.edge'
const context = { users: [{ name: 'John Doe' }, { name: 'Jane Doe' }] }
const options = { path: './output.pdf' }

pdf.create(template, context, options)

Look https://playwright.dev/docs/api/class-page#page-pdf for different options.

Create template.edge

<html>

<head>
  <style>
    .page {
      position: relative;
      width: 100%;
      height: 100%;
    }
  </style>
</head>

<body>
  @each(user in users)
    <div class="page">
      {{user.name}}
    </div>
  @endeach
</body>

</html>

Look https://docs.adonisjs.com/guides/views/introduction for edge syntax

0.1.6

1 month ago

0.1.5

1 month ago

0.1.4

7 months ago

0.1.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.0.9

1 year ago

0.1.3

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

1.0.0

2 years ago