Copy link to clipboard
Copied
Hey all,
I've searched around and found a few things but nothing that caters completely, apologies if I missed it though. Not familiar with writing scripts at all so would be very grateful for help with this.
I'm looking to save a pdf with two versions, one as a standard pdf and the second with 'preserve illustrator capabilities turned off'. I found - pDFSaveOptions.preserveEditability false whilst looking through for solutions.
The files would need to be saved in a new folder 'project title - client name' created within a specific folder and the files named 'project title_mockup.pdf' and 'project title_send_mockup.pdf'
Is there a way to achieve this with prompts to input the file/folder name? or would this be difficult due to only needing the first part 'project title' of the folder name in the file name?
Many thanks,
var projectTitle = prompt("Please enter the 'project title - client name':","default text") ; //no extension
var pdfSaveSettingsA = newPDFSaveOptions();
//input your settings here
var pdfSaveSettingsB = newPDFSaveOptions();
//input your secondary pdf save settings here
var outputFilePath = "/Path/To/Folder/"
var pdfAFileName = projectTitle + "_mockup.pdf";
var pdfBFileName = projectTitle + "_send_mockup.pdf";
//output pdf A
app.activeDocument.saveAs(File(outputFilePath + pdfAFileName),pdfS
...Copy link to clipboard
Copied
var projectTitle = prompt("Please enter the 'project title - client name':","default text") ; //no extension
var pdfSaveSettingsA = newPDFSaveOptions();
//input your settings here
var pdfSaveSettingsB = newPDFSaveOptions();
//input your secondary pdf save settings here
var outputFilePath = "/Path/To/Folder/"
var pdfAFileName = projectTitle + "_mockup.pdf";
var pdfBFileName = projectTitle + "_send_mockup.pdf";
//output pdf A
app.activeDocument.saveAs(File(outputFilePath + pdfAFileName),pdfSaveSettingsA);
//output pdf B
app.activeDocument.saveAs(File(outputFilePath + pdfBFileName),pdfSaveSettingsB);
Copy link to clipboard
Copied
Thank you very much! It's really appriciated!
Definitely my bad but the files are exporting as an .ai with none of the pdf settings applied, I'll do some more attempts to see where I'm going wrong.
Copy link to clipboard
Copied
woops. i'm a dingus. i forgot to actually USE the the pdf save options we setup. I'll edit the comment.
Copy link to clipboard
Copied
Thank you so much, all working now except getting I'm getting errors when adding the pdf export settings I'd like.
How would I show 'preserve illustrator capabilities' as checked for the first and unchecked for the second?
Would it be possible to create a new folder with a name prompt before it is saved?
Thanks again!
Copy link to clipboard
Copied
Sorry, figured out why the pdf settings weren't being applied.
Just the new folder in the location now?
Thanks!
Copy link to clipboard
Copied
pdfSaveOptionsA.preserveEditability = true;
pdfSaveOptionsB.preserveEditability = false;
Folders can be created like this:
var folderName = prompt("enter folder name", "default text") ;
var myNewFolder = Folder("path/to/folder/" + folderName) ;
if (!myNewFolder.exists)
myNewFolder.create()
Copy link to clipboard
Copied
Thanks again, this is perfect. Will save a lot of time!
Copy link to clipboard
Copied
Apologies but need your help again!
If the prompt is canceled the script will run with 'null' as the folder/name title. Can we add in a stop if the prompt is canceled?
Realised I'm going to need a reduced second version for re-saving documents to prevent the need to input the details each time. I've removed the prompt and naming elements but getting an error with the output lines?
Thanks in advance!
#target illustrator
var pdfSaveSettingsA = new PDFSaveOptions();
pdfSaveSettingsA.preserveEditability = true;
//input your settings here
var pdfSaveSettingsB = new PDFSaveOptions();
pdfSaveSettingsB.preserveEditability = false;
//input your secondary pdf save settings here
//output pdf A
app.activeDocument.saveAs(File(pdfSaveSettingsA));
//output pdf B
app.activeDocument.saveAs(File(doc.name.replace("_mockup.pdf", "_send_mockup.pdf") ,pdfSaveSettingsB));
Copy link to clipboard
Copied
For your output error, you're passing in PDFSaveOptions instead of a file string to the saveAs() function. Each saveAs() function call has one required parameter (a file object), and one optional one (save settings). The File() object in the first parameter is required and the argument inside the parenthases for File() should be a string representing a relative or absolute file path. Then the second parameter is the save settings.
Change this:
//output pdf A
app.activeDocument.saveAs(File(pdfSaveSettingsA));
//output pdf B
app.activeDocument.saveAs(File(doc.name.replace("_mockup.pdf", "_send_mockup.pdf") ,pdfSaveSettingsB));
to this:
//output pdf A
var doc = app.activeDocument;
var outputFileNameA = decodeURI(doc.fullName);
var outputFileNameB = outputFileNameA.replace("_mockup.pdf","_send_mockup.pdf");
doc.saveAs(File(outputFileNameA),pdfSaveSettingsA);
doc.saveAs(File(outputFileNameB),pdfSaveSettingsB);
Here's the "stop doing stuff if the dialog is cancelled" thing.
function outputTwoPdfs()
{
var projectTitle = prompt("Please enter the 'project title - client name':", "default text"); //no extension
if (!projectTitle)
{
return;
}
var pdfSaveSettingsA = newPDFSaveOptions();
pdfSaveSettingsA.preserveEditability = true;
var pdfSaveSettingsB = newPDFSaveOptions();
pdfSaveSettingsb.preserveEditability = false;
var outputFilePath = "/Path/To/Folder/"
var pdfAFileName = projectTitle + "_mockup.pdf";
var pdfBFileName = projectTitle + "_send_mockup.pdf";
//output pdf A
app.activeDocument.saveAs(File(outputFilePath + pdfAFileName), pdfSaveSettingsA);
//output pdf B
app.activeDocument.saveAs(File(outputFilePath + pdfBFileName), pdfSaveSettingsB);
}
outputTwoPdfs();
Copy link to clipboard
Copied
Thank you again.
I've asked a lot from you and appreciate it greatly!
Do you have any suggestions or answers to the possibility of a request in another thread I created?
https://community.adobe.com/t5/illustrator-discussions/help-with-scripting-or-actions-is-something-a...