Hi, Ulrich
Sorry, but now I’m even more confused. I thought my script already does that, especially since it’s not possible to add page to a sheet definition because that returns a javascript exception error.
Here is a breakdown of imposition section of my script:
// Create imposition
const imposition = new Impose({ unit: "mm" });
// Create a new sheet definition
const sheetID = imposition.addSheetDef(sheetWidth, sheetHeight, "mm");
...
const numSheets = Math.ceil(lastPage / group); // Total number of sheets for imposition to iterate
...
// ===== IMPOSITION =====
let pageIndex = 0;
let groupPageCount = Math.ceil(lastPage / numOfSlots);
if (sides == 2 && groupPageCount % 2 !== 0)
groupPageCount++;
do {
// Add front and reverse sheets (if DS) for each iteration
const frontSheetID = imposition.addSheet( sheetID );
const reverseSheetID = (sides == 2) ? imposition.addSheet(sheetID) : "";
let groupPage = pageIndex;
// Iterate through all the columns and rows until it fills one sheet (front and reverse if DS)
for (let col = 0; col < numCols; col++) {
for (let row = 0; row < numRows; row++) {
...
// ===== FRONT SHEET =====
...
// Create front sheet slot
const frontSlotID = imposition.addSlot(frontSheetID, {
...
} );
// Assign odd pages to the front sheet
imposition.addPage(frontSheetID, frontSlotID, groupPage);
// ===== REVERSE SHEET =====
if (sides == 2) {
...
// Create reverse sheet slot
const reverseSlotID = imposition.addSlot(reverseSheetID, {
...
} );
// Assign next page to the reverse sheet in a mirrored position
imposition.addPage(reverseSheetID, reverseSlotID, groupPage + 1);
}
groupPage += groupPageCount;
}
}
groupPage += groupPageCount;
pageIndex += sides == 2 ? 2 : 1;
groupPage = pageIndex;
currentSheet++;
} while (currentSheet <= numSheets);
What makes this all even more confusing to me is that I have another script that is nearly identical that it works fine (below). The only difference between these scripts is that one fills the page top down per column and the other fills the page left-to-right per row (they are a copy and paste of each other).
Dynamic Cut and Stack (left to right per row) DEBUG.kfpx (25.3 KB)
Result of the “left to right per row” script (correct result).
However, that being said, after reviewing and comparing the two scripts I noticed one other difference which I thought it was a mistake.
When adding a page to the reverse of the sheet:
-The script that works is placing the slot on what it seems to be the front sheet instead of the reverse:
const reverseSlotID = imposition.addSlot(frontSheetID, {…});
-I thought this was a mistake and changed the new script (“top down per column”) to what you see above:
const reverseSlotID = imposition.addSlot(reverseSheetID, {…});
If I change the “top down per column” script to add the reverseSlotID to the frontSheetID, it works correctly:
Is my logic for a double sided document off?
- Create front sheet
- Create reverse sheet
- Add slot to front sheet
- Add page to front slot
- Add slot to reverse sheet
- Add page to reverse slot