Skip to main content
Known Participant
March 28, 2024
Question

How to create a document with a default unit of mm by jsx?

  • March 28, 2024
  • 1 reply
  • 334 views

jsx guide:

app.documents.add([documentColorSpace] [, width] [, height] [, numArtBoards]
    [, artboardLayout] [, artboardSpacing] [, artboardRowsOrCols]
)

no param to set the unit

or can I set the unit after the document created? anyone advice?

This topic has been closed for replies.

1 reply

m1b
Community Expert
Community Expert
March 28, 2024

Hi @LoveYou阿逗逼6666, you can make a document preset:

var myDocPreset = new DocumentPreset;
myDocPreset.artboardLayout = DocumentArtboardLayout.GridByRow;
myDocPreset.artboardRowsOrCols = 1;
myDocPreset.artboardSpacing = 20;
myDocPreset.colorMode = DocumentColorSpace.RGB;
myDocPreset.documentBleedLink = true;
myDocPreset.documentBleedOffset = [0, 0, 0, 0];
myDocPreset.height = 5000;
myDocPreset.numArtboards = 1;
myDocPreset.previewMode = DocumentPreviewMode.DefaultPreview;
myDocPreset.rasterResolution = DocumentRasterResolution.ScreenResolution;
myDocPreset.title = 'Test';
myDocPreset.transparencyGrid = DocumentTransparencyGrid.TransparencyGridNone;
myDocPreset.units = RulerUnits.Millimeters;
myDocPreset.width = 5000;

var newDoc = app.documents.addDocument("Basic RGB", myDocPreset);

 

Just an example, but I've set the RulerUnits to millimeters to show you.

- Mark 

m1b
Community Expert
Community Expert
March 28, 2024

Also can do this way:

var myDocPreset = app.getPresetSettings('Web');
myDocPreset.width = 960;
myDocPreset.height = 768;
myDocPreset.units = RulerUnits.Millimeters;

var newDoc = app.documents.addDocument(DocumentPresetType.Web, myDocPreset);

 - Mark