@akashkore5/pdf-n-up-calculator 0.0.0-stage → 1.0.0
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/README.md +30 -2
- package/index.js +43 -0
- package/package.json +23 -4
package/README.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @akashkore5/pdf-n-up-calculator
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Calculate N-up grid layouts, bounding boxes, and imposition geometries for 2-in-1, 4-in-1, and multi-page per sheet PDF documents.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### 🌐 Live In-Browser Client-Side Tool
|
|
8
|
+
Need to quickly impose and print multi-page sheets without command lines or Adobe Acrobat subscriptions?
|
|
9
|
+
Use the free web app at **[EditPDFKit - 2-in-1 / 4-in-1 PDF Maker](https://www.editpdfkit.com/tools/pdf-n-up)**.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
### Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @akashkore5/pdf-n-up-calculator
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Usage
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
const { calculateNUpGrid } = require('@akashkore5/pdf-n-up-calculator');
|
|
23
|
+
|
|
24
|
+
// Calculate 4-in-1 layout for standard A4 sheet
|
|
25
|
+
const layout = calculateNUpGrid(4, 595.28, 841.89);
|
|
26
|
+
console.log(layout);
|
|
27
|
+
// { cols: 2, rows: 2, slotWidth: 297.64, slotHeight: 420.945, totalSlots: 4 }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### License
|
|
31
|
+
MIT © [Akash Kore](https://github.com/akashkore5) • [EditPDFKit](https://www.editpdfkit.com)
|
package/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @akashkore5/pdf-n-up-calculator
|
|
3
|
+
* Helper calculations for N-up PDF sheet imposition (2-in-1, 4-in-1, 9-in-1).
|
|
4
|
+
* Powered by https://www.editpdfkit.com/tools/pdf-n-up
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calculates row and column dimensions for grid imposition
|
|
9
|
+
* @param {number} nUpCount - 2, 4, 9, 16
|
|
10
|
+
* @param {number} sheetWidth - Sheet width in points (default A4: 595.28)
|
|
11
|
+
* @param {number} sheetHeight - Sheet height in points (default A4: 841.89)
|
|
12
|
+
* @returns {Object} Imposition layout metrics
|
|
13
|
+
*/
|
|
14
|
+
function calculateNUpGrid(nUpCount = 2, sheetWidth = 595.28, sheetHeight = 841.89) {
|
|
15
|
+
let cols = 1;
|
|
16
|
+
let rows = 2;
|
|
17
|
+
|
|
18
|
+
if (nUpCount === 4) {
|
|
19
|
+
cols = 2;
|
|
20
|
+
rows = 2;
|
|
21
|
+
} else if (nUpCount === 9) {
|
|
22
|
+
cols = 3;
|
|
23
|
+
rows = 3;
|
|
24
|
+
} else if (nUpCount === 16) {
|
|
25
|
+
cols = 4;
|
|
26
|
+
rows = 4;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const slotWidth = sheetWidth / cols;
|
|
30
|
+
const slotHeight = sheetHeight / rows;
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
cols,
|
|
34
|
+
rows,
|
|
35
|
+
slotWidth,
|
|
36
|
+
slotHeight,
|
|
37
|
+
totalSlots: cols * rows
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
calculateNUpGrid
|
|
43
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akashkore5/pdf-n-up-calculator",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Grid, scaling, and offset calculation utility for 2-in-1, 4-in-1, and N-up PDF page imposition and printing.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pdf",
|
|
8
|
+
"n-up",
|
|
9
|
+
"2-in-1",
|
|
10
|
+
"4-in-1",
|
|
11
|
+
"imposition",
|
|
12
|
+
"pdf-printing",
|
|
13
|
+
"editpdfkit"
|
|
14
|
+
],
|
|
15
|
+
"author": "Akash Kore <https://github.com/akashkore5>",
|
|
16
|
+
"homepage": "https://www.editpdfkit.com/tools/pdf-n-up",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/akashkore5/pdf-n-up-calculator.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/akashkore5/pdf-n-up-calculator/issues"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT"
|
|
25
|
+
}
|