From 134485a6d637ce5b422098c08bccb274c73bca86 Mon Sep 17 00:00:00 2001 From: Tan Kian-ting Date: Wed, 15 Nov 2023 12:37:21 +0800 Subject: [PATCH] add grid --- blank.pdf | Bin 0 -> 9625 bytes package-lock.json | 71 ++++++++++++++++++++++++++++++++++++--- package.json | 1 + src/libclo/breakLines.js | 2 +- src/libclo/index.js | 34 +++++++++++++++++++ src/libclo/index.ts | 43 +++++++++++++++++++++++- 6 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 blank.pdf diff --git a/blank.pdf b/blank.pdf new file mode 100644 index 0000000000000000000000000000000000000000..92353b206dc999161f58d5c3de9d0d1e08a62ea1 GIT binary patch literal 9625 zcmaiaWmFVU*Df71v`EMRLxT(<(k)1*fKo#VNW%=B(xIfZFqD9T0@5MfokN$DfYQ=^ z2Ym0hzPr}D)@AYIJhSWBd!Lwd*05+km*;xIEd*c*MEwB(f?!^-(`#FRxHy1E-p1b5 z(izMnZ*S&m`P|an$-)xAqiX4BtZShtcx;*t+E)Zfs3^V^-saPl$ybu7Ym(Cv;G z$XdKP`BHOYesgW&?|C`#^Y$k8_VV)fJoe}H7Ej*Cc)=H!=trwx{Qc9VZkLOjZ%yc> z{4dUTzRz_1#FwQJzBoJ932e;;65iI#M_A*@+@{k@U2n{3_#dBapgr&phMp<#meavr6u@+FspuQsktNS}pvy~;MlSz{IQJs_<#mOA8%C6{@|)vuqwDt4 zn;AY9MP|ZQ~^~4}m;!|7JU%?c6voGhb<+9&!6-JFh|5^^D59W_=Z~ zTKz}34Yqh@q7>?1>UZ3F0!3GLpJ`dVFU&r^t&W<`(w3I*TbNU*jjm zZ~^*Y&Mm)~qr-3iM`YF9RUOuZ8~K@_7Ph++tazqmAKD@^+JN9VVhpqOi4iscrC3M zpl$q*jJ@EAF{ClIzH+a7iy1D-E#t#m3|+0{a=z(cf#II{RrAhOSrQ_OWm6{5J1HK` z)p)=EIJ$A@T^)O&VjT=C#lxjpZkb;_v*5;lP7)FeY?O~HYFtzY%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MNUKh{{X#jR%8GG literal 0 HcmV?d00001 diff --git a/package-lock.json b/package-lock.json index 4883791..52593f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "jsdom": "^22.1.0", "minimist": "^1.2.8", "npx": "^10.2.2", + "pdf-lib": "^1.17.1", "pdfkit": "^0.13.0", "typescript-parsec": "^0.3.4" }, @@ -741,6 +742,22 @@ "node": ">= 8" } }, + "node_modules/@pdf-lib/standard-fonts": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz", + "integrity": "sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==", + "dependencies": { + "pako": "^1.0.6" + } + }, + "node_modules/@pdf-lib/upng": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@pdf-lib/upng/-/upng-1.0.1.tgz", + "integrity": "sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==", + "dependencies": { + "pako": "^1.0.10" + } + }, "node_modules/@swc/helpers": { "version": "0.4.36", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.36.tgz", @@ -9569,6 +9586,11 @@ "node": ">=8" } }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -9642,6 +9664,17 @@ "node": "*" } }, + "node_modules/pdf-lib": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/pdf-lib/-/pdf-lib-1.17.1.tgz", + "integrity": "sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==", + "dependencies": { + "@pdf-lib/standard-fonts": "^1.0.0", + "@pdf-lib/upng": "^1.0.1", + "pako": "^1.0.11", + "tslib": "^1.11.1" + } + }, "node_modules/pdfkit": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/pdfkit/-/pdfkit-0.13.0.tgz", @@ -10515,8 +10548,7 @@ "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "node_modules/tslint": { "version": "6.1.3", @@ -11736,6 +11768,22 @@ "fastq": "^1.6.0" } }, + "@pdf-lib/standard-fonts": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz", + "integrity": "sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==", + "requires": { + "pako": "^1.0.6" + } + }, + "@pdf-lib/upng": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@pdf-lib/upng/-/upng-1.0.1.tgz", + "integrity": "sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==", + "requires": { + "pako": "^1.0.10" + } + }, "@swc/helpers": { "version": "0.4.36", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.36.tgz", @@ -18319,6 +18367,11 @@ "release-zalgo": "^1.0.0" } }, + "pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -18371,6 +18424,17 @@ "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true }, + "pdf-lib": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/pdf-lib/-/pdf-lib-1.17.1.tgz", + "integrity": "sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==", + "requires": { + "@pdf-lib/standard-fonts": "^1.0.0", + "@pdf-lib/upng": "^1.0.1", + "pako": "^1.0.11", + "tslib": "^1.11.1" + } + }, "pdfkit": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/pdfkit/-/pdfkit-0.13.0.tgz", @@ -19001,8 +19065,7 @@ "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "tslint": { "version": "6.1.3", diff --git a/package.json b/package.json index 1f75e5c..90711f6 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "jsdom": "^22.1.0", "minimist": "^1.2.8", "npx": "^10.2.2", + "pdf-lib": "^1.17.1", "pdfkit": "^0.13.0", "typescript-parsec": "^0.3.4" } diff --git a/src/libclo/breakLines.js b/src/libclo/breakLines.js index e5d0865..b94d123 100644 --- a/src/libclo/breakLines.js +++ b/src/libclo/breakLines.js @@ -14,7 +14,7 @@ class BreakLineAlgorithm { isBreakPoint(item) { return item.newLined !== undefined; } - /**check if a boeitem is BreakPoint Type */ + /**check if a boeitem is HGlue Type */ isHGlue(item) { return item.stretchFactor !== undefined; } diff --git a/src/libclo/index.js b/src/libclo/index.js index c2b873e..17b36b4 100644 --- a/src/libclo/index.js +++ b/src/libclo/index.js @@ -36,6 +36,9 @@ exports.Clo = exports.calculateTextWidthHeightAux = exports.calculateTextWidthHe const canva_1 = require("../canva"); const fontkit = __importStar(require("fontkit")); const breakLines = __importStar(require("./breakLines")); +require("pdfkit"); +const pdf_lib_1 = require("pdf-lib"); +const fs = __importStar(require("fs")); /** * TYPES */ @@ -364,6 +367,37 @@ class Clo { //console.log(breakLineAlgorithms.totalCost(a,70)); let segmentedNodes = breakLineAlgorithms.segmentedNodes(a, 70); console.log(this.segmentedNodesToFrameBox(segmentedNodes, this.attrs["defaultFrameStyle"])); + // generate pdf + const pdfDoc = yield pdf_lib_1.PDFDocument.create(); + var page = pdfDoc.addPage(); + page.drawText('You can create PDFs!'); + for (var j = 0; j < 1000; j += 5) { + if (j % 50 == 0) { + page.drawText(i.toString(), { x: 50, y: j }); + } + page.drawLine({ + start: { x: 0, y: j }, + end: { x: 1000, y: j }, + thickness: 0.5, + color: (0, pdf_lib_1.rgb)(0.75, 0.2, 0.2), + opacity: 0.20, + }); + } + for (var i = 0; i < 1000; i += 5) { + if (i % 50 == 0) { + page.drawText(i.toString(), { x: i, y: 50 }); + } + page.drawLine({ + start: { x: i, y: 0 }, + end: { x: i, y: 1000 }, + thickness: 0.5, + color: (0, pdf_lib_1.rgb)(0.75, 0.2, 0.2), + opacity: 0.20, + }); + } + pdfDoc.save(); + const pdfBytes = yield pdfDoc.save(); + fs.writeFileSync("blank.pdf", pdfBytes); }); } segmentedNodesToFrameBox(segmentedNodes, frame) { diff --git a/src/libclo/index.ts b/src/libclo/index.ts index b64a819..bcd6a46 100644 --- a/src/libclo/index.ts +++ b/src/libclo/index.ts @@ -5,6 +5,10 @@ import { JSDOM } from "jsdom"; import * as fontkit from "fontkit"; import * as util from "node:util"; import * as breakLines from "./breakLines"; +import "pdfkit"; +import PDFKitPage from "pdfkit/js/page"; +import { ColorTypes, PDFDocument, rgb } from "pdf-lib"; +import * as fs from "fs"; /** * TYPES @@ -443,7 +447,44 @@ export class Clo{ //console.log(breakLineAlgorithms.totalCost(a,70)); let segmentedNodes = breakLineAlgorithms.segmentedNodes(a, 70); - console.log(this.segmentedNodesToFrameBox(segmentedNodes, this.attrs["defaultFrameStyle"])); + console.log( + this.segmentedNodesToFrameBox(segmentedNodes, this.attrs["defaultFrameStyle"])); + + // generate pdf + const pdfDoc = await PDFDocument.create(); + var page = pdfDoc.addPage(); + page.drawText('You can create PDFs!'); + + for (var j = 0; j<1000; j+=5){ + if (j %50 == 0){ + page.drawText(i.toString(), {x: 50, y: j}); + } + + page.drawLine({ + start: { x: 0, y: j }, + end: { x: 1000, y: j }, + thickness: 0.5, + color: rgb(0.75, 0.2, 0.2), + opacity: 0.20, + }); + } + + for (var i = 0; i<1000; i+=5){ + if (i % 50 == 0){ + page.drawText(i.toString(), {x: i, y: 50}); + } + page.drawLine({ + start: { x: i, y: 0 }, + end: { x: i, y: 1000 }, + thickness: 0.5, + color: rgb(0.75, 0.2, 0.2), + opacity: 0.20, + }); + } + pdfDoc.save(); + + const pdfBytes = await pdfDoc.save(); + fs.writeFileSync("blank.pdf", pdfBytes); } segmentedNodesToFrameBox(segmentedNodes : BoxesItem[][], frame : FrameBox) : Box{ -- 2.39.2