Need javascript to automate hiding a layer (INDD CS4)

Hi,
We've been having a problem lately with our writers remembering to kill the DRAFT watermark layer before they export the print and web pdfs.
I need a script that will automatically hide the "watermark" layer in the current document, save the document, then start the File > Adobe PDF Presets > [my_preset].
This would save our doc controllers and writers a lot of headache, but being inexperienced with javascript (okay, all programming), I really don't know how to write something that would do this, but I've come to understand that any process can be automated in indesign.
Can anyone help me out?
Thanks!
Ryan

Hey!
I think this will work:
app.activeDocument.save();
var myExportPresetName = "myPreset";
var myWaterLayerName = "Watermark";
try{var myPreset = app.pdfExportPresets.item(myExportPresetName);myPreset.name;}
catch(_){alert("Can't find Export Preset");exit();}
try{app.activeDocument.layers.item(myWaterLayerName).visible = false;}
catch(_){alert("Can't find layer: " + myWaterLayerName);exit();};
var myFile = File.saveDialog ("Save PDF","PDF files: *.pdf");
if(myFile != null)
app.activeDocument.exportFile(ExportFormat.PDF_TYPE, myFile, false, myPreset);
else
alert("No output file selected!");
Just change preset name and layer name.
tomaxxi
http://indisnip.wordpress.com/

