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.
- package/package.json +1 -1
- package/pdfbooklet.js +6 -10
package/package.json
CHANGED
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
|
|
102
|
-
const
|
|
103
|
-
const scale =
|
|
104
|
-
const
|
|
105
|
-
const
|
|
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
|
|
111
|
-
y: box.y + (box.height - h2) / 2 + dy,
|
|
107
|
+
x, y,
|
|
112
108
|
xScale: scale,
|
|
113
109
|
yScale: scale,
|
|
114
110
|
})
|