Skip to content

meafmira/bs-react-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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"));

Releases

No releases published

Packages

No packages published