Similar Messages

  • How can I disable the automatic hiding of known file attachments, and why are always about 10 internet pages where I have to download something if i use firefo

    How can I disable the automatic hiding of known file attachments, and why are always about 10 internet pages where I have to download something when I use mozila firefox?
    Windows Computer

    1) If you are talking about the file names on the computer, there is a
    setting to turn off known file types. Open your file browser. Then
    just under the location bar, press '''Tools,''' then '''Folder Options.'''
    A new window will open. Select '''View.''' Look for
    '''Hide Extensions For Known File Types.'''
    2) Never NEVER '''NEVER''' download anything unless you know what
    it is. If a web site claims it needs to download something, what is it?
    It could be something like the flash player, '''or a virus ! !'''
    Ask questions, or go somewhere else.

  • Need Javascript to force reading mode on document open...

    Need Javascript to force reading mode on document open... Does anyone know how to do this? Acrobat 8 does not come with a custom action for opening a page in reading mode...
    Would also like the remove the page scroll bar from the document window. Can this also be applied using Javascript?

    This code will embed a script that will open the doc in Reading Mode:
    this.addScript("OpenInReadingMode","app.execMenuItem('ReadingMode');");
    You can't remove the toolbar from the document window, only in full screen mode it's invisible.

  • I need to create automatic invoice(vf01) on click of pgi.so which Bapi?

    Hi all,
               I need to create automatic invoice(vf01) on click of pgi.
    so which bapi shell i use and how shell i pass   outbound deliver((likp-vbeln) to document (KOMFK-vbeln) through that bapi.
    Is BAPI_BILLINGDOC_CREATE is correct bapi to do so.if it is then what i have to pass in parametres.
    Please suggest me.
    Regards,
    Himanshu

    Hi,
      Thanks buddy for your kind support. Now i have below code ..plese check.
    tables:  nast.
      data : bb like BAPIVBRK occurs 0 with header line ,
             re like BAPIRET1 occurs 0 with header line ,
             ss like BAPIVBRKSUCCESS occurs 0 with header line .
            bb-REF_DOC = nast-OBJKY.
           bb-REF_DOC_CA = 'J'. " commented"
              append bb.
    CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
    EXPORTING
      CREATORDATAIN         =
      TESTRUN               =
      POSTING               =
      TABLES
        BILLINGDATAIN         = bb
      CONDITIONDATAIN       =
      CCARDDATAIN           =
      TEXTDATAIN            =
      ERRORS                =
        RETURN                = re
        SUCCESS               = ss .
    I have to chek whether it works or not.
    Regards,

  • Mail Viewing Options Gone.  I need to DISABLE automatically marking a message as read!

    In Lion, the Mail Viewing options to disable automatically marking a viewed message as read are gone!  I absolutely NEED to disable automatically marking a viewed message as read!  How can I disable this if the option isn't present?  Is there a workaround?

    Ok...I take part of what I said back. It was MailActOn by InDev which allowed me to not automatically have a message marked as read.  See http://indev.ca/MailActOn.html for more info.
    Apparently the version I had loaded wasn't compatible with Lion Mail.app.  Since updating it, I know have this feature again.

  • Will not open web page said need javascript have it

    I have up to date java firefox tells me i need javascript? on my browser
    do not know what to do now

    Uninstall Java and install Java again.

  • Need to generate automatic mail, when notification creation in IW21

    Hi All,
    when i am creating notification in IW21, i need to generate automatic mail. I know mailing program.
    I searched with following USER EXITS. And i tried with BADI also.
    IWO10026
    IWO10027
    IWOC0001
    IWOC0002
    IWOC0003
    IWOC0004
    But still i didnt get solution for this problem. Can anyone help me.
    Regards
    Lakshaman Dev

    Hi,
    You can use the following BADI.
    NOTIF_EVENT_SAVE.
    This is a filter dependant BADI. Use filter 'Maintain Notification'.
    This BADI will trigger at the time of saving your notification.
    Hope this helps.
    Regards,
    Mrunal.

  • Automatically Launching Bridge when PS CS4 is launched

    I just installed CS4 and my first difference is the (on a PC) Edit/Preferences/General does not have a check box for automatically alunching Bridge.
    Was this moved to somewhere else?  I liked this in CS3.
    Thanks in advance.
    Marv

    If you want Bridge to start up automatically when Photoshop starts in CS4 like it could in CS3, you will need to use an action.  Here are the steps:
    Create a new action by clicking the sticky note mini-icon in the action panel.
    Give it a name like "BridgeStart".
    Click on Record.
    Do a File>Browse in Bridge... from the menu (this will start Bridge).
    Go back to the Photoshop window and click the stop button in the Actions panel (the square mini-icon).
    Now you have your action but you need to tell Photoshop to use it everytime it starts up.  To do that:
    Do File>Scripts>Scripts Event Manager...
    Put a check in "Enable Events to Run Scripts/Action"
    Select "Start Application" where it says Photoshop Event.
    Select Action and specify the Action that you created earlier.
    Click on the Add button to add the event.
    Now everytime Photoshop starts, Bridge will start, too.
    Hope that helps.

  • How to cancel-undo new adjustment layer in CS4

    How do I cancel a new adjustment layer in CS4?
    I used to just hit Exc key and it would disappear.
    Now Command+z won't even undo it.
    That makes me have to click on it in the layers pallet and drag it in the trash...

    'Initially' my ***. Unless they improve both the performance and the interface design of the Adjustments Panel hugely. They would also have to find a way to float the panel, so it disappears.
    The two 'advantages' of the panel are as follows - 1 the TAT tool allowing within image dragging to adjust values. I assume for users without the ability to grasp the concept the most powerful tool, Curves. I will admit that when it eventually is fast enough to use efficiently, and implemented smoothly, this may be a good addition. 2 - the ability to alter opacity and mode of the adjustment, without exiting the dialog. More of a choice for inexperienced users who think this should be necessary at all.
    At the moment these two, relatively minor for advanced users, advantages are outweighed by the many disadvantages by a long chalk.
    You don't need to do V and then delete in CS4 - the delete key just deletes layers

  • Can you have a PDF fit on the viewer's screen automatically when exporting from InDesign CS4?

    Can you have a PDF fit on the viewer's screen automatically when exporting from InDesign CS4?

    If you were to upgrade to InDesign CS5 or CS5.5 and if you exported as Adobe PDF (Interactive), you could set the View settings for Page Layout and Zoom.
    While, as Jongware points out, its possible for individual users to override that option (Preferences > Page Display > Default Layout and Zoom), the number who will actually do that is actually very tiny.

  • Using indd CS4 for email blasts?

    Happy Holidays everyone.  Instead of using 'contant contact' or other such email blast software with templates, what I typically do is design an original email blast in InDesign, and then send it as a pdf to a company who switches it (somehow) into html. Which takes them some time, and some extra money, before they blast the thing.
    However, there has to be an easier way, to take my designed "flyer" right to html, in indd,cs4???  I tried exporting it as html, and the file had no graphics in it, bummer.  I tried exporting as eps, and the file was too huge.  I tried exporting as a variety of different jpegs, and still wasn't right--although, it could be brought into a Word file.  But, again could not add 'link's" to our website in Word.
    So, what am I missing here?  Thanks

    What you're missing is the fact that there is no easy way. My advice: spend the money on Constant Contact, MailChimp or one of the other specialized services.
    Bob

  • Hello, I have an apple Mac Pro. It is an older machine but I just had the Apple Store install a new drive with OSX 10.6.8. It runs great but I need to load software. Will it run CS4 Design Standard? Or, will I need CS5.

    Hello, I have an Apple Mac Pro Laptop. It is an older machine but I just had the Apple Store install a new hard drive with OSX 10.6.8. It runs great but I need to load software. Will it run CS4 Design Standard? Or, will I need CS5. This machine can't run 10.7.

    Hi There,
    As per CS5.5 Design Standard release notes it can run on 10.6.8.
    Kindly try to install in and share the results so that we can assist you if needed.
    Please find the download link in my previous post.
    Thanks,
    Atul Saini

  • Need help with folder level javascript to automate "save button" on a fillable form

    I have been racking my brain for the past 6 hours trying to get a simple save button to work.
    Background: I am using Acrobat Pro 11 to create a save button on a fillable form. My intent is for the end users (my team of 3, whos computers I have access to) to be able to fill out the form, click save, and have the filename appended with date and other info and saved to a local folder on their machine.
    I am attempting to take the default form name i.e. Support Call Log.pdf and have three of the feilds within the form generate a new file name. --> Support Call Log_Brad_121_2015
    End users will fill out the form using adobe viwer X.
    Instead of putting the code that I have tried, modified, and tried again and again. I would like to ask for a fresh start and then see if I can locate my error after. I need to know what to put in my folder level script, line for line.
    I also need to know the correct syntax and format to establish a new file name with the extracted feild data, saved to the same exact file path as the original document.
    Any and all help will be greatly appreciated, I am about to go crazy!!!

    Didn't let me do it, invalid. So, here is what I have now changed my button code to:
    //get field value
    var fv1 = getField("Technician:").value;
    var fv2 = getField("Date Received:").value;
    var fv3 = getField("Unit Number:").value;
    // Split Path into an array so it is easy to work with
    var aMyPath = this.path.split("/");
    // Remove old file name
    aMyPath.pop();
    var NewFileName = "Support Call Log" + "_" + fv1 + "_" + fv2 + "_" + fv3 + ".pdf";
    NewFileName = NewFileName.replace(/[\s\!\?\<\>\'\"\*\/\\\=\?\^\`\{\}\|\~]+/g, "_");
    aMyPath.push(NewFileName);
    //save
    mySaveAs(this,aMyPath.join("/"));
    Im still getting the error dialogue box, and nothing shows in my javascript debugger window when I click the button. Seems to be something goofy with my Folder level script:
    var mySaveAs = app.trustedFunction(
         function(oDoc, cPath, cFlName)
              cPath = cPath.replace(/([^/})$/, "$1/");
              try{
                   oDoc.saveas(cPath + cFlName);
                   catch(e){
                                  app.alert("Error During Save");

  • How do I automatically scale a layer to fit a canvas while maintaining the original aspect ratio?

    I'm currently tasked with reformatting 3,000 product images (thumbnail, normal, and large sizes for each) for a new online store. To do that, I'm trying to create a Photoshop (CS6) action that can automate the process as much as possible because I have a hard deadline and not a lot of time to get it all done. Where I'm running into issues is scaling the images automatically once I've used File-->Place. My canvas sizes are all square (670px X 670px, 250px X 250px, and 125px X 125px), but the product images I'm placing on the canvases are almost always rectangular with the height greater than the width at about a 2:3 ratio. I need to scale them so that the image is touching the top and bottom edges of the canvas and the width is adjusted accordingly with the image centered horizontally.
    I found the program below on another thread, but it's not working exactly like I need it to. It mentions "maintain aspect ratio," but when I run it, the image I'm trying to place ends up getting stretched to fill the entire canvas rather than the width adjusting to the height once the height has reached its maximum. I have no experience with JavaScript, so I'm having a difficult time adjusting the code to meet my needs. Any help would be greatly appreciated since I am a writer who is WAY out of his comfort zone.
    var maintainAspectRatio;// set to true to keep aspect ratio 
    if(app.documents.length>0){ 
        app.activeDocument.suspendHistory ('Fit Layer to Canvas', 'FitLayerToCanvas('+maintainAspectRatio+')'); 
    function FitLayerToCanvas( keepAspect ){// keepAspect:Boolean - optional. Default to false 
        var doc = app.activeDocument; 
        var layer = doc.activeLayer; 
        // do nothing if layer is background or locked 
        if(layer.isBackgroundLayer || layer.allLocked || layer.pixelsLocked 
                                || layer.positionLocked || layer.transparentPixelsLocked ) return; 
        // do nothing if layer is not normal artLayer or Smart Object 
        if( layer.kind != LayerKind.NORMAL && layer.kind != LayerKind.SMARTOBJECT) return; 
        // store the ruler 
        var defaultRulerUnits = app.preferences.rulerUnits; 
        app.preferences.rulerUnits = Units.PIXELS; 
        var width = doc.width.as('px'); 
        var height =doc.height.as('px'); 
        var bounds = app.activeDocument.activeLayer.bounds; 
        var layerWidth = bounds[2].as('px')-bounds[0].as('px'); 
        var layerHeight = bounds[3].as('px')-bounds[1].as('px'); 
        // move the layer so top left corner matches canvas top left corner 
        layer.translate(new UnitValue(0-layer.bounds[0].as('px'),'px'), new UnitValue(0-layer.bounds[1].as('px'),'px')); 
        if( !keepAspect ){ 
            // scale the layer to match canvas 
            layer.resize( (width/layerWidth)*100,(height/layerHeight)*100,AnchorPosition.TOPLEFT); 
        }else{ 
            var layerRatio = layerWidth / layerHeight; 
            var newWidth = width; 
            var newHeight = ((1.0 * width) / layerRatio); 
            if (newHeight >= height) { 
                newWidth = layerRatio * height; 
                newHeight = height; 
            var resizePercent = newWidth/layerWidth*100; 
            app.activeDocument.activeLayer.resize(resizePercent,resizePercent,AnchorPosition.TOPLEFT); 
        // restore the ruler 
        app.preferences.rulerUnits = defaultRulerUnits; 

    Hum Im not sure Im getting you here… Have you looked at Image Processor…?
    Why are you NOT just using Fit Image and canvas size in your actions…?
    These are all built-in to Photoshop.
    If you wanted to do all 3 sizes in the 1 fly-bye then use script to process…
    If you need extra file naming conventions then script would probably be best…
    All of the above should have NO trouble handling your 3k files…

  • Need help subscripting in a text layer

    Hi.  I need some help getting the Java Script right for subscripting in a text layer.
    Specifically, I need to access the text in layers named "Formula1" "Formula2" thru "Formula6", find each number in the text and subscript it.
    I actually want to set the baseline for that character to -3
    I usually write code in VBA, and JavaScript is winning the battle!  I need Java so I can share it with someone on a mac. 
    Ideas?  Help?  I'll take em!  Thanks!

    As others have said, to change the format of just some of the chars in a textItem can only be done with Action Manager. On Windows you can use javascript or VB. On Mac you can only use javascript.
    A textItem's descriptor has 10 keys. The one controls that kind of char formatting is stored in the 'textStyleRange' key. That one descriptor has 69 keys that store the formatting for that range. There may be several ranges.. Some of the keys in 'textStyleRange'  are also descriptors that have their own keys. To avoid unwanted changes to the existing formatting you need to read all those keys, change only the 'baselineShift' key in the 'textStyleRange' descriptor, then write all the settings back to the textItem's descriptor.
    It may be that it is possible to do this kind of format editing with a script but it would take a lot of work and many, many line of code. It also would take a good understanding of how Action Manager works with it's actionDescriptors, actionReferences, actionLists, and their methods and properties.
    It has been a good while since I looked at Xbytor's script, but when I last looked it only supports limited formatting and overwrites existing formatting it doesn't support with default text formatting. If your text doesn't have any special formatting his script would be the best way to go.
    If your text does have formatting unsported by X's script you will either need to expand his script or create your own. Unless this kind of text editing is something that you need to do very often it may not be worth the effort.

Maybe you are looking for

  • My airport is connected to an Ethernet cable and I have created a wifi network but my iPad and I phone can't seem to join it. They just keep trying. What's wrong?? Help!

    I have just bought an airport express to connect to the Ethernet cable in my cabin. It's all set up all lights green and I've set up my wifi connection. But when I try to connect my I pad 3 or my iPhone 4 it finds the network but cannot seem to join

  • Can't eject USB drive

    Hi, This is driving me crazy. Every time I used a USB drive, I am told that it can't be ejected because a program is using it. Sometimes it says the finder is using it (it shouldn't be: if the finder is using it it is only listing it as a drive). Rel

  • Give ZEN app file system rights so can install without user login

    ZfD 6.5.2 NW 6.5.5 Is it possible to give an app rights to the file system on a Netware box to find the msi it needs to install even if there isn't a user logged in to the workstation? We have an app associated with workstations and when we tried to

  • Slow Wireless

    Hello Just recently become a proud owner of a MacBook, having upgraded from my aging G3 iBook. Fantastic so far, apart from the wireless connection. Have a Belkin 54g router connected through UK online with a 2mb connection. Can't seem to get above 6

  • Settings of images? (rendering)

    I've made a slide show using .jpg pictures and the rendering is taking a long time. I looked into the solutions to rendering problems in this discussion board and they all say to match the source settings to the sequence settings. But how do I match