bs-react-pdf

0.0.13 • Public • Published

bs-react-pdf npm version

react-pdf bindings for bucklescript

Installation

  1. $ npm i bs-react-pdf
  2. Add bs-react-pdf to bs-dependencies section of your bsconfig.json

Examples

Document

open ReactPdf.Core;
 
let styles =
  StyleSheet.create({
    "page": {"flexDirection": "row", "backgroundColor": "#fff"},
    "section": {"margin": 10, "padding": 10, "flexGrow": 1}
  });
 
let component = ReasonReact.reducerComponent("MyDocument");
 
let make = (_children) => {
  ...component,
  reducer: ((), _state: unit) => ReasonReact.NoUpdate,
  render: (_self) =>
    <Document>
      <Page size="A4" style=styles##page>
        <View style=styles##section>
          <Text key="hello"> (ReasonReact.stringToElement("Section #1")) </Text>
        </View>
        <View style=styles##section>
          <Text> (ReasonReact.stringToElement("Section #2")) </Text>
        </View>
      </Page>
    </Document>
};

Save in a file

ReactPdfNode.render(<MyDocument />, "example.pdf")
|> Js.Promise.then_(() => Js.Promise.resolve @@ Js.log("Pdf created"));

Package Sidebar

Install

npm i bs-react-pdf

Weekly Downloads

0

Version

0.0.13

License

MIT

Last publish

Collaborators

  • meafmira