Jump to a specific bookmark using JavaScript

Hello,
I am able to successfully jump to a specific bookmark in a PDF document when I run the following code in the Debugging Console:
// Jump to "Monthly Summary"
for (var i=0; i<this.bookmarkRoot.children.length; i++) {
            if (this.bookmarkRoot.children[i].name.indexOf("Monthly Summary")!=-1) {
               this.bookmarkRoot.children[i].execute();
The problem is that I would like to be able to run this code in a folder level JavaScript file ,however, the above code does not work for me.
What must I change to make this code work in an external JavaScript file?
Any help would be appreciated.
Thanks
Linda

Since a bookmark only exist as an object in a PDF file how can it work as written as a folder level script without any control. All folder level scripts are run when the Acrobat/Reader application is started and possibly before any PDF file is opened. So your code will run but not find any bookmarks.
Have you tired to run this code when there is no open PDF file?
I get the following error when there is no open PDF:
this.bookmarkRoot is undefined
3:Console:Exec
TypeError: this.bookmarkRoot is undefined
3:Console:Exec
undefined
The "undefined" means there is no bookmarkRoot defined or found. Note bookmarks only exist within a PDF file that have bookmarks.
Next, once you get a PDF open, how are you going to get this code to run for the form when there is no way to identify the block of code to run?
As George has suggested you need to create/define a function and then call that defined function form within the PDF. Once a function is defined, that function can be called by the name of the function as part of the document level function for a PDF form, or as a field or bookmark action.
Since you have decided to place this code in the user's Acrobat JavaScript folder, how are other users going to call this code located on your system. Using your approach will require all users need to install your code on their system. If you were to put the code in the PDF as a document level script, the script it could execute upon opening the PDF. If one put it in as a document level function, then it could be called upon opening the PDF, as a bookmark, as a button, etc.
I would look for a function to open any bookmark in the PDF by bookmark name by searching for the existence of that named bookmark. With this approach, I could use the function in any PDF and execute any possible bookmark as needed.

Similar Messages

  • Add bookmark using javascript, it opens in the sidebar, not in the main window

    im using this function:
    function add_bookmark(){
    var title = "My Title";
    var url = "www.myurl.com";
    window.sidebar.addPanel(title, url, "");
    it successfully creates a bookmark but when i click on it, it just opens in the sidebar and not in the main window.

    Don't use that function as it selects the "Open this bookmark in the sidebar" feature in Properties for the bookmark. That is the way it works in Firefox and it probably won't ever be fixed. Someone filed a Bug about fixing that in Firefox back in 2004 or 2005, and the Mozilla developers marked it as WONTFIX due to perceived security issues with scripts of that sort.

  • Renaming Bookmarks using javascript?

    I have several pages that are generated from another macro and compiled into a single binder. The problem is when we have multiple PDFs and we need to combine them the bookmarks numbers do not sync.
    So if I have pages in the first PDF ranging from 001-073 and then insert another PDF the bookmark ranges starts back to 001 and not picking up at 074 to XXX. Is there a possible solution to this?
    You can see a snap shot of the issue below.
    Thanks guys!

    try67 I am looking for an automated process, there are 200-500 bookmarks depending on the project. If I understand you correctly you are saying to modify
    each bookmark by right clicking/rename?? Or maybe I need to read that again after I have my coffee.

  • Rearranging existing bookmarks with javascript

    Hi,
    I run Create > PDF from Web Page and I end up with a PDF where I have all bookmarks pointing to the correct pages, but some of them are in the wrong order, and all are in the same level.
    I need to programmatically reorder the bookmarks using javascript. I have never used javascript before, so if anybody had done something similar and could give me a hand, it would be greatly appreciated.
    Thanks!
    Flavia

    There is a bookmark object in the Acrobat JavaScript model.  Look it up.  It has a method named insertChild(). You can use this function to reorder the bookmarks.  You could even do it based on page order. However, if this is a one time activity, it's just as easy to reorder them by hand, in Acrobat.
    You can also write a script to automatically reorder the pages based on the bookmarks using the the "doc.movePage()" function. I've written lots of scripts to do this sort of thing. In fact, there is one up at www.pdfscriting.com. It's labeled "Use Bookmarks to Re-order pages"
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)
    Having trouble, Why Doesn't my Script Work?

  • Javascript question. Possible to save bookmark with javascript in Safari?

    Is it possible to save a bookmark using javascript in Safari?
    In IE I use:
    window.external.AddFavorite(url, title);
    In Firefox I use:
    window.sidebar.addPanel(title, url,'');
    In Safari I have no clue.
    Any thoughts, is it even possible?

    I'm going to call this bookmark function from inside a Flash application and I don't want the URL to be the exact URL that the Flash application has.
    If you have a solution to the problem I would be very happy if you could post it!

  • CAML Query to get specific item in folder based on dropdown value using Javascript client object model

    Hi,
    I am using the Javascript Client object model.
    I have a custom list and a custom document library.
    Custom list contains 2 columns - dlName , dlValue
    The document library contains 2 folders - "folder1" ,  "folder2" and contains some images.
    The image name starts with the "dlValue" available in the custom list
    I am using a visual webpart and using javascript client object model.
    I am trying to achieve the below functionality:
    1) Load a dropdown with the custom list.
    2) set the image based on the value in dropdown.
    I have achieved the first option, I have set the dropdown, but not sure how to query the folder and set the image.
    Below is the code i have used so far:
    //In Visual webpart
    <select id="ddlTest" >
    </select>
    <br/>
    <div id="PreviewLayer">
    <img id="imgPlaceHolder" runat="server" alt="Image" title="imgPlaceHolder" src=" " />
    </div>
    // In Javascript file
    function RenderHtmlOnSuccess() {
    var ddlTest = this.document.getElementById("ddlTest");
    ddlTest.options.length = 0;
    var enumerator = this.customListItems.getEnumerator();
    while (enumerator.moveNext()) {
    var currentItem = enumerator.get_current();
    var dropdownValue = currentItem.get_item("dlValue");
    ddlTest.options[ddlTest.options.length] = new Option(currentItem.get_item("dlName"), dropdownValue);
    setImage(dropdownValue); // Not sure how to query the folder and set the image based on value.
    // Also if dropdown value is changed, corresponding image should be shown
    How to query the folder and based on dropdown value, show the image? Also, how to handle the dropdown value change?
    Thanks

    Hi,
    Here are two links for your reference:
    Example of how to Get Files from a Folder using Ecmascript \ Javascript client object model in SharePoint 2010
    http://sharepointmantra.wordpress.com/2013/10/19/example-of-how-to-get-files-from-a-folder-using-ecmascript-javascript-client-object-model-in-sharepoint-2010/
    SP2010 JSOM Client Object Model: How to get all documents in libraries including all folders recursively
    http://sharepoint.stackexchange.com/questions/70185/sp2010-jsom-client-object-model-how-to-get-all-documents-in-libraries-including
    In SharePoint 2013, we can also use REST API to achieve it.
    http://msdn.microsoft.com/en-us/magazine/dn198245.aspx
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Is there a way to selectively disable "quick search" on specific websites (i.e. those which use javascript-driven keyboard shortcuts)

    Some websites use javascript (or differently) driven keyboard shortcuts - for example some google services or the tinytiny-rss feed reader. On those sites users normally don't use the "quick search" function, but it tends to get in the way of the keyboard shortcuts which tend to be pretty useful.
    So, is there a way selectively disable quick-search on some websites? Maybe there is a Addon for this?
    Thanks in advance, Kind Regards
    - NebuK

    1.SmartyPanouZe3rd,
    Sep 4, 2013 1:03 PM   in reply to SmartyPanouZe3rd
    This is a follow-up to the above question I had.
    Since i noticed people looking at the question, but no replies showing up, i contacted BC support directly with the same question.
    I got a reply.
    I did tests based on the reply.
    Here is what is going on based on the reply.
    (spoiler alert : It works... but it's not yet a perfect score.)
    All the details are posted here :
    http://www.animavdo.com/mut/ambiguity-001.html
    Hope this can help others.
    Cheers.
    PS  I still will use DW for the heavy lifting...
           But MUSE is nice for quickly putting together a mini website.
           Highly recommended App.

  • Adding text to indesign pages with specific font ,size,and color using javascript

    Hello,
    Using javascript i am able to add some text to each page of an indesign file.
    myNewText = "SOME TEXT"
    myTextFrame = myPage.textFrames.item(0);
    tempframe = myTextFrame.contents;
    myTextFrame.contents =  myNewText + tempframe ;
    But i want to specify the font used,size and color for that text.
    When i try the code mentioned in indesign javascript scripting guide
    myNewText .appliedFont = app.fonts.item("Times New Roman");
    myNewText .fontStyle = "Bold";
    nothing gets changed and font family already used stays the same.
    How can i do that only for the added text and not for the whole content?I dont want to add the text to a new text frame I want to append it to the existing text frame.
    And is there a way to specify font size too?
    thank you

    There's a mixup going on here. Let's see if we can sort out some of it
    at least.
    If you just want to add new text to an already existing text frame,
    that's easy:
    myTextFrame.contents += "Hello";
    But if you want the new text to have unique formatting, it's a little
    more complicated.
    There are two simple ways to do it, I think:
    1. Create a temporary text frame, as you have done, and add the text,
    and format everything in there. Then move() that formatted text to the
    end of myTextFrame and delete the temporary frame:
    tempFrame = app.activeDocument.textFrames.add();
    tempFrame.contents = "New Text";
    tempFrame.paragraphs[0].appliedFont = app.fonts.itemByName("Times New
    Roman"); // etc...
    tempFrame.paragraphs[0].move(myTextFrame.insertionPoints[-1],
    LocationOptions.AFTER);
    tempFrame.remove();
    2. The other option, is to add the text directly to your textFrame. But
    if you want to format only that text, you have to store where the text
    started:
    myTextFrame = app.selection[0];
    firstInsertionPoint = myTextFrame.insertionPoints[-1].index;
    myTextFrame.contents += "New Text";
    myAddedText =
    myTextFrame.characters.itemByRange(myTextFrame.insertionPoints[firstInsertionPoint],
    myTextFrame.insertionPoints[-1]);
    myAddedText.appliedFont = app.fonts.itemByName("Trajan Pro"); // etc.
    What you've done in your sample script, however, is to try to apply a
    font to a simple JavaScript string. It won't work, but the way you did
    it, it won't throw an error either, because in fact you've created a new
    property of your string. (myString = "Hello"; myString.appliedFont =
    "Times"; // myString now has a Javascript property called appliedFont --
    but that's nothing to do with InDesign!)
    HTH,
    Ariel

  • How to use JavaScript to Open a link automatically

    Is there a method (using JavaScript) to allow a user clicked link to open the link through a “intermediary” page?
    For example, say I have a web page with a embedded Flash file that contains links to several different (outside) web pages. The behavior I want is that the user clicks a link (within the Flash file), a HTML window opens (over the 1st HTML/Flash window) with the new content, leaving the original Flash/HTML window displayed in the background. The user reads the new content. The user can then close the newer window and be back at the displayed HTML/Flash file.
    The twist is that the link embedded in the referring Flash/HTML file goes to a “intermediary page”. Call that the “collector” page. I control that page. On that page I have collected (in a list) all the actual outside URLs (I do this so that I can easily change the URLs using HTML rather than having to edit the Flash file.) The Flash file contains essentially the same URL for each outside location (plus a variable unique to a specific URL).
    The user should not ever actually see this intermediary/collector page. Instead, they click the link, a variable is passed from the referring page to the collector page and fires the corresponding link automatically (replacing the content in the newly created window). Since the link fires automatically the content in the new window (initially created by the collector page) changes to the destination content.
    Is this possible?
    What JavaScript functions are used?
    How are the referring links constructed in the Flash so the variable is passed to the collector page?
    How does the “collector” page auto open the actual content?
    If anyone can point me to descriptions on how this might be done I’d certainly appreciate it.
    TPK

    >is there a way i can call javascript without security checking?
    It wouldn't be security if you could just bypass it. Did you read all
    the security notes? You might be able to do something with trusted
    functions, but I'm not sure how that would integrate with a plug-in.
    Aandi Inston

  • Retrieving list items from a specific view using CSOM

    How can I query a specific view of a SharePoint List using the C# CSOM? I am dealing with SharePoint Online, so the only option is to use SharePoint.Client.
    I have done this using Javascript, and I know how to do this with SharePoint On-Premises, but I haven't found a way to do with for SharePoint online using C#.

    hi Dkhouri,
    thanks for posting your issue, you can create a specific view of a list using CSOM and C#.
    Kindly find the code snippet below fort he same.
    Code for CSOM :- 
    // Starting with ClientContext, the constructor requires a URL to the
    // server running SharePoint.
    ClientContext context = new ClientContext("http:SiteUrl");
    // Assume the web has a list named "Announcements".
    List announcementsList = context.Web.Lists.GetByTitle("Announcements");
    // This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll"
    // so that it grabs all list items, regardless of the folder they are in.
    CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
    ListItemCollection items = announcementsList.GetItems(query);
    // Retrieve all items in the ListItemCollection from List.GetItems(Query).
    context.Load(items);
    context.ExecuteQuery();
    foreach (ListItem listItem in items)
    // We have all the list item data. For example, Title.
    label1.Text = label1.Text + ", " + listItem["Title"];
    For C# 
    public CamlQuery CreateInventoryQuery(string searchSku)
    var qry = new CamlQuery();
    qry.ViewXml =
    @"<View>
    <Query>
    <Where>
    <BeginsWith>
    <FieldRef Name='SKU' />
    <Value Type='Text'>" + searchSku + @"</Value>
    </BeginsWith>
    </Where>
    </Query>
    </View>";
    return qry;
    Also, checkout below mentioned URLs for more details
    http://www.c-sharpcorner.com/UploadFile/sagarp/sharepoint-2013-caml-query-for-item-id-with-jquery/
    http://msdn.microsoft.com/en-us/library/ff798388.aspx
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Automatic Creation of Bookmarks in Javascript

    I need to create a bookmark based on a random string of text located in the same place on every page and I have approx. 1,000 pages to work with.
    For example, on every page there will be a string that has a format of XX-XXX-XX-XXXXX-XX.  It will be in the same location on every page.  The bookmark will need that string's value and point to the page that particular string occurs on.
    So on page 2 the string is Z1-0AA-D3-P99N2-AP, the bookmark inherits that name, and points to page 2.
    I have been searching these forums and the internet in general.  I realise I can use the following to start off with but I don't know how to find the string, name the bookmark after it, and then what is the correct value for X?  I don't think it would be this.pageNum, but I could be wrong.
    var FoundString = /\d{2}+"-"+\d{3}+"-"+\d{2}+"-"+\d{5}+"-"+\d{2}/ ?
    Edit: var FoundString = /\d{2}\W\d{3}\W\d{2}\W\d{5}\W\d{2}/
    this.bookmarkRoot.createChild({FoundString, X})
    I don't use javascript often so I'd definitely appreciate any assistance you can offer.

    Okay, after some consulting with a fellow co-worker, here are two scripts that work (both are his scripts):
    Absolute - this is for when you're 100% positive the position of the words never move.
    for(var i = 0; i < this.numPages; i++){
        var v1 = this.getPageNthWord(i,218);
        var v2 = this.getPageNthWord(i,219);
        var v3 = this.getPageNthWord(i,220);
        var v4 = this.getPageNthWord(i,221);
        var v5 = this.getPageNthWord(i,222);
        var vis = v1 + "-" + v2 + "-" + v3 + "-" + v4 + "-" + v5;
        this.bookmarkRoot.createChild(vis,"this.pageNum ="+ i,i);
    Regex - this will loop through and make sure the Regular Expression matches before creating the bookmark.  Best used if the word position moves.  It is really slow, though.  Really really slow.
    for(var i = 0; i < this.numPages; i++){
        for(var j = 0; j < this.getPageNumWords(i); j++){
            var v1 = this.getPageNthWord(i,j);
            var v2 = this.getPageNthWord(i,j+1);
            var v3 = this.getPageNthWord(i,j+2);
            var v4 = this.getPageNthWord(i,j+3);
            var v5 = this.getPageNthWord(i,j+4);
            var vis = v1 + "-" + v2 + "-" + v3 + "-" + v4 + "-" v5;
            var reg = /\d{2}-\d{3}-\d{2}-\d{5}-\d{2}/;
            if(reg.test(vis)){
                break;
        this.bookmarkRoot.createChild(vis,"this.pageNum ="+ i,i);
    Hopefully this helps someone out in the future!

  • Using Javascript to go to next page

    I'm trying to figure out how to advance to the next page in a captivate 3 course using Javascript. We have navigation buttons for "Prev" and "Next", but I'd like to be able to call some JavaScript when they click the Next button on a particular page, and then at the same time, advance to the next page.
    This is being launched from an LMS. The initial JS is going to set the score to 100%, which works fine. We typically have a "Close Course" button on the last slide to make sure it passes back a 100%, but many students are not clicking that button and the course simply returns a "passed" with a 0%.
    So making this JS call as part of the "Next" button should result in more 100% scores when they get to the end of the course, but I need it also to advance to the next slide.
    Thanks for any assistance!
    John

    Hi there
    Methinks you are overthinking this. Here's why.
    Note that any Button or Click Box obeject will release the pause when it has been clicked by the user unless you specifically configure it not to. If you assign some JavaScript to the Button object and the user clicks it, it does two things.
    Carries out the assigned action
    Releases the pause so the movie continues playing
    So I'm thinking in this case it's a simple matter of timing.
    Cheers... Rick
    Click here for Adobe Authorized Captivate and RoboHelp HTML Training
    Click here for the SorcerStone Blog
    Click here for RoboHelp and Captivate eBooks

  • Using javascript to control playback

    I'm trying to figure out how to use javascript to control
    playback of a captivate-movie.
    I want to control the playback (play, pause and so on) using
    javascript only. The playback-control in captivate does not "blend
    in" with the design on our website. I want to make a custom
    html/javascript playback-control.
    I was hoping that the captivate-player could be controlled
    easily with javascript, perhaps something like this:
    http://www.jeroenwijering.com/extras/javascript.html
    Any suggestions?

    quote:
    Originally posted by:
    CatBandit
    I don't know how to do it with Java-script, but yes, I think
    it can be done. I'll leave that to someone else more skilled at
    that than I.
    Have you considered creating your own Captivate playback
    controls? That might be another option. You can do that with a good
    image editor and some spare time. To see examples of what I'm
    talking about, try:
    Project > Skin > Skin (drop-list) > "bmp playbars"
    Paul Dewhurst, an Adobe Community Expert for Captivate has
    specific instructions for building your own playbars on his
    web-site "raisingaimee".
    Click
    here to see Paul's coverage of playbars
    Hope this helps - in any case,
    welcome to the Captivate User's Community!
    Thanks for the tip Larry! I will take a look at the link in
    your post.
    We already have a design for playback-control on our site
    (for embedded windows media player), which blends perfertly into
    our existing design. I really hope that it's possible to control
    the captivate-move with pure javascript. But I will "play around"
    wit the "bmp toolbars" feature. Thanks!

  • Is there any way to jump to a specific point in a long page?

    I'm trying (and failing) to find a way to create a navigation bar at the top of a long page that will allow you to jump to certain sections of that long page. I've tried using relative navto:// links, and hyperlinking to text anchor points, but nothing I try seems to work. Can anybody help? Is this even possible?

    In Smooth Scrolling articles, you can use decimals or percentages to jump to a specific position.
    Example: navto://myarticle#3.3 (jumps to a specific position in smooth scrolling article that displays the bottom of page 4 and the top of page 5)
    Example: navto://myarticle#50% (jumps to the middle of smooth scrolling article)

  • Jumping to a specific frame in another movie

    I'm wondering how to jump to a specific frame in an external
    movie. I'm not using the loadmovie command so I don't think the
    _level command will work. I just have two swf movies playing on the
    same page. I need to have a button in Movie A when released will go
    to a certain frame in Movie B. Thanks!

    well this certainly should work if the code is on the main
    timeline, and there is nothing else. However when you say
    'scrubber' do you mean that your 'testing' the movie by pressing
    'enter' while in the IDE, so that you're actually 'seeing' the
    playhead move? If this is the case, yes, no actions will execute.
    To test the swf file, use Ctrl+Enter (or Command+Enter on Mac) to
    run an actual 'test'

Maybe you are looking for