New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@alheimsins/pdf-make

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alheimsins/pdf-make

High-level API for pdfmake PDF document generation library

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Build Status js-standard-style

pdf-make

High-level API for pdfmake - PDF document generation library for server-side and client-side usage in pure JavaScript.

Installation

$ npm install @alheimsins/pdf-make

Usage

PDF

(async () => {
  const pdfmake = require('@alheimsins/pdf-make')
  const fs = require('fs').promises

  const content = {
    content: [
      'test'
    ]
  }

  // Creates PDF buffer
  const buffer = await pdfmake(content)

  console.log(buffer)
  // Returns <Buffer 25 50 44 46 2d 31 2e 33 0a 25 ff ff ff ff 0a 38 20 30 20 6f 62 6a 0a 3c 3c 0a 2f 54 79 70 65 20 2f 45 78 74 47 53 74 61 74 65 0a 2f 63 61 20 31 0a 2f ... >

  console.log('data:application/pdf;base64' + buffer.toString('base64'))
  // Return data:application/pdf;base64JVBERi0xLjMKJf////8KOCAwIG9iago8PAovVHlwZSAvRXh0R1N0YXRlCi9jYSAxCi9DQSAxCj4+CmVuZG9iago3IDAgb2JqCjw8Ci9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL

  await fs.writeFile('test.pdf', buffer)
  // Create test.pdf file
})()

PDF/A-2B

(async () => {
  const pdfmake = require('@alheimsins/pdf-make')
  const fs = require('fs').promises

  const content = {
    content: [
      'test'
    ]
  }
  const options = {
    type: '2',
    version: 'B'
  }

  // Creates PDF buffer
  const buffer = await pdfmake(content, options)

  console.log(buffer)
  // Returns <Buffer 25 50 44 46 2d 31 2e 33 0a 25 ff ff ff ff 0a 38 20 30 20 6f 62 6a 0a 3c 3c 0a 2f 54 79 70 65 20 2f 45 78 74 47 53 74 61 74 65 0a 2f 63 61 20 31 0a 2f ... >

  console.log('data:application/pdf;base64' + buffer.toString('base64'))
  // Return data:application/pdf;base64JVBERi0xLjMKJf////8KOCAwIG9iago8PAovVHlwZSAvRXh0R1N0YXRlCi9jYSAxCi9DQSAxCj4+CmVuZG9iago3IDAgb2JqCjw8Ci9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL

  await fs.writeFile('test.pdf', buffer)
  // Create test.pdf file
})()

Documentation

See pdfmake documentation

License

MIT

About

Created with ❤ for Alheimsins

Alheimsins logo

Keywords

FAQs

Package last updated on 15 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc