Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@jakmsok-react-pdf/render
Advanced tools
This package is fork from github.com/diegomura/react-pdf to add wrap style
React-pdf render engine
yarn add @jakmsok-react-pdf/render
const render = require('@jakmsok-react-pdf/render');
const primitives = require('@jakmsok-react-pdf/primitives');
const view = {
type: primitives.View,
style: {
backgroundColor: 'red',
borderTopLeftRadius: 5,
borderTopRightRadius: 10,
borderBottomLeftRadius: 0,
borderBottomRightRadius: 15,
borderTopColor: 'yellow',
borderLeftColor: 'green',
borderBottomColor: 'black',
borderRightColor: 'purple',
},
box: {
left: 20,
top: 20,
width: 100,
height: 80,
borderTopWidth: 3,
borderLeftWidth: 2,
borderBottomWidth: 1,
borderRightWidth: 4,
},
};
const doc = {
type: primitives.Document,
children: [
{
type: primitives.Page,
box: { width: 400, height: 600 },
children: [view],
},
],
};
// Provide your own context
const ctx = createContext();
render.default(ctx, doc);
This library exports a render
function that takes two arguments:
type
and arguments.A node represents a single element inside a document. It's mainly defined by it's type
(mandatory) field in addition to other values to define where that element is positioned inside the document (box
), how it looks (style
), how it should behave (params
) and what sub-nodes it contains (children
).
The root node must always be of type DOCUMENT
, containing as many PAGE
nodes as desired inside it's children field.
Bare in mind this package does not handle any type of node positioning, inheritance, style transformations or any other layout related logic. It's role is limited to render exactly the node it get's into the provided context. Take this into account when definig styles as paddingTop
, paddingLeft
and so on instead of the shortcut padding
. For layout or styles transformation this project provides separate packages.
Mandatory field specifiying the type of the particular node. The full list of types can be found and imported from @jakmsok-react-pdf/primitives
Defines bounding box where a particular node is located inside a document
Defines how the node looks like. There are some types of nodes that expect special style values, but generally all support:
Specific node params needed to render correctly ot behave like certain way. Specially needed for SVG nodes
const fs = require('fs');
const render = require('@jakmsok-react-pdf/render');
const pdfkit = require('@jakmsok-react-pdf/pdfkit');
const PDFDocument = pdfkit.default;
const ctx = new PDFDocument({ autoFirstPage: false });
const doc = {}; // See above
render.default(ctx, doc);
const stream = fs.createWriteStream('./test.pdf');
ctx.pipe(stream);
MIT © Diego Muracciole
FAQs
This package is fork from github.com/diegomura/react-pdf to add wrap style
The npm package @jakmsok-react-pdf/render receives a total of 0 weekly downloads. As such, @jakmsok-react-pdf/render popularity was classified as not popular.
We found that @jakmsok-react-pdf/render demonstrated a not healthy version release cadence and project activity because the last version was released 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.