Skip to content

Commit

Permalink
Merge pull request #27 from h1dd3nsn1p3r/development
Browse files Browse the repository at this point in the history
🔥 Added: Font and style option in config.
  • Loading branch information
h1dd3nsn1p3r authored Jun 23, 2024
2 parents e4380f9 + 3d73010 commit 8f31f2a
Show file tree
Hide file tree
Showing 36 changed files with 274 additions and 464 deletions.
42 changes: 42 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# editorconfig.org
# Ref: https://editorconfig.org/

# top-most EditorConfig file
root = true

[*]
indent_style = tab
tab_width = 2
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{js, jsx, ts, tsx, mjs, cjs, cts, mts}]
indent_style = tab
tab_width = 2
indent_size = 2

[*.{svelte, vue}]
indent_style = tab
tab_width = 2
indent_size = 2

[*.json]
indent_style = tab
tab_width = 2
indent_size = 2

[*.{css, scss, sass}]
indent_style = tab
tab_width = 4
indent_size = 4

[*.php]
indent_style = tab
tab_width = 2
indent_size = 2
28 changes: 14 additions & 14 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Deploy updates to npm
on:
release:
types: [published]
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "18"
- run: npm install
- run: npm run build
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "18"
- run: npm install
- run: npm run build
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ examples
src
.github
.gitignore
.editorconfig
pnpm-lock.yaml
tsconfig.json
tsup.config.ts
56 changes: 48 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ Once you call the `create` method, it will return a promise. You can either use

If required you can change the configuration of the invoice. It is an object with the following structure:

### Strings

All the text strings that are used in the invoice can be customized. For example:

```js
const { PDFInvoice } = require('@h1dd3nsn1p3r/pdf-invoice');
Expand Down Expand Up @@ -308,15 +312,57 @@ const create = async(): Promise<void> => {
}
```

### Config limitations:
### Fonts

For now only `latin` characters are supported. It seems like a limitation of `Helvetica` font. I'll be adding support for other languages soon.
Following are the fonts that are available build-in with the library:
- Helvetica
- Times
- Courier
All these three fonts includes regular, bold, italic and bold-italic styles. You can use them in the configuration object. For example:
```js
const config = {
// ....
style: {
font: "Helvetica", // "Helvetica", "Times", "Courier"
fontSize: 10, // Optional. Default is 10.
lineHeight: 1.8, // Optional. Default is 1.8.
color: "#000000", // Optional. Default is black.
},
};
```
Any font can be used with the `font` option by passing the fonts `TTF` files path. For example:
```js
const config = {
// ....
font: {
Noto: {
normal: path.join(__dirname, "fonts/noto/regular.ttf"),
italics: path.join(__dirname, "fonts/noto/italic.ttf"),
bold: path.join(__dirname, "fonts/noto/bold.ttf"),
bolditalics: path.join(__dirname, "fonts/noto/bold-italic.ttf"),
},
},
style: {
font: "Noto",
fontSize: 10, // Optional. Default is 10.
lineHeight: 1.8, // Optional. Default is 1.8.
color: "#000000", // Optional. Default is black.
},
};
```
If you need additional information do check the [example](https://github.com/h1dd3nsn1p3r/pdf-invoice/blob/development/examples/example.ts). In the example, I have used "Noto" and the `TTF` files of Noto font are included in the `fonts` directory. If you have non-latin characters, then you can use any custom font that supports the characters.
## Types
This library is written in TypeScript. If you need to import the types, then you can import them from `global.d.ts` file. Refer to [Global types](https://github.com/h1dd3nsn1p3r/pdf-invoice/blob/stable/global.d.ts) file for more information.
Import example:
Example:
```js
import type { CompanyInfo, CustomerInfo, InvoiceInfo, ItemInfo, QRInfo, InvoicePayLoad } from '@h1dd3nsn1p3r/pdf-invoice/global.d.ts';
Expand All @@ -329,9 +375,3 @@ Refer to [releases](https://github.com/h1dd3nsn1p3r/pdf-invoice/releases) sectio
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## Todo
- [ ] Add design/style options.
- [ ] Add configuration options - (Strings, Fonts, Styles, etc.)
- [ ] Add support for multi-language.
151 changes: 0 additions & 151 deletions dist/class/invoice.d.mts

This file was deleted.

Loading

0 comments on commit 8f31f2a

Please sign in to comment.