Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@garage-panda/react-pdf-export

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@garage-panda/react-pdf-export

A PDF generator for React applications

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
decreased by-51.52%
Maintainers
3
Weekly downloads
 
Created
Source

npm version

react-pdf-export

About

It allows you to either download or print a pdf file with your own content.

Example

Example code in stackblitz

Installation

// with npm

npm i @garage-panda/react-pdf-export

// with yarn

yarn add @garage-panda/react-pdf-export

Import the package

import { PdfExport, useGeneratePdf } from "@garage-panda/react-pdf-export";

Retrieve the component and the useEffect

const { generatePdf, containerRef } = useGeneratePdf();

That's it!

Usage

import { PdfExport, useGeneratePdf } from '@garage-panda/react-pdf-export';

const App() {
    const { generatePdf, containerRef } = useGeneratePdf();

    return (
      <React.Fragment>
        <PdfExport containerRef={containerRef}>
          <h1>This is the content of the PDF in here</h1>
          <div>
            <p>Yes, you can put any child</p>
            <div>Because it's awesome!</div>
          </div>
        </PdfExport>

        <button onClick={generatePdf}>Generate PDF</button>
      </React.Fragment>
    );
}

export default App;

Available optional props

PropTypeDefaultDescriptionOptional
classNamestringnoneA custom class passed down to the iframe containeryes
showInDombooleantrueShow the preview of the PDF in the DOMyes
lazyLoadbooleanfalseIn the lazy load mode the content of the PDF is added to the DOM when you call generatePdf and is cleared afterwards. In non-lazy load the content is added to the DOM when the page is renderedyes
optionsHeadOptions{ styles: [], scripts: [], includeParentStyles: true }Styles and scripts loaded only in the iframeyes

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Support

If you like what you see, feel free to support us!

License

MIT

Keywords

FAQs

Package last updated on 01 Nov 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