-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Antonov548/podofo.js
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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. | ||
|
||
## 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 | ||
|
||
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(); | ||
|
||
``` |