-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* featue/onward-jspdf: UPDATE webpack and webpack-dev-server UPDATE go for jspdf in version 2.5.1
- Loading branch information
Showing
29 changed files
with
3,603 additions
and
1,815 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Editor configuration, see https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
docs/vendors-node_modules_dompurify_dist_purify_js.bundle.js
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
docs/vendors-node_modules_html2canvas_dist_html2canvas_js.bundle.js
Large diffs are not rendered by default.
Oops, something went wrong.
1,677 changes: 1,677 additions & 0 deletions
1,677
docs/vendors-node_modules_jspdf_node_modules_canvg_lib_index_es_js.bundle.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
{ | ||
"name": "jspdf-template", | ||
"version": "3.1.1", | ||
"main": "app.js", | ||
"version": "4.0.0", | ||
"main": "src/app.js", | ||
"author": "André Kelling", | ||
"description": "Invoice template and setup for jsPDF usage in ES6.", | ||
"repository": "https://github.com/AndreKelling/jspdf-template", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "webpack", | ||
"webpack": "webpack-dev-server" | ||
"build": "webpack --mode=development", | ||
"dev": "webpack-dev-server --mode=development" | ||
}, | ||
"dependencies": { | ||
"jspdf-yworks": "^2.1.1", | ||
"svg2pdf.js": "^1.5.0", | ||
"webpack": "^5.72.0", | ||
"jspdf": "^2.5.1", | ||
"svg2pdf.js": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"webpack": "^5.73.0", | ||
"webpack-cli": "^4.9.2", | ||
"webpack-dev-server": "^4.8.1" | ||
"webpack-dev-server": "^4.9.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import fetchSvg from "../utils/fetchSvg"; | ||
|
||
export default (doc, printData, pageNr) => { | ||
const pageWidth = doc.internal.pageSize.width; | ||
const pageCenterX = pageWidth / 2; | ||
let n; | ||
|
||
return fetchSvg('img/logo.svg').then(async ({svg, width}) => { | ||
if (svg) { | ||
n = 0; | ||
|
||
while (n < pageNr) { | ||
n++; | ||
|
||
doc.setPage(n); | ||
|
||
await doc.svg(svg, { | ||
x: pageCenterX - width / 2, | ||
y: 25 | ||
}); | ||
|
||
doc.link(pageCenterX - width / 2, 25, width, 60, {url: printData.personalInfo.website}); | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import newPage from '../utils/newPage'; | ||
|
||
export default async (doc, printData, startY, fontSize, lineSpacing) => { | ||
|
||
let startX = 57; | ||
const pageWidth = doc.internal.pageSize.width; | ||
const endX = pageWidth - startX; | ||
|
||
const tablecol2X = 386; | ||
const tablecol3X = 460; | ||
|
||
doc.setFontSize(fontSize); | ||
doc.setFont(doc.vars.fontFamily, doc.vars.fontWeightNormal); | ||
|
||
//-------Table Header--------------------- | ||
startY += lineSpacing * 1.5; | ||
|
||
doc.text(printData.label.tableItems, startX, startY); | ||
doc.text(printData.label.tableQty, tablecol2X, startY, {align: 'right'}); | ||
doc.text(printData.label.tableSinglePrice, tablecol3X, startY, {align: 'right'}); | ||
doc.text(printData.label.tableSingleTotal, endX, startY, {align: 'right'}); | ||
|
||
startY += lineSpacing; | ||
|
||
doc.line(startX, startY, endX, startY); | ||
|
||
startY += lineSpacing * 1.5; | ||
|
||
//-------Table Body--------------------- | ||
|
||
const items = Object.values(printData.items); | ||
|
||
for (const item of items) { | ||
doc.setFont(doc.vars.fontFamily, doc.vars.fontWeightBold); | ||
const splitTitle = doc.splitTextToSize( | ||
item.title, | ||
tablecol2X - startX - lineSpacing * 1.5 | ||
); | ||
const heightTitle = splitTitle.length * doc.internal.getLineHeight(); | ||
|
||
doc.setFont(doc.vars.fontFamily, doc.vars.fontWeightNormal); | ||
const splitDescription = doc.splitTextToSize( | ||
item.description, | ||
tablecol2X - startX - lineSpacing * 1.5 | ||
); | ||
const heightDescription = splitDescription.length * doc.internal.getLineHeight(); | ||
|
||
// <><>><><>><>><><><><><>>><><<><><><><> | ||
// new page check before item output | ||
// @todo: display table header at start of a new page | ||
startY = await newPage(doc, startY, heightDescription + heightTitle); | ||
|
||
doc.setFont(doc.vars.fontFamily, doc.vars.fontWeightBold); | ||
doc.text(splitTitle, startX, startY); | ||
|
||
// tweak Y to be below title. fits nicer with long descriptions. descriptions will be probably taking a row space while titles do not. | ||
startY += heightTitle; | ||
|
||
doc.setFont(doc.vars.fontFamily, doc.vars.fontWeightNormal); | ||
doc.text(splitDescription, startX, startY); | ||
|
||
doc.text(item.qty, tablecol2X, startY, {align: 'right'}); | ||
|
||
doc.text(item.amount, tablecol3X, startY, {align: 'right'}); | ||
|
||
doc.text(item.total, endX, startY, {align: 'right'}); | ||
|
||
startY += heightDescription + lineSpacing; | ||
} | ||
|
||
return startY; | ||
} |
Oops, something went wrong.