From 03896a1d701c7b6d66f2b56815e29aa22ae64758 Mon Sep 17 00:00:00 2001 From: Michael Antonov Date: Sat, 1 Jun 2024 11:24:12 +0200 Subject: [PATCH] Update README.md --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index e69de29..40ae3e9 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,43 @@ +# 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. + +## Buld 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 +Minimal example of creating PDF: + +```js + +const PodofoModule = require('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(); + +```