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

jsx-to-pdf

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-to-pdf

A Simple Utility to render React JSX to PDF

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by57.14%
Maintainers
1
Weekly downloads
 
Created
Source

jsx-to-pdf Maintainability

A Simple Utility to render React JSX to PDF

Getting Started

Installation

$ npm i jsx-to-pdf

Basic Implementation

import { JsxToPdf } from "jsx-to-pdf";

function App() {
  return (
    <JsxToPdf>
        {({ save, jsxRef, error, errorText }) => {
          return (
            <div className="App" ref={jsxRef}>
              <button style={{ height: 50, margin: 20, backgroundColor: '#61dafb' }} onClick={save}>Download PDF for this Page</button>
            </div>
          )
        }}
    </JsxToPdf>
  )
}

Hook Implementation

import { useJsxToPdf } from "jsx-to-pdf";

function App() {
  const { jsxRef, convertToPdf } = useJsxToPdf()
  return (
    <div className="App" ref={jsxRef}>
      <button style={{ height: 50, margin: 20, backgroundColor: '#61dafb' }} onClick={save}>Download PDF for this Page</button>
    </div>
  )
}

Input

NameTypeDefaultDescription
nameStringjsxToPdfName of the PDF to be saved
scaleNumber1Scale of the HTMLNodeElement element
xNumber0Offset x of the PDF
yNumber0Offset y of the PDF
widthNumberJSPDF document widthWidth of the HTMLNodeElement to be set in PDF
heightNumberJSPDF document heightHeight of the HTMLNodeElement to be set in PDF
{...rest}Object{}JSPDF options

Output

Render Props
NameTypeDefaultDescription
saveFunction() => {}Trigger PDF Submit
jsxRefrefundefinedReference to the HTMLNodeElement
loadingBooleanfalseLoader for PDF save
errorBooleanfalseError
errorTextString() => {}Error Text
Hooks
NameTypeDefaultDescription
convertToPDFFunction() => {}Trigger PDF Submit
jsxRefrefundefinedReference to the HTMLNodeElement
loadingBooleanfalseLoader for PDF save
errorBooleanfalseError
errorTextString() => {}Error Text

Contribution

Questions

Feel free to contact me or create an issue

FAQs

Package last updated on 03 Jan 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