Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@bcgov/carbone-render

Package Overview
Dependencies
Maintainers
11
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bcgov/carbone-render - npm Package Compare versions

Comparing version
2.1.2
to
2.2.0
+2
-2
package.json
{
"name": "@bcgov/carbone-render",
"version": "2.1.2",
"version": "2.2.0",
"description": "Async wrapper around Carbone render",

@@ -38,3 +38,3 @@ "main": "index.js",

"dependencies": {
"carbone": "^2.1.1",
"carbone": "^3.1.0",
"fs-extra": "^10.0.0",

@@ -41,0 +41,0 @@ "uuid": "^8.3.2"

+49
-39

@@ -1,34 +0,45 @@

## carbone-render
Library to generate a document from an existing template and JSON data. This is a wrapper around [carbone](https://carbone.io), please refer to their documentation for more detail.
# carbone-render
### important
This library will require LibreOffice installed. It requires LibreOffice to do pdf generation.
[![npm](https://img.shields.io/npm/v/@bcgov/carbone-render.svg)](https://www.npmjs.com/package/@bcgov/carbone-render)
[![downloads](https://img.shields.io/npm/dm/@bcgov/carbone-render.svg)](https://npmcharts.com/compare/@bcgov/carbone-render?minimal=true)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![img](https://img.shields.io/badge/Lifecycle-Stable-97ca00)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)
### usage
Library to generate a document from an existing template and JSON data. This is a wrapper around [carbone](https://carbone.io), please refer to their documentation for more detail.
#### install/initialize
## Prerequisites
```
This library will require LibreOffice installed to do pdf generation.
## Installation
```sh
npm i @bcgov/carbone-render
...
```
## Usage
```js
const carboneRenderer = require('@bcgov/carbone-render');
```
#### startFactory
Optional call to start up the carbone python converter. This is recommended to call on start of your application, otherwise, the first call to render will take longer as it starts the converter.
### startFactory
```
Optional call to start up the carbone python converter. This is recommended to call on the start of your application. Otherwise, the first call to render will take longer as it starts the converter in the background.
```js
carboneRenderer.startFactory();
```
#### fileTypes
Return a dictionary of allowable file conversions. Convert to pdf is always allowed.
### fileTypes
```
Return a dictionary of allowable file conversions. Convert to pdf is always allowed.
```js
const allowedConversions = carboneRenderer.fileTypes;
```
##### returns object
```
Returns dictionary
```json
{

@@ -99,14 +110,15 @@ "csv": [

#### async render
Generate a new document from a template and JSON data. Render the report.
### async render
```
const data = {
Generate a new document from a template and JSON data. Render the report.
```js
const data = {
"firstName": "Jane",
"lastName": "Smith",
"title": "Who?"
"title": "Who?"
};
const options = {
"convertTo": "pdf",
"convertTo": "pdf",
"reportName": "{d.firstName}-{d.lastName}.docx",

@@ -120,6 +132,6 @@ "overwrite": "true",

yesOrNo : function (data) { // data = d.myBoolean
if (this.lang === 'fr') {
return data === true ? 'oui' : 'non';
}
return data === true ? 'yes' : 'no';
if (this.lang === 'fr') {
return data === true ? 'oui' : 'non';
}
return data === true ? 'yes' : 'no';
}

@@ -140,10 +152,11 @@ };

##### returns object
```
{
success: false,
errorType: null,
errorMsg: null,
reportName: null,
report: null
Returns object
```json
{
"success": false,
"errorType": null,
"errorMsg": null,
"reportName": null,
"report": null
}

@@ -159,4 +172,1 @@ ```

| report | binary - generated file |