bs-react-pdf
v0.0.13
Published
react-pdf bindings for bucklescript
Downloads
8
Maintainers
Readme
bs-react-pdf
react-pdf bindings for bucklescript
Installation
$ npm i bs-react-pdf
- Add
bs-react-pdf
tobs-dependencies
section of yourbsconfig.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"));