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

adonis-pdf

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonis-pdf

Create PDF files within Adonis using pdfmake

  • 0.0.22
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-42.31%
Maintainers
1
Weekly downloads
 
Created
Source

adonis-pdf

Service provider for building PDFs using pdfmake.

:exclamation: WARNING! This package is heavily in development and is therefore unstable. It may not work correctly or at all. When it is working the way that it needs to I will bump it up to 0.1.0!

Installation

  • Run npm i adonis-pdf or yarn add adonis-pdf
  • Add 'adonis-pdf/providers/PdfProvider' to the providers array within start/app.js

Configuration

Configuration is done through config/pdf.js. This file should have automatically been copied to your project during installation if you installed it via adonis-cli. If you installed it with npm or Yarn, or the file was not copied across correctly, you may copy the config file from this package or run the following command to create it:

adonis pdf:getconfig

By default all configuration options are null (i.e. we use the pdfmake defaults) but feel free to override them as per the pdfmake documentation:

OptionDescription
fontsCustomise the fonts used in your PDFs; if no fonts are specified this package will automatically load default Roboto fonts
stylesCustom style dictionaries allowing you to maintain consistent styles across each PDF
headerCustom header for each page within your PDFs
footerCustom footer for each page within your PDFs
backgroundCustom background for each page within your PDFs
page.sizeSet the page size to be used
page.orientationSet the page orientation
page.marginsSet up the page margins

Usage

Add const PDF = use('PDF') to whatever file you wish to use it, then call PDF.create(). This method accepts two parameters:

  • content: Array representing the PDF content
  • stream: A Readable or Writeable Stream the PDF will be piped to

Example

'use strict'

const PDF = use('PDF')

class MyController {

  async generatePdf ({ response }) {

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

    PDF.create(content, response.response)

    return response
  }

}

module.exports = MyController

Keywords

FAQs

Package last updated on 09 Feb 2018

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