Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #target illustrator
- try {
- if (app.documents.length > 0 ) {
- var destFolder = null;
- destFolder = Folder.selectDialog( 'Sélectionner le dossier d\'export pour la preview.', '~' );
- if (destFolder != null) {
- var options, i, sourceDoc, targetFile;
- options = this.getOptions();
- for ( i = 0; i < app.documents.length; i++ ) {
- sourceDoc = app.documents[i];
- targetFile = this.getTargetFile(' [preview]' + sourceDoc.name,'.pdf', destFolder);
- sourceDoc.saveAs( targetFile, options );
- }
- alert( 'Previews enregistrés au format PDF' );
- }
- }
- else{
- throw new Error('Aucun document ouvert.');
- }
- }
- catch(e) {
- alert( e.message, "Alerte de script", true);
- }
- function getOptions()
- {
- var options = new PDFSaveOptions();
- options.acrobatLayers = true;
- options.colorBars = true;
- options.colorCompression = CompressionQuality.JPEGLOW;
- options.compressArt = true;
- options.embedICCProfile = true;
- options.enablePlainText = true;
- options.generateThumbnails = false;
- options.optimization = true;
- options.pageInformation = false;
- options.compatibility = PDFCompatibility.ACROBAT7;
- return options;
- }
- function getTargetFile(docName, ext, destFolder) {
- var newName = "";
- if (docName.indexOf('.') < 0) {
- newName = docName + ext;
- } else {
- var dot = docName.lastIndexOf('.');
- newName += docName.substring(0, dot);
- newName += ext;
- }
- var myFile = new File( destFolder + '/' + newName );
- if (myFile.open("w")) {
- myFile.close();
- }
- else {
- throw new Error('Accès refusé');
- }
- return myFile;
- }
- printPostScript();
- function printPostScript() {
- app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;
- var docPath, docs, inFolder, opts, psPath;
- jobOpts = new PrintJobOptions();
- opts = new PrintOptions();
- opts.printPreset = 'PostScript';
- opts.jobOptions = jobOpts;
- var sepOpts = new PrintColorSeparationOptions();
- opts.colorSeparationOptions = sepOpts;
- var fontOpts = new PrintFontOptions();
- opts.fontOptions = fontOpts;
- fontOpts.downloadFonts = PrintFontDownloadMode.DOWNLOADNONE;
- fontOpts.fontSubstitution = FontSubstitutionPolicy.SUBSTITUTEDEVICE;
- opts.customPaperSupport = true;
- sepOpts.convertSpotColors = true;
- sepOpts.overPrintBlack = true;
- sepOpts.colorSeparationMode = PrintColorSeparationMode.HOSTBASEDSEPARATION;
- var psOpts = new PrintPostScriptOptions();
- opts.postScriptOptions = psOpts;
- psOpts.postScriptLevel = PrinterPostScriptLevelEnum.PSLEVEL3;
- if ( app.documents.length > 0 ) {
- docs = app.documents;
- } else {
- inFolder = Folder.selectDialog( 'Select Source Folder...' );
- if ( inFolder != null ) {
- docs = inFolder.getFiles( '*.ai' );
- };
- };
- for ( i = docs.length-1; i >= 0; i-- ) {
- if ( docs[i] instanceof File ) {
- app.open( docs[i] );
- } else {
- app.activeDocument = docs[i];
- };
- docPath = decodeURI( app.activeDocument.fullName );
- psPath = docPath.replace( /.ai$/, '.ps' );
- jobOpts.file = File( psPath );
- app.activeDocument.print( opts);
- app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );
- };
- app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement