• Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    JavaScript
  • License
    zlib License
  • Created about 12 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create PDFs in your browser or nodejs (javascript port of libharu)

hpdf.js

Create PDFs in your browser (port of libharu) See the demo page

Why?

Because other projects with the same goal lack a lot of features (e.g. custom fonts).

Features

  • Custom Fonts (Type1 and TTF)
  • PNG, JPG and RAW images
  • Password encryption
  • Text and Link Annotations
  • Outlines
  • Drawing function (lines, cycles etc.)
  • Encoding support

How to use

Include hpdf.js or hpdf.min.js in your HTML file and see examples or libharu API reference

API naming convention

  • Function names are like their libharu API pendants but object-oriented and their first letter is lowercase.
    // javascript code                           // C code
    var pdf = new HPDF();                        HPDF_Doc pdf = HPDF_New (error_handler, NULL);
    var page = pdf.addPage();                    HPDF_Page page = HPDF_AddPage(pdf);
    pdf.free();                                  HPDF_Free(pdf);
  • Get in the function name is ommitted and Set is kept
    // javascript code                           // C code
    var width = page.width();                    HPDF_REAL width = HPDF_Page_GetWidth(page);
    page.setLineWidth(5);                        HPDF_Page_SetLineWidth(page, 5);
  • Use undefined in Javascript where you would use NULL in C
    // javascript code                           // C code
    var root = pdf.createOutline(undefined,      root = HPDF_CreateOutline (pdf, NULL, "OutlineRoot", NULL);
       "OutlineRoot", undefined);
  • Use strings (case irrelevant) in Javascript where you would use constants in C
    // javascript code                           // C code
    page.setSize('B5', 'landscape');             HPDF_Page_SetSize(page, HPDF_PAGE_SIZE_B5, HPDF_PAGE_LANDSCAPE);
  • Tailing NULL/undefined can be ommitted
    // javascript code                           // C code
    var font = pdf.font('Helvetica');            HPDF_Font font = HPDF_PDF_GetFont(pdf, 'Helvetica', NULL);
  • Instead of calling a error handler in C, an Exception is thrown in Javascript

Dependencies

None. You just need emscripten and CoffeeScript if you want to help developing hpdf.js

How to compile (for devs only)

  1. Configure libhaku cmake ./libharu

  2. Configure libpng cd ./libpng; cmake .; cd ..

  3. Compile hpdf.js ./compile.sh (You might want to change some paths in this bash script!)

More Repositories

1

texlive.js

Compiling LaTeX (TeX live) in your browser
TeX
1,226
star
2

wireguard-p2p

A tool for setting up WireGuard connections from peer to peer.
Rust
290
star
3

bulletinboard-dht

Your internet-wide general-purpose DHT to store key/value pairs
Rust
120
star
4

unix-toolbox.js

The power of Unix command line tools ported to Javascript
JavaScript
81
star
5

unix-toolbox.js-exact-image

ExactImage's bardecode ported to JS
JavaScript
61
star
6

cxx2rs

A rust-binding generator for C files
Python
51
star
7

QtMongo

Bindings for QML to MongoDB
JavaScript
41
star
8

unix-toolbox.js-imagemagick

JavaScript
40
star
9

pdftex.js

This project is deprecated. Use texlive.js:
C
31
star
10

unix-toolbox.js-gnupg

A port of the GNU Privacy Guard to Javascript using Emscripten
JavaScript
20
star
11

kademlia.php

A Distributed Hash Table written in PHP
PHP
17
star
12

ep_latex

LaTeX support for etherpad-lite
JavaScript
15
star
13

nicepipe

Nicepipe is netcat's p2p buddy
C
13
star
14

unix-toolbox.js-poppler

JavaScript
10
star
15

wg-p2p-nm-plugin

A NetworkManager VPN plugin for WireGuard
C
9
star
16

stun3489

An implementation of STUN (RFC 3489) using tokio
Rust
8
star
17

unix-toolbox.js-libgpg-error

Shell
8
star
18

lunadht

Your general purpose DHT
C
7
star
19

taikai

kaitai-like serialization
Rust
6
star
20

nebula-lighthouse-service

This server is a public Nebula VPN Lighthouse Service. You can use it in case you donโ€™t have a publicly accessible server to run your own Nebula Lighthouse.
Python
6
star
21

rusty-abstract-algebra

Abstract Algebra Traits for Rust
Rust
6
star
22

unix-toolbox.js-base

JavaScript
5
star
23

opendht

A Rust API for OpenDHT
Rust
5
star
24

tuntap.rs

Linux TunTap bindings for Rust
Rust
4
star
25

libnice.rs

Bindings for libnice >= v0.1.4
Rust
2
star
26

nonblocking_socket.rs

Non-blocking Read::read() operations on AsRawFd structs (i.e. TcpStream)
Rust
2
star
27

yp

A reverse debugger for python based on rr
C
2
star
28

unix-toolbox.js-libc

C
2
star
29

validanguagePHP

A server-side version of Validanguage
PHP
2
star
30

unix-toolbox.js-file

JavaScript
2
star
31

netlink-wg

API for netlink (with a focus on WireGuard interfaces)
Rust
2
star
32

quelle

A visual sparql explorer
JavaScript
2
star
33

unix-toolbox.js-antigraingeometry

C++
2
star
34

tls-state-machine

A TLS State Machine for Rust
Rust
2
star
35

Async-CouchDB-API

Asynchronous Javascript API for CouchDB
JavaScript
2
star
36

opendht-py

A pypi package for opendht (pip install opendht)
Python
2
star
37

unix-toolbox.js-xz

Shell
2
star
38

reporepo

Continuous Deployment for Debian
C
1
star
39

intercom

A framework to break the client-server paradigm on the net
Rust
1
star
40

unix-toolbox.js-zlib

C
1
star
41

unix-toolbox.js-libjpeg

C
1
star
42

drunken_bishop-rs

An implementation of OpenSSL's randomart algorithm
Rust
1
star
43

adding_neurons_in_deep_learning

1
star
44

unix-toolbox.js-freetype

C
1
star
45

unix-toolbox.js-libassuan

Shell
1
star
46

unix-toolbox.js-libksba

C
1
star
47

libtls.rs

Rust bindings for libressl's libtls
Rust
1
star
48

infinitus-p2p

A peer-to-peer service
C
1
star
49

libssh.rs

rust-bindings for libssh
Rust
1
star
50

unix-toolbox.js-libgcrypt

C
1
star
51

pseudotcp.rs

pseudo-TCP bindings for libnice
Rust
1
star
52

unix-toolbox.js-libtiff

C
1
star
53

nm-vpn-plugin

Documentation on NetworkManager VPN plugin implementation
C
1
star
54

connected_socket.rs

Connect() for UDP sockets
Rust
1
star
55

unix-toolbox.js-expat

Shell
1
star
56

lowenzahn

A Diaspora Add-on for Firefox
1
star
57

unix-toolbox.js-libpng

C
1
star
58

wireguard-tools-rs

A port of wireguard's embeddable library
C
1
star