KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
pdfmills
★ 8
Open GitHub ↗
No description available.
Download README (.md)
Explore Similar Repositories
i2c_verilog
:
I2c
searchutils
:
Set of scripts and techniques to search for through office documents, or leverage the Windows indexing service
DeepCommenter
:
No description available.
chinese-calligraphy-dataset
:
No description available.
haskell-setup
:
Haskell setup for vscode with cabal and nix
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
pdfmills
?
Download (.md)
# pdfmills A simple DSL wrapper around [pdfkit](https://github.com/foliojs/pdfkit) ## What's inside - Elements: - `Text` or `Paragraph`s - `Image`s - Layouts: - `Block` - `Flex` - `RatioFlex` - `EqualFlex` - Spacing: - `LineBreaks` for vertical spaces - `Margin` - `Padding` - Automatic page management ## How to install ```sh yarn add @random-guys/pdfmills ``` or ```sh npm i @random-guys/pdfmills ``` ## Get Started ```ts import { block, Text } from "@random-guys/pdfmills"; // arrange elements vertically const divStyle: BlockStyle = { display: "block", margin: 0 }; const flexStyle: FlexStyle = { display: "flex" }; div( { ...divStyle, margin: 4 }, row({ style: flexStyle, elements: [ col(p("START DATE"), ["right"], 60), col(p("ACCOUNT NUMBER", alignRight), ["right", "left"], 100), col(p("INCOME", alignRight), ["left"], 60) ] }), row({ style: flexStyle, elements: [ col(p("12/03/07", { ...headerFont, align: "left" }), ["right"], 60), col(p("0087567843", headerFont), ["right", "left"], 100), col(p("₦250,000", headerFont), ["left"], 60) ] }), br(20), row({ style: flexStyle, elements: [ col(p("END DATE"), ["right"], 60), col(p("BALANCE", alignRight), ["right", "left"], 100), col(p("INCOME", alignRight), ["left"], 60) ] }), row({ style: flexStyle, elements: [ col(p("12/03/07", { ...headerFont, align: "left" }), ["right"], 60), col(p("₦560,000", headerFont), ["right", "left"], 100), col(p("₦25,000", headerFont), ["left"], 60) ] }) ); // arrange elements horizontally const headerFont: FontStyle = { ...alignRight, fontColor: [130, 134, 145] }; row({ style: flexStyle, elements: [ col(p("12/03/07", { ...headerFont, align: "left" }), ["right"], 60), col(p("0087567843", headerFont), ["right", "left"], 100), col(p("₦250,000", headerFont), ["left"], 60) ] }); // load the element const elements = [firstRow, br(50), secondRow, br(40), thirdRow]; // write the elements to the buffer render(context, elements); // you can write the buffer to the file stream save(context.raw, "output.pdf"); // you can also upload the file to Azure blob storage import { Blobber } from "@random-guys/blobber"; import uuid from "uuid/v4"; const tempName = `${uuid()}.pdf`; const uploader = new Blobber<any>("reports"); context.raw.end(); return await uploader.streamLocalFile(tempName, this.context.raw); ``` Checkout the [examples](https://github.com/random-guys/pdfmills/tree/develop/examples) folder for real life examples.