Copy link to clipboard
Copied
Hi form, this is my first atempt to create a document using UXP plugin.
From the code below the document is creating 6 Pager document with size 100x210mm and with 3mm bleeds as described in the "documentPreferences"
However I'm not able to set "marginPreferences" as 5mm.
The ocde runs well without errors but margins 15mm (which I guess taken from default parameters - I see 15mm margins in the file > new Window)
Could you mabe give me some suggestions?
const { entrypoints } = require("uxp");
const { app } = require("indesign");
//const indesign = require("indesign");
entrypoints.setup({
panels: {
showPanel: {
show({node} = {}) {
document.getElementById("btnCreateTrifold").addEventListener("click", () => {
const doc = app.documents.add({
marginPreferences: {
top: "5mm",
left: "5mm",
bottom: "5mm",
right: "5mm"
},
documentPreferences: {
pageWidth: "100mm",
pageHeight: "210mm",
pagesPerDocument: 6,
documentBleedBottomOffset: "3mm",
documentBleedInsideOrLeftOffset: "3mm",
documentBleedOutsideOrRightOffset: "3mm",
documentBleedTopOffset: "3mm",
facingPages: false,
allowPageShuffle: false,
}
});
console.log(doc.marginPreferences);
// Set margin sizes
// Set the page size for pages 1 and 6
// Stick pages 1, 2 and 3 together
// Stick pages 4, 5 and 6 together
});
}
}
}
});
Copy link to clipboard
Copied
I'm not JS guy, but I think you should set it inside documentPreferences:
const doc = app.documents.add({
documentPreferences: {
pageWidth: "100mm",
pageHeight: "210mm",
marginPreferences: {
top: "5mm",
left: "5mm",
bottom: "5mm",
right: "5mm"
},
pagesPerDocument: 6,
documentBleedBottomOffset: "3mm",
documentBleedInsideOrLeftOffset: "3mm",
documentBleedOutsideOrRightOffset: "3mm",
documentBleedTopOffset: "3mm",
facingPages: false,
allowPageShuffle: false,
}
});
or something like that.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#MarginPreference.html
Copy link to clipboard
Copied
Hi Robert
The thing is that "marginPreferences" isn't part of the "documentPreferences" 😞
Application.marginPreferences
Document.marginPreferences
Page.marginPreferences
Anyway thank you very much for the replay and I'll continue dive in to find the solution.
Copy link to clipboard
Copied
Right, sorry.
Margin Preferences is readonly of the Document.
I'm on my phone, so you have to setup margins AFTER creating your document.
Copy link to clipboard
Copied
Hi there
I found the way to adjust the margins and the problem was that last time i tried to adjust
Doc.marginPreferences. Eventhough in the documentation we have posibility to use it, it's a wrong way.
In fact there is no way to have margins in document. In normal wey we can adjust margins only on the pages or in master pages.
Application.marginPreferences
Document.marginPreferences
Page.marginPreferences
When we creating the document margins are in the Application side. so the right code will look like this.
First adjust the margins in the app side and then create the document.
// Set margin sizes
app.marginPreferences.bottom = "10mm";
app.marginPreferences.left = "10mm";
app.marginPreferences.right = "10mm";
app.marginPreferences.top = "10mm";
//add document
const doc = app.documents.add();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now