Skip to content

Commit

Permalink
PRINT startY for bulletPoints direct after titles
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreKelling committed Feb 21, 2024
1 parent f696a23 commit 7318d18
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jspdf-product-label-54x70",
"version": "1.2.7",
"version": "1.2.8",
"main": "src/app.js",
"author": "André Kelling",
"description": "Dymo Label PDF printing 54 x 70mm.",
Expand Down
4 changes: 2 additions & 2 deletions src/print/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export default (printDataArr) => {
// <><>><><>><>><><><><><>>><><<><><><><>

printDataArr.forEach((printData, index) => {
titles(doc, printData, pageWidth);
const startY = titles(doc, printData, pageWidth);

bulletPoints(doc, printData.bulletPoints, pageWidth);
bulletPoints(doc, printData.bulletPoints, pageWidth, startY);

// print qr code before text. so that any white margin from image is below text.
qrCode(doc, printData.qrCode, pageWidth);
Expand Down
4 changes: 2 additions & 2 deletions src/print/partials/bullet-points.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import JsPDF from 'jspdf';
* @param {JsPDF} doc
* @param {string[]} bulletPoints
* @param {number} pageWidth
* @param {number} startY
*/
export default (doc, bulletPoints, pageWidth) => {
export default (doc, bulletPoints, pageWidth, startY) => {
if (!bulletPoints) {
return;
}

const startX = 2;
let startY = doc.vars.startY.bulletPoints;
const lineSpacing = doc.vars.lineSpacing - 1;

doc.setFontSize(doc.vars.fontSizes.SmallestFontSize);
Expand Down
1 change: 0 additions & 1 deletion src/print/partials/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default (doc) => {
doc.vars.startY = {
logo:1,
titles:14,
bulletPoints:35,
productCode:52,
qrCode:50,
productId:67.5
Expand Down
7 changes: 6 additions & 1 deletion src/print/partials/titles.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import JsPDF from 'jspdf';
* @param {JsPDF} doc
* @param {PrintData} printData
* @param {number} pageWidth
*
* @return number
*/
export default (doc, printData, pageWidth) => {
const pageCenterX = pageWidth / 2;
Expand All @@ -31,6 +33,9 @@ export default (doc, printData, pageWidth) => {
doc.setFontSize(doc.vars.fontSizes.SubTitleFontSize);
const productColour = printData.productColour;
if (productColour) {
doc.text(productColour, pageCenterX, startY + 1, {align: 'center'});
doc.text(productColour, pageCenterX, startY, {align: 'center'});
startY += doc.vars.lineSpacing;
}

return startY;
}

0 comments on commit 7318d18

Please sign in to comment.