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.

Similar Messages

  • 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

  • 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?

  • 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.

  • I can't open my gallery after i migrate the iphoto! How can i fix this bad problem?

    HI,
    I can't open my gallery after i migrate the iphoto! How can i fix this bad problem? Flz help me!!

    Try repair permissions with Disk Utility
    Regards
    TD

  • How can I fix this theme problem?

    It turns weird.
    It was not like this before.
    I had this theme for a long time so I know it is not theme maker's problem.
    How can I fix this
    http://imgur.com/jAHMmWQ

    lalex, do you have the url or name of the theme in the addons website? You may need to contact them as well.

  • How can I fix this Authorisation problem

    When I sync iphone with computer, it won't transfer purchases on iphone to my computer  - says computer not authorised. But if I go to authorise the computer it says it is authorised. How can I fix this?

    It sounds like one of these Apple IDs does not match:
    The Apple ID used to purchase the items
    The Apple ID you are using to "Authorize This Computer"
    The Apple ID used on the iPhone

  • How can I fix this compatibility problem?

    After running software updates, including to Microsoft Office, I can't open mail attachments or connect with shared calendars. How can I fix this?

    Hi there 5340Daniel,
    You may find the troubleshooting steps in the article below helpful.
    If you can't see, download, or add attachments to an iCloud Calendar event
    http://support.apple.com/kb/ht5373
    -Griff W. 

  • GridBagLayout with JPanel, only 3 lines. Can you fix this?

    GridBagLayout gridBagLayout = new GridBagLayout();
    setLayout(gridBagLayout);
    panel1.addComponent(modelLbl,0, 0, 0, 0);
    this is all inside of a JPanel that is inside of a JTabbedPane. I want to use a GridBagLayout to arrange the components inside panel1 (which is a JPanel) but the compiler is telling me addComponent is undefined for JPanel.
    Can you figure this out? How can I use a GridBagLayout in a JPanel?
    If you cant use GridBagLayout is there anything similiar available for JPanel?

    well as helpful as that was.....
    i found the answer myself and it goes more like this...
    panel1.setLayout(new GridBagLayout);
    and then you have to create a GridBagConstraints object to enter the contraints, something like:
    GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, Insets insets, int ipadx, int ipady) ;
    and then you just use
    panel1.add(component, GridBagConstraints object);

  • How can I fix this graphics problem on my Macbook Pro?

    Whilst playing numerous games on my Macbook Pro, I have noticed the same problem. This causes the game to be almost unplayable and usually happens after playing the game for a while. I have had this happen on many games such as Portal 2, World of Warcraft, Team Fortress 2, Starcraft II and a few others.
    I have had this problem ever since I first got my Macbook Pro, but the issue has changed slightly since. A software update a long time ago caused the problem from affecting the whole screen to just affecting the window the game was being played in.
    I can sometimes fix the problem by opening the Display preferences in System Preferences and it automatically fixes itself - without me doing anything. There is another way I have found to temporarily fix the problem, however this has only worked on World of Warcraft. It involves changing the reselecting the display in the video settings and reapplying it - causes the game screen to go black for a few seconds and the issue is resolved.
    The problem is that the graphics on the screen start to flicker and move about and certain sections are missed out. It's kind of like a fuzzy tear in the screen.
    I have a attached an image of the worst case of this that I have had (I managed to screenshot it).
    System Specs
      Model Identifier:          MacBookPro7,1
      Processor Name:          Intel Core 2 Duo
      Processor Speed:          2.4 GHz
      Memory:          4 GB
      Chipset Model:          NVIDIA GeForce 320M

    Does it do the same thing if you boot from a different disk, like your old Mac OS X install disk?  I see you're running Lion, so also try booting from the recovery partition by holding down command and r at startup.
    If it can't boot from any system, it's a hardware issue.  You'll need to contact Apple for service.  If you can boot from the recovery partition, try repairing the hard drive with Disk Utility.  You may also want to try running Apple Hardware Test.

  • Flash Animations and Movies are lagging after having played a flash game which was graphics intense heavy and frequently refreshed which caused lags, how can I fix this lagging problem for Flash?

    On June 30th, I was playing a game called Lil Einstein's Manhattan project over at Newgrounds.com and the game although fine at first, later on in the advanced levels of the game, started to cause my browser to lag intensely and heavily. Now, when I try and watch other flash movies and animations, the flash doesn't run as smoothly, there are skips in the flash animations and movies, and it slows down.
    I tried scan disks, I tried defragmenting my computer, I tried uninstalling and re-installing Firefox.. Nothing worked to restore the Flash.
    But when I view Flash movies and animations on Internet Explorer, they run fine... but not anymore on Firefox.
    Other Firefox users who have played this game also reported problems as well..
    How can I fix my Firefox Browser and return the Flash running to normal?
    == This happened ==
    Not sure how often
    == June 30th, 2010

    If you have already scanned PC with an updated Anti-Virus and still the issue exists then I would suggest some troubleshooting techniques to resolve this problem:
    Update browser
    Remove unwanted Add-ons
    Remove unwanted Tool-bars
    Repair Registry
    Repair ActiveX objects and shared DLLs
    In case of facebook and Zynga I would suggest to Check for Problems with your Internet Connection.Try to Update Java and Reduce the Number of Running Internet Applications.
    Sometimes Multimedia content lag due to Hardware Acceleration, so disabling Hardware Acceleration should fix your problem.
    Open Flash Video in browser
    Right click on Video Player | Settings
    Open Display Panel
    Uncheck Enable Hardware Acceleration
    If issue still exists then you can find some more techniques described in detail here:
    http://www.shockwaveflashcrash.com/Easiest-fix-for-shockwave-flash-plug-in-Crash.html

  • Recent upgrades prevent loging into Citibank, can you fix this?

    Attempts to login to Citibank.com give "We've had a problem processing your request." This error appears to be from FIrefox, not Citibank, as they have no record of attempted logins. I have cleared citibank cookies and that doesn't help.

    Maybe its the new mixed content blocker?
    Starting in Firefox 23, if a secure page includes certain types of insecure content, Firefox blocks the insecure content and a shield icon will appear in the address bar. See this article for more information about the new mixed content blocker: [[How does content that isn't secure affect my safety?]]
    To temporarily allow the mixed content to be displayed:
    *Click the '''shield icon''' [[Image:Mixed Content Shield]] in the address bar and choose '''Disable Protection on This Page''' from the dropdown menu.
    [[Image:Fx23MixedContentBlocker]]
    To allow insecure content to be displayed in all secure pages, enter '''about:config''' in the address bar and double-click on this preference, to toggle it from true to false:
    '''security.mixed_content.block_active_content'''
    You can also use this add-on instead, to toggle the preference:
    *[https://addons.mozilla.org/firefox/addon/toggle-mixed-active-content/ Toggle Mixed active content] add-on
    You may want to do this only for the current session, then reset the preference back to "true" and check back with the site to see whether it's been fixed, since this is a global setting that exposes you on all sites, not just the one you care about.
    Let us know if this helps!

  • In Windows Live Hotmail, the tabs/elements constantly reload. Can you fix this?

    In Windows Live Hotmail,
    The buttons/elements on the side of the inbox page constantly reload, while I'm reading a message and when I try to go back to inbox, it automatically switches back to the message I was reading before.
    Please fix this!

    See comments 17,44,63,71:<br />
    [https://bugzilla.mozilla.org/show_bug.cgi?id=627729 Bug 627729] - Hotmail web page continually reloads every second<br />
    ''(please do not comment in bug reports; you can vote instead)''

  • Can you fix this in the Icelandic version: "Hlaða niðu Firefox" it should be spelled "Hlaða niður Firefox"

    When I download the Icelandic version of Firefox it says: "Downloading Firefox" or "Hlaða niðu Firefox". It is spelled wrong in Icelandic and should be spelled "Hlaða niður Firefox". Can you please fix it?

    hi gaggi96, thank you for bringing this up - i've forwarded your information to the icelandic translation team ([https://bugzilla.mozilla.org/show_bug.cgi?id=1133329 bug# 1133329]).

Maybe you are looking for

  • Can I use an Apple Gift Card to buy a Photo Book from iPhoto

    Is it possible to use an Apple Gift Card to buy a Photo Book that was created in iPhoto '11?

  • 24" cinema display. comes with USB cable?

    i ordered the display and the web page says in the "what's in the box" section that it includes an AC power cord. does this mean i will have to purchase the USB/mini DIsplayport cable separately?

  • Problem while import u201CSAPKU60003 & SAPKNA7013u201D into SAP CRM 2007

    Gentlemen, I have a problem while import u201CSAPKU60003 & SAPKNA7013u201D into SAP CRM 2007, My current Support Package Level is: SAP_ABA       700     0015 SAP_BASIS     700     0015 PI_BASIS      2006_1_700     0006 ST-PI     2005_1_700     0006 C

  • Adding up a Custom Field Approver in Purchase Requisition

    Hi,   Could anyone please let me know how to addup a custom field Approver to Purchase Requistion.    Requesting you to list down the User enhancements that are available for PR Lineitems screen.    The transaction used is ME51N. Regards, Ganga

  • Bogus "Upgrade AIR Runtime" messages

    I am developing using Flash Builder 4.5.1 on Mac, debugging via USB on a Motorola Xoom.  Every time I run or debug my app on the device, I get the following dialog box: Upgrade AIR Runtime Your device has an older version of Adobe AIR installed. Woul