Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/meafmira/bs-react-pdf

react-pdf bindings for bucklescript
https://github.com/meafmira/bs-react-pdf

bs-react-pdf bucklescript ocaml react react-pdf reason reasonml

Last synced: about 1 month ago
JSON representation

react-pdf bindings for bucklescript

Awesome Lists containing this project

README

        

# bs-react-pdf [![npm version](https://img.shields.io/npm/v/bs-react-pdf.svg?style=flat-square)](https://www.npmjs.com/package/bs-react-pdf)

[react-pdf](https://github.com/diegomura/react-pdf) bindings for [bucklescript](https://bucklescript.github.io/bucklescript/)

## Installation

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

## [Examples](https://github.com/meafmira/bs-react-pdf/tree/master/examples)
### Document

```reason
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) =>



(ReasonReact.stringToElement("Section #1"))


(ReasonReact.stringToElement("Section #2"))



};
```

### Save in a file

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