Can you fix my script problem?

Hi everyone
I got this script:
function: gen specify color of text to pdf
everything was very well, unless final step, I want to the script keep the new file's name as same as my indesign file's name,
and no need to type in (".pdf")
Thank you all so much!
Harvey
//==============================================================
var doc = app.properties.activeDocument && app.activeDocument; 
if (!doc) {alert("Adiós Amigo") ; exit();} 
var sN = doc.swatches.everyItem ().name, 
    sID = doc.swatches.everyItem ().id, 
    /** UI */ 
    w = new Window ('palette', "Print by Color"), 
    g1 = w.add('group'), 
    g2 = w.add('group'), 
    st = g1.add('statictext', undefined, "Select Swatch from Drop Down List") 
    d = g1.add('dropdownlist', undefined, sN), 
    b1 = g2.add('button', undefined, "PDF"), 
    b2 = g2.add('button', undefined, "Print"); 
    b1.onClick = function () {proccessPages (d.selection, true)} 
    b2.onClick = function () {proccessPages (d.selection)} 
w.show(); 
function proccessPages (s, e) { 
    var l, c = 0, o, p, pO = {}, pA = []; 
    if (s == null) {alert("No Swatch Selected") ; return;}; 
    app.findTextPreferences = app.changeTextPreferences = null; 
    s = doc.swatches.itemByID (sID[s.index]); 
    app.findTextPreferences.fillColor = s; 
    var pageFinds = doc.findText (); 
    if (!(l = pageFinds.length)) {alert("No finds") ; return;}; 
    for (c = 0; c < l; c++) { 
        o = (p = pageFinds[c].parentTextFrames[0].properties.parentPage) && p.documentOffset + 1; 
        if (p) pO["_" + o] = o; // if the finds on a page add to page list 
    c = 0; 
    for (o in pO) pA[c++] = pO[o]; 
    var pageRange = "+" + pA.join(", +"); 
    doc.printPreferences.pageRange = pageRange; 
    if (!e) doc.print(true); 
    else { 
        app.pdfExportPreferences.pageRange = pageRange; 
        f = File.saveDialog("Export PDF", "PDF: *.PDF"); 
        if (!f) return; 
      app.activeDocument.exportFile (ExportFormat.PDF_TYPE, File(exportPath+'/'+linkname.name.replace(/(\.[^.]+)$/, '.pdf')), false, app.pdfExportPresets.item(exportPreset)); 
//==============================================================

everything was very well, unless final step...
app.activeDocument.exportFile (ExportFormat.PDF_TYPE, File(exportPath+'/'+linkname.name.replace(/(\.[^.]+)$/, '.pdf')), false, app.pdfExportPresets.item(exportPreset));
Hi Harvey,
Be honest, it can not work. There no exportPath, linkname and exportPreset in your code.
You pasted it from a several independent codes and ask for help to fix it ==> but, to tell you the true, is nothing to fix.
It reminds me very much one story happened to some guy somewhere:
He was asked by a stranger:
"Which way is shortest to another part of the city."
The guy knew the city pretty well but explaining the way took a minutes.
At the end, nonetheless, a stranger jumped to a guy's back and ask:
"Could you kindly take me there, pls?"
Jarek

Similar Messages

  • Can you fix this script problem?

    Hi everyone
    I got this script
    for gen underline text to pdf
    the problem is it gen each page multi times if the page more then one place has underline text
    Can you fix it?
    //======================================================================
    var f = new Folder("~/Desktop/Revised_PDF put in here/"); 
    f.create();
    var doc = app.documents; 
    app.findTextPreferences = null; 
    app.findTextPreferences.underline = true; 
    for(var i=0;i<doc.length;i++) 
            var found = doc[i].findText(); 
            var _pages = []; 
            for(var j=0;j<found.length;j++) 
                    var txfms = found[j].texts[0].parentTextFrames; 
                    for(var k=0;k<txfms.length;k++) 
                            _pages.push(txfms[k].parentPage.name); 
            for(var j=0;j<_pages.length;j++) 
                    if(_pages[j] === _pages[j-1]) 
                            _pages.splice(j,1); 
            if(_pages.length != 0) 
                    app.pdfExportPreferences.pageRange = _pages.toString(); 
                    doc[i].exportFile(ExportFormat.PDF_TYPE, new File("~/Desktop/Revised_PDF put in here/" + doc[i].name.replace(/\.indd$/i,".pdf")), false);
            _pages = []; 
    app.findTextPreferences = null;
    alert("Done.");
    var f = Folder("~/Desktop/Revised_PDF put in here/" ); 
    f.execute(); 
    //======================================================================
    for specific details:
    Is that possible to write a script for export underline text to PDF?
    thanks
    Harvey

    > the problem is it gen each page multi times if the page more then one place has underline text
    Is this only when you have multiple unconnected text frames (each one containing underlined text) on the same page? Or possibly footnotes, tables, or anchored text?
    Chinna's script assumes all text is in a single threaded story: the findText command searchs one story at a time, from start to end (and across multiple pages). If it reaches the end of the story, it continues with the next one, even if it has to go back to the first page. And anchored objects, text in tables, and text in footnotes all count as "separate texts".
    Chinna's script already removes multiple pages:
    for(var j=0;j<_pages.length;j++)
      if(_pages[j] === _pages[j-1])
        _pages.splice(j,1);
    but it only works for a continuous story, because the "found" occurrences will be in the original page order, such as "1,2,2,3,5,5". This code removes successive doubles (see the Javascript documentation for a description of "splice"). As soon as you have separate stories (tables, 'notes, et cetera), you get a series such as "1,3,3,5,1,6" -- where "1,6" would be the occurrences in a separate story.
    The solution is simple: before removing the duplicates, sort the pages. As far as scripting goes, this is remarkably easy:
    _pages.sort();
    Please note that I just felt like answering your question this once. If you do what you did on most some of your other questions (ask for multiple versions for other formatting, have a different functionality, work on "selected documents" or "all in a folder" or "in a book file", or follow up with questions about totally unrelated scripts) I will probably not answer anymore.
    No offense meant, of course.

  • Can you fix scripts problem?

    I got these three script, their work very well, but not in the cell, can you fix it:
    Script 1:
    00.// left Indent: whatever, firstLineIndent: 8 mm 
    01. 
    02.var curDoc = app.activeDocument; 
    03. 
    04.if ( !app.selection.length ) { 
    05.    var paras = curDoc.stories.everyItem().paragraphs; 
    06.} 
    07.else if(app.selection.length == 1 && app.selection[0].hasOwnProperty( “baseline” )) { 
    08.        var paras = app.selection[0].paragraphs; 
    09.} 
    10.else { 
    11.    alert(“Something wrong with your selection!”); 
    12.    exit(); 
    13.} 
    14. 
    15.paras.everyItem().firstLineIndent = “8mm”; 
    Script 2:
    01.// left Indent: whatever, firstLineIndent: 0 
    02. 
    03.var curDoc = app.activeDocument; 
    04. 
    05.if ( !app.selection.length ) { 
    06.    var paras = curDoc.stories.everyItem().paragraphs; 
    07.} 
    08.else if(app.selection.length == 1 && app.selection[0].hasOwnProperty( “baseline” )) { 
    09.        var paras = app.selection[0].paragraphs; 
    10.} 
    11.else { 
    12.    alert(“Something wrong with your selection!”); 
    13.    exit(); 
    14.} 
    15. 
    16.paras.everyItem().firstLineIndent = “0mm”; 
    Script 3:
    01.// left Indent: 8 mm, firstLineIndent: -8 mm 
    02. 
    03.var curDoc = app.activeDocument; 
    04. 
    05.if ( !app.selection.length ) { 
    06.    var paras = curDoc.stories.everyItem().paragraphs; 
    07.} 
    08.else if(app.selection.length == 1 && app.selection[0].hasOwnProperty( “baseline” )) { 
    09.        var paras = app.selection[0].paragraphs; 
    10.} 
    11.else { 
    12.    alert(“Something wrong with your selection!”); 
    13.    exit(); 
    14.} 
    15. 
    16.for ( var i = 0; i < paras.length; i ++ ) { 
    17.    var curPara = paras[i]; 
    18.    if ( curPara.leftIndent == 0 ) { 
    19.        curPara.leftIndent = “8mm”; 
    20.    } 
    21.    curPara.firstLineIndent = “-8mm”; 
    22.} 

    Harvey,
    an alert is not an error. Try this one:
    // left Indent: whatever, firstLineIndent: 8 mm
    // das aktive Dokument
    var curDoc = app.activeDocument;
    // Anzahl der ausgewählten Objekte
    var nSel = app.selection.length;
    // wenn nichts ausgewählt ist
    if ( nSel == 0 ) {
        // alle Textabschnitte im Dokument
        var allStories = curDoc.stories.everyItem();
        // alle Absätze in Textabschnitten
        var paras = allStories.paragraphs.everyItem();
        // alle Absätze in Tabellen (wirft Fehler, wenn es keine Tabellen gibt!)
        try {
            var parasInTables = allStories.tables.everyItem().cells.everyItem().paragraphs.everyItem();
        catch (e) {
        makeIndent( paras, parasInTables );
    // wenn etwas ausgewählt ist
    else {
        // Hilfszähler
        var probCtr = 0;
        // Eine Schleife durch die Auswahl
        for ( var n = 0; n < nSel; n++ ) {
            var curSel = app.selection[n];
            // der Typ der aktiven Auswahl
            var selType = curSel.constructor.name;
            // prüfen, ob Text (inkl. Tabelle) oder Textrahmen ausgewählt ist
            if ( curSel.hasOwnProperty ( "baseline" ) || selType == "TextFrame" ) {
                var paras = app.selection[n].paragraphs.everyItem();
                try {
                    var parasInTables = app.selection[n].tables.everyItem().cells.everyItem().paragraphs.everyItem();
                catch (e) {
            // falls nur eine Tabelle ausgewählt ist
            else if ( selType == "Table" ) {
                var parasInTables = app.selection[n].cells.everyItem().paragraphs.everyItem();
            // wenn eine Zelle ausgewählt ist
            else if ( selType == "Cell" ) {
                var parasInTables = app.selection[n].paragraphs.everyItem();
            // falls etwas anderes ausgewählt ist
            else {
                // Hilfszähler wird hochgezählt, Schleife aber nicht abgebrochen
                probCtr++;
            makeIndent( paras, parasInTables );
        } // end for
        if ( probCtr == n ) {
            // der Hinweis erfolgt nur, wenn die Auswahl gar nicht passt. Ansonsten werden "falsche" Objekte einfach ignoriert.
            alert ( "Something wrong with your selection!" );
            exit();
    } // end else
    // die Einzüge verändern
    function makeIndent( paras, parasInTables ) {
        try {
            paras.firstLineIndent = "8mm";
        catch (e) {
        try {
            parasInTables.firstLineIndent = "8mm";
        catch (e) {

  • Why am I not able to type into my pdf files. Why is the cursor only appearing at he areas where there in no typing? I believe I know who's doing this, but can you fix the problem for me please?

    I cannot type into one of my pdf files. The cursor only appears where there is no typing. I believe there is foul play going on on my computer, Can you fix this problem?

    Hi Donna,
    Let's see if we can get to the bottom of this mystery! I hope it's not foul play.
    You say the problem is with just one of your PDF files? What version of Acrobat/Reader are you using? If you're in Reader, you're limited to commenting/annotating the PDF (you can't edit text with Reader, so you wouldn't be able to select text that's in the PDF already).
    Please let me know what program/tools you're using and we can take it from there.
    Best,
    Sara

  • Ayee payment was made to my account that I wasn't aware of and need it to be remove can you fix my problem?

    Ayee payment was made to my account that I wasn't aware of and need it to be remove can you fix my problem?

    We are all itunes users just like you.
    Contact itunes support.

  • Hello.I can`t buy applications in my apple id.Then i buy in applications writes error contact support.Can you fix this problem?Thaks

    Hello.I can`t buy applications in my apple id.Then i buy in applications writes error contact support.Can you fix this problem?Thaks

    We are all itunes users just like you.
    You need to contact itunes support.
    http://www.apple.com/support/itunes/contact/

  • I have no audio what so ever i have seen in one of the tables where it was deleted how can you fix this i tried everything i know

    == Issue
    ==
    I have another kind of problem with Firefox
    == Description
    ==
    i have been trying to get the audio to play for 3 days now i did see where it had been deleted this is a used comp i haven't had it long can you fix this i'm at my wits end
    == Firefox version
    ==
    3.6.3
    == Operating system
    ==
    Windows NT 5.0
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
    == Plugins installed
    ==
    *-Default Plug-in
    *Adobe Acrobat Plug-In Version 5.10 for Netscape
    *Java(TM) Platform SE binary
    *Next Generation Java Plug-in 1.6.0_20 for Mozilla browsers
    *Network Object Plugin
    *Windows Multimedia Services DRM Store Plug-In
    *Npdsplay dll

    Hello Virginia.
    You may be having a problem with some extension or plugin that is hindering your Firefox's normal behavior. Have you tried disabling all add-ons (just to check), to see if Firefox goes back to normal?

  • Has anyone else had an unsaved photo disappear from a text message?Gone. No thumbnail... it doesn't exist anymore? How do you fix that? Can you fix that?

    The photo is gone in the text message. Gone. No thumbnail...it doesn't exist anymore. How do you fix that? Can you fix that? Can you ever get the photo to show up again? I stumpted the guy on the phone with this problem. I need some help from anyone who has experienced this problem and might have a solution! Thanks in advance!

    This happened to me also, a few days ago... I went to look at pics that were sent from just one person, all the other photos that people texted are there during same time period.  It is only this one contacts several photos that disappeared...   There is an arrow when I click on it it goes to a blank page?!?   Have you received any feedback or answers??  Did your photos  that are missing come from only one person or multiple?  If you have any information that might help let me know!!!  I really want them back!!  Thanks much!

  • Paste in place to next Master unfunction, can you fix it?

    Hi, everyone
    I got this script, which copy from:
    Paste In Place to Specify Master Page
    I change it into:
    var myDialog = app.dialogs.add({name:"Copy Select item to next Master",canCancel:true});
    with(myDialog){
        with(dialogColumns.add()){
        staticTexts.add({staticLabel:"Select a Master you want to copy to"});
            with(dialogRows.add()){
               var mySelection = dropdowns.add({stringList:["Master A", "Master B","Master C", "Master D", "Master E","Master F", "Master G"], selectedIndex:0});
    if (myDialog.show() == true)
    function main(){
      if("Copy to next Master");
          copy_to_next_master(); 
    function copy_to_next_master() { 
        if (mySelection.selectedIndex == 0){
    var nSel = app.selection.length;   
    for ( var i = 1; i < app.documents.length; i++) {   
            var nextDoc = app.documents[i];   
            if (!nSel) { alert( "Nothing selected!" ); exit(); } 
            for ( var n = 0; n < nSel; n++ ) { 
                var curSel = app.selection[n]; 
                curSel.duplicate( nextDoc.masterSpreads[0] ); 
    alert("Done.\rWhat you select are pasted in place to next documents' Master  A");
        if (mySelection.selectedIndex == 1){
    var nSel = app.selection.length;   
    for ( var i = 1; i < app.documents.length; i++) {   
            var nextDoc = app.documents[i];   
            if (!nSel) { alert( "Nothing selected!" ); exit(); } 
            for ( var n = 0; n < nSel; n++ ) { 
                var curSel = app.selection[n]; 
                curSel.duplicate( nextDoc.masterSpreads[1] ); 
    alert("Done.\rWhat you select are pasted in place to next documents' Master  B");
        if (mySelection.selectedIndex == 1){
    var nSel = app.selection.length;   
    for ( var i = 1; i < app.documents.length; i++) {   
            var nextDoc = app.documents[i];   
            if (!nSel) { alert( "Nothing selected!" ); exit(); } 
            for ( var n = 0; n < nSel; n++ ) { 
                var curSel = app.selection[n]; 
                curSel.duplicate( nextDoc.masterSpreads[2] ); 
    alert("Done.\rWhat you select are pasted in place to next documents' Master  C");
        if (mySelection.selectedIndex == 1){
    var nSel = app.selection.length;   
    for ( var i = 1; i < app.documents.length; i++) {   
            var nextDoc = app.documents[i];   
            if (!nSel) { alert( "Nothing selected!" ); exit(); } 
            for ( var n = 0; n < nSel; n++ ) { 
                var curSel = app.selection[n]; 
                curSel.duplicate( nextDoc.masterSpreads[3] ); 
    alert("Done.\rWhat you select are pasted in place to next documents' Master  D");
        if (mySelection.selectedIndex == 1){
    var nSel = app.selection.length;   
    for ( var i = 1; i < app.documents.length; i++) {   
            var nextDoc = app.documents[i];   
            if (!nSel) { alert( "Nothing selected!" ); exit(); } 
            for ( var n = 0; n < nSel; n++ ) { 
                var curSel = app.selection[n]; 
                curSel.duplicate( nextDoc.masterSpreads[4] ); 
    alert("Done.\rWhat you select are pasted in place to next documents' Master  E");
        if (mySelection.selectedIndex == 1){
    var nSel = app.selection.length;   
    for ( var i = 1; i < app.documents.length; i++) {   
            var nextDoc = app.documents[i];   
            if (!nSel) { alert( "Nothing selected!" ); exit(); } 
            for ( var n = 0; n < nSel; n++ ) { 
                var curSel = app.selection[n]; 
                curSel.duplicate( nextDoc.masterSpreads[5] ); 
    alert("Done.\rWhat you select are pasted in place to next documents' Master  F");
        if (mySelection.selectedIndex == 1){
    var nSel = app.selection.length;   
    for ( var i = 1; i < app.documents.length; i++) {   
            var nextDoc = app.documents[i];   
            if (!nSel) { alert( "Nothing selected!" ); exit(); } 
            for ( var n = 0; n < nSel; n++ ) { 
                var curSel = app.selection[n]; 
                curSel.duplicate( nextDoc.masterSpreads[6] ); 
    alert("Done.\rWhat you select are pasted in place to next documents' Master G");
    but unfunction, can you fix it?
    thanks
    Teetan

    Hi,
    Modifying your code - notice that function main() suppose to be
    1. defined and
    2. called
    Compare it to this code:
    #target  indesign
    var
      myDialog = app.dialogs.add({name:"Copy Selected item(s) to chosen Master",canCancel:true}),
      mStringList = ["Master A", "Master B","Master C", "Master D", "Master E","Master F", "Master G"];
    with(myDialog){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Select a Master you want to copy to"});
      with(dialogRows.add()){
      var mySelection = dropdowns.add({stringList:mStringList, selectedIndex:0});
    main();
    function main(){
      if (!app.documents.length || !app.selection.length)
      alert( "Nothing selected!" );
      exit();
      if (myDialog.show() == true)
      copy_to_next_master();
    function copy_to_next_master() {
    var
      mChoice = mySelection.selectedIndex,
      mMsg = "Done.\rWhat you select is pasted in place to next documents - " + mStringList[mChoice],
      nSel = app.selection.length,
      mDone = false,
      i,n,nextDoc,curSel;  
    for ( i = 1; i < app.documents.length; i++) {  
      nextDoc = app.documents[i];  
      targetMaster = nextDoc.masterSpreads[mChoice];
      if (!targetMaster.isValid) {
      mMsg += "\rCan't detect " + mStringList[mChoice] + " in a doc: " + nextDoc.name;
      continue;
      mDone = true;
      for ( n = 0; n < nSel; n++ ) {
      curSel = app.selection[n];
      curSel.duplicate( nextDoc.masterSpreads[mChoice] );
    mDone ? alert(mMsg) : alert("Nothing copied");
    Jarek

  • Facebook wont load but everything else does? can you fix this please?

    For the past 2 days now when ever i try to log onto facebook it will not load the page. Everything else works just fine. Why is this and how can i fix this annoying problem so i can contact folks overseas?

    Using Safari to access Facebook?
    If so...
    From your Safari menu bar click Safari > Preferences then select the Privacy tab.
    Click:   Remove All Website Data
    Then delete the cache.
    Open a Finder window. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.
    If nothing above helped, troubleshoot Safari extensions.
    From the Safari menu bar click Safari > Preferences then select the Extensions tab. Turn that OFF, quit and relaunch Safari to test.
    If that helped, turn one extension on then quit and relaunch Safari to test until you find the incompatible extension then click uninstall.

  • My iPod speaker is broken, i bought it one year ago, can you fix that for free?

    my iPod speaker is broken, i bought it one year ago, can you fix that for free?

    You are not address ing Apple here, we are all just users like yourself.
    If the headphones work but not the speaker:
    - Try cleaning out/blowing out the headphone jack. Try inserting/removing the plug a dozen times or so. There is a little switch in the headphone jack that disconnects the speaker when the headphone jack is inserted.
    Try the following to rule out a software problem
    - Reset the iPod. Nothing will be lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup
    - Restore to factory settings/new iPod.
    If the speaker still does not work, make an appointment at the Genius Bar of an Apple store. Seems you have a bad headphone jack.
    Apple Retail Store - Genius Bar
    If not under warranty Apple will exchange your iPod for a refurbished one for this price. They do not fix yours. The Apple warranty is for one year unless you purchased the optional Applecare extended warranty
    Apple - iPod Repair price                  
    A third-party place like the following will replace the jack for less. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Replace the jack yourself
    iPod Touch Repair – iFixit

  • Please how can i fix my DVD problem for window 7 cq56

    how can i fix my DVD problem for cq 56 107 SA windows 7? it is selecting disc.

    What is the problem... can you please tell us in detail???
    ||-Although I am working on behalf of HP, I am speaking for myself and not for HP.-||
    //Click on Kudos if my reply was helpful and answered your question//
    ||-If my answer solved the problem please mark the topic as the accepted solution-||

  • Can I fix the alignment problems my Color LaserJet CP1518ni is having? The red does not line up.

    Can I fix the alignment problems my Color LaserJet CP1518ni is having?  The red does not line up.  I have installed the latest updates, etc.  Calibrating does not help.  The printer is only a few years old.  What gives?
    This question was solved.
    View Solution.

    Please be aware that this forum is a peer to peer support forum, it is not a direct link to HP support.
    I have a similar issue with a Laserjet cp1525nw, it was mostly corrected by removing and reseating the toner cartridges.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • How can i fix a malware problem?

    How can i fix a malware problem?

    That depends on what malware problem you are having.  Start by going to Thomas Reed's site http://www.thesafemac.com and read up on malware.  If you are having adware issues, follow his link to AdwareMedic and use that to clean out adware and block it.  Tom is a regular and trusted member of these discussions and a great security guy.

  • How can you fix your ipod touch when apps are closing on you, how can you fix your ipod touch when apps are closing on you

    How can you fix your ipod when apps keep crashing on you while your in that app?

    See:
    iOS: Troubleshooting applications purchased from the App Store
    Contact the developer/go to their support site if only one app.
    Restore from backup. See:
    iOS: How to back up              
    Restore to factory settings/new iPod

Maybe you are looking for