Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

pdf-javascript

This project arose from the need to generate PDF files for production on a plotter. As it was developed to run in a web browser, some features still need to be implemented to work with Node.js.

References

Basic usage

In this example, a PDF file is generated with the message "Hello World!" in the bottom left corner of the page.

/// importing ...import{PDF,PDFPage,PDFStream}from"../source/index.mjs"/// create a documentletdoc=PDF.Create();/// create a pageletpage=newPDFPage();/// indicate a font type used by the pagepage.use(PDF.Fonts.COURIER);letfontSize=4;letpx=20;letpy=20;/// init a 2d rendererletcontent=newPDF.Path2D();/// set a fill colorcontent.fillColor(newPDF.Color(0xff0000));/// write "hello world"content.fillText('Hello World!',px,py,fontSize,PDF.Fonts.COURIER);/// add content to the pagepage.append(newPDFStream(content));/// add page to documentdoc.attach(page);/// display in an iframedoc.preview(document.body,innerWidth,innerHeight);/// open a popupdoc.open();/// downloaddoc.download();

See examples

To view the examples in docs/, you need to start a local server. In the following example, we use Python to start a simple server. Then, open the localhost in a web browser.

git clone https://github.com/devConcordia/pdf-javascript.git
cd pdf-javascript
python -m http.server

About

A generator for PDF files using Javascript

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages