Copy link to clipboard
Copied
Hi all,
Error 1200: an Illustrator error occurred: 1129270854 (FNOC)
Line: 19 -> doc.saveAs(File(originalDocPath + "|" + originalDocName + "_SAMPLE FA.pdf"), opts);
Right at the end of running the script to outline fonts, delete unused swatches etc, I get the above. Everything has worked just the file saving part fails.
And the thing thats driving my totally nuts, is it works on M1 iMacs but NOT with any M2 Studios. I've tried opening the .js files, duplicating and re-saving them, from the Mac Studio...
HELLLLLLLLP... I'm at my wits end. BIG, BIG thank you for any help.
HNY!!!
ooooooh, I think I see what the problem might be
perhaps you didn't mean to use the Pipe "|" but instead you meant to use the Slash "/" (Folder separator)
replace this
var fileName = originalDocPath + "|" + originalDocName + "_SAMPLE FA.pdf";
with this
var fileName = originalDocPath + "/" + originalDocName + "_SAMPLE FA.pdf";
Copy link to clipboard
Copied
On Windows, the Pipe Character "|" is not allowed in a file name, that might be the case on M2 as well.
Carlos
Copy link to clipboard
Copied
Thanks for the reply.... so if that was the case on a Mac also, what would go in its place?
Copy link to clipboard
Copied
Thanks for the reply.... so if that was the case on a Mac also, what would go in its place?
By @LEE324144488r75
this should be pretty easy to test, replace the "|" character in your original program with a dash "-" to see if it works
Copy link to clipboard
Copied
Hi @LEE324144488r75, I suggest adding something like this:
try {
var fileName = originalDocPath + "|" + originalDocName + "_SAMPLE FA.pdf";
doc.saveAs(File(fileName), opts);
} catch (error) {
alert('Error saving to "' + fileName + '". (' + error.message + ')');
// handle error here
}
This will at least connect the error with the specific path that it was trying.
Like Carlos, I suspect it is a bad path. However, I have used pipe characters on MacOS plenty of times and I don't think that is the problem. Pipe characters must be escaped or quoted on the command line, but many characters are like that. On MacOS, I believe colons are the main character to avoid. Anyway, take a screenshot of the error alert that shows the path and that way you can test that path independent of your script. An alternative issue could be the contents of `opts` which we don't know. If you use VSCode with the ExtendScript Debugger, you can put a debugger call right before the saveAs:
var fileName = originalDocPath + "|" + originalDocName + "_SAMPLE FA.pdf";
debugger;
doc.saveAs(File(fileName), opts);
and then, in your Debug console you can type `opts` to see its contents:
Hope that helps as a start.
- Mark
Copy link to clipboard
Copied
// The active document
var doc = app.activeDocument;
// The path of the original document
var originalDocPath = doc.path;
// The name of the original document
var originalDocName = doc.name;
// An array of all the layers in the active document
var allLayers = doc.layers;
// Get just the file name. Ignore the file extension .pdf and .ai
originalDocName = originalDocName.replace(/\.pdf|\.ai/gi, "")
{
// Setup pdf save options
var opts = new PDFSaveOptions();
// Use the preset named "XXX"
opts.pdfPreset = "SEBNINI Press Quality";
// Save the document in the original folder using the original name with _SAMPLE FA suffix
{
var fileName = originalDocPath + "|" + originalDocName + "_SAMPLE FA.pdf";
doc.saveAs(File(fileName), opts);
} catch (error) {
alert('Error saving to "' + fileName + '". (' + error.message + ')');
// handle error here
}
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
Copy link to clipboard
Copied
Tried that, unless i placed it wrong, error attached. Thanks for trying buddy.
Copy link to clipboard
Copied
On line 19 of your posted code, you left out the
try {
Copy link to clipboard
Copied
Try running this script on the M2 machine:
(function () {
var targetPdfName = 'SEBNINI Press Quality';
alert('"' + targetPdfName + '" ' + (pdfPresetExists(targetPdfName) ? 'is good!' : 'doesn\'t exist!'));
function pdfPresetExists(name) {
var names = app.PDFPresetsList;
for (var i = 0; i < names.length; i++)
if (name === names[i])
return true;
return false;
};
})();
Maybe the pdf preset isn't installed?
Copy link to clipboard
Copied
ooooooh, I think I see what the problem might be
perhaps you didn't mean to use the Pipe "|" but instead you meant to use the Slash "/" (Folder separator)
replace this
var fileName = originalDocPath + "|" + originalDocName + "_SAMPLE FA.pdf";
with this
var fileName = originalDocPath + "/" + originalDocName + "_SAMPLE FA.pdf";
Copy link to clipboard
Copied
Samer error - sorry
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Carlos is right here—it definitely should be a forward slash.
Copy link to clipboard
Copied
But.... I just changed the original version for a / and it's now working without the VAR work around. I don't understand why it's fine on the M1s, but anyways.
Hats off to you both. We got there in the end. Thank you so much!
Copy link to clipboard
Copied
Glad you got it working! The "VAR workaround" isn't a workaround—I just added an alert that would show you the exact path, because the path is usually the cause of problems with files/opening/saving.
Good luck with the rest of your script!
- Mark
Copy link to clipboard
Copied
Gotcha. Thank you Mark, appreciate your time!! HNY.