
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-component-export-view
Advanced tools
w = 100 (Width in pixels - defaults to the width of the element)
h = 50 (Height in pixels - defaults to the height of the element)
x = 0 (X Coordinate in pixels against left edge of the page - defaults to 0)
y = 0 (Y Coordinate in pixels against left edge of the page - defaults to 0)
unit = 'px' (Measurement unit (base unit) to be used when coordinates are specified.
Possible values are "pt" (points), "mm", "cm", "m", "in" or "px". - defaults to 'mm')
- if you are trying to get the pdf to fill up the exact space, try setting unit to "px"
orientation = 'p' (portrait) OR 'l' (landscape) - defaults:
- landscape if width > height
or
- portrait if height > width
The format of the PDF. Can be:
a0 - a10
b0 - b10
c0 - c10
dl
letter
government-letter
legal
junior-legal
ledger
tabloid
credit-card
Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89]
The previous way of using an export looked like this:
exportComponentAsJPEG(node, fileName, type, backgroundColor, options)
The new way: pass node & an optional object with only the fields you need.
exportComponentAsJPEG(node, {fileName, html2CanvasOptions})
exportComponentAsPDF(node, {fileName, html2CanvasOptions, pdfOptions})
import { exportComponentAsJPEG, exportComponentAsPDF, exportComponentAsPNG } from 'react-component-export-image';
import React from 'react';
class ComponentToPrint extends React.Component {
render() {
return <div>Hello World</div>;
}
}
export default class MyComponent extends React.Component {
constructor(props) {
super(props);
this.componentRef = React.createRef();
}
render() {
return (
<React.Fragment>
<ComponentToPrint ref={this.componentRef} />
<button onClick={() => exportComponentAsJPEG(this.componentRef)}>
Export As JPEG
</button>
<button onClick={() => exportComponentAsPDF(this.componentRef)}>
Export As PDF
</button>
<button onClick={() => exportComponentAsPNG(this.componentRef)}>
Export As PNG
</button>
</React.Fragment>
);
}
}
import { exportComponentAsJPEG, exportComponentAsPDF, exportComponentAsPNG } from 'react-component-export-image';
import React, { useRef } from 'react';
const ComponentToPrint = React.forwardRef((props, ref) => (
<div ref={ref}>Hello World</div>
));
const MyComponent = () => {
const componentRef = useRef();
return (
<React.Fragment>
<ComponentToPrint ref={componentRef} />
<button onClick={() => exportComponentAsJPEG(componentRef)}>
Export As JPEG
</button>
<button onClick={() => exportComponentAsPDF(componentRef)}>
Export As PDF
</button>
<button onClick={() => exportComponentAsPNG(componentRef)}>
Export As PNG
</button>
</React.Fragment>
);
};
export default MyComponent;
npm i react-component-export-view
or
yarn add react-component-export-view
FAQs
export component as jpeg, png, pdf
We found that react-component-export-view demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.