pdfbooklet 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/pdfbooklet.js +6 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfbooklet",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Create booklet from a pdf file suitable for compact printing",
5
5
  "main": "pdfbooklet.js",
6
6
  "bin": {
package/pdfbooklet.js CHANGED
@@ -98,17 +98,13 @@ async function createBooklet(inputPdfPath, outputPdfPath) {
98
98
  const {width, height} = a.size()
99
99
  const w = width - marginInsets.left - marginInsets.right;
100
100
  const h = height - marginInsets.top - marginInsets.bottom;
101
- const xscale = box.width / w;
102
- const yscale = box.height / h;
103
- const scale = xscale < yscale ? xscale : yscale;
104
- const w2 = w * scale;
105
- const h2 = h * scale;
106
-
107
- const dx = -marginInsets.left * scale;
108
- const dy = -marginInsets.top * scale;
101
+ const xScale = box.width / w;
102
+ const yScale = box.height / h;
103
+ const scale = xScale < yScale ? xScale : yScale;
104
+ const x = box.width / 2 + box.x - w * scale / 2 - marginInsets.left * scale;
105
+ const y = box.height / 2 + box.y - h * scale / 2 - marginInsets.bottom * scale;
109
106
  newPage.drawPage(a, {
110
- x: box.x + (box.width - w2) / 2 + dx,
111
- y: box.y + (box.height - h2) / 2 + dy,
107
+ x, y,
112
108
  xScale: scale,
113
109
  yScale: scale,
114
110
  })