Hummus Recipe
This is an easy recipe for HummusJS with a high level class.
I hope this repo will bring more attentions from the community to help HummusJS to grow faster.
Feel free to open issues to help us!
Features
- Javascript with C++ library.
- High performance creation, modification and parsing of PDF files and streams.
- Easy to create and modify PDF files.
- Reusable components.
- Support Basic HTML elements to text
Documentation
Instructions
- GetStarted
- Coordinate System
- Create a new PDF
- Modify an existing PDF
- Append PDF
- Insert PDF
- Overlay PDF
- Split PDF
- Encryption
GetStarted
npm i hummus-recipe --save
Coordinate System
In order to make things easier, I use Left-Top
as center [0,0]
instead of Left-Bottom
.
You may write and edit the pdf like you write things on papers from the left top corner.
It is similar to the Html Canvas
pdfDoc text'start from here' 0 0 text'next line' 0 20 text'some other texts' 100 100 ...
Create a new PDF
const HummusRecipe = ;const pdfDoc = 'new' '/output.pdf' version: 16 author: 'John Doe' title: 'Hummus Recipe' subject: 'A brand new PDF'; pdfDoc ;
const HummusRecipe = ;const pdfDoc = 'new' 'output.pdf';pdfDoc // 1st Page text'Welcome to Hummus-Recipe' 'center' 250 color: '066099' fontSize: 30 bold: true font: 'Helvatica' align: 'center center' text'some text box' 450 400 color: '066099' fontSize: 20 font: 'Courier New' strikeOut: true highlight: color: 255 0 0 textBox: width: 150 lineHeight: 16 padding: 5 15 style: lineWidth: 1 stroke: '#00ff00' fill: '#ff0000' dash: 20 20 opacity: 01 // 2nd page // end and save ;
Modify an existing PDF
const HummusRecipe = ;const pdfDoc = 'input.pdf' 'output.pdf';pdfDoc // edit 1st page text'Add some texts to an existing pdf file' 150 300 // edit 2nd page // end and save ;
Append PDF
const HummusRecipe = ;const pdfDoc = 'input.pdf' 'output.pdf';const longPDF = '/longPDF.pdf';pdfDoc // just page 10 // page 4 and page 6 // page 1-3 and 6-20 // all pages ;
Insert PDF
const HummusRecipe = ;const pdfDoc = 'input.pdf' 'output.pdf'; pdfDoc // insert page3 from longPDF to current page 2 ;
Overlay PDF
const HummusRecipe = ;const pdfDoc = 'input.pdf' 'output.pdf'; pdfDoc ;
Split PDF
const HummusRecipe = ;const pdfDoc = 'input.pdf';const outputDir = path; pdfDoc ;
Encryption
const HummusRecipe = ;const pdfDoc = 'input.pdf' 'output.pdf'; pdfDoc ;