Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/antonov548/podofo.js

JavaScript interface for PoDoFo library
https://github.com/antonov548/podofo.js

js pdf pdf-document pdf-generation webassembly

Last synced: 2 months ago
JSON representation

JavaScript interface for PoDoFo library

Awesome Lists containing this project

README

        

# podofo.js

podofo.js is a JavaScript interface for the [PoDoFo](https://github.com/podofo/podofo) library.

Library provides functions to parse, create and modify PDF.

## NPM package
npm package is available - [npm/podofo.js](https://www.npmjs.com/package/podofo.js)

```bash
npm i podofo.js
```

## Build with docker

podofo.js is a compiled PoDoFo library to WebAssembly using Emscripten.
Docker [image](https://github.com/Antonov548/podofo.js-docker) can be used to build library from scratch.
This docker image contains minimal required tools and dependencies to build a JavaScript module.

Check [CI pipeline](https://github.com/Antonov548/podofo.js/blob/main/.github/workflows/ci.yaml) for more details how to build library.

## Example
```js
import PodofoModule from 'podofo.js'

const Podofo = await PodofoModule();

const document = new Podofo.Document();
const pages = document.getPages();

const page = pages.createPage(
Podofo.getPageSize(Podofo.PageSize.A4, false));

const fonts = document.getFonts();
const font = fonts.getDefaultFont();

const painter = new Podofo.Painter();
painter.setCanvas(page);
painter.setFont(font, 10);
painter.drawText("Hello world!", 0, 0);
painter.finishDrawing();

const pdf = document.save();

painter.delete();
document.delete();

```