Results 1 to 6 of 6

Thread: How to launch JavaScript functions in PDF

  1. #1
    Join Date
    Nov 2009
    Posts
    583

    How to launch JavaScript functions in PDF

    Hi all,

    I am a script developer in on one company, My company want to created an API wherein developers will have the ability to launch JavaScript functions in PDF. But i do not have idea about this. I think AJAX will help them. But exactly how ?? Any suggestion is appreciated.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to launch JavaScript functions in PDF

    You need to add Adobe API for JavaScript in PDF. You do not need to tagging the document on it and adobe is automatically created a shortcut like " That" on the document. "That" will not really create any security problems because by default. Because you are already on PDF document. You should try this and reply.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    How to launch JavaScript functions in PDF

    You can add a javascript on Pdf by these ways if you want to add a page open action.
    # Right-click the page thumbnail you want to apply the action to on the Pages tab.
    # Then select Page Properties to open the dialog box.
    # click the trigger drop-down list and choose an option.
    # You can choose either Page Open or Page Close.
    # Then select Run a JavaScript from the Actions drop-down list.
    # click on add.
    # write the script on the JavaScript Editor dialog box.
    # click OK to close the box.
    # Return the page Properties dialog box.
    # you can see the actions a Page Open Run JavaScript now appears.
    # Close and save the file.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    How to launch JavaScript functions in PDF

    If you want to add document actions ,then follow these steps:
    # Select Advanced > JavaScript > Set Document Actions.
    # Choose a document action from the list in this dialog box.
    # Then select the JavaScript action from the list
    # click on edit button.
    # Add the script in java script box.
    # Click on OK to close the dialog box.
    # Return to the Document Actions dialog box
    # You find that the script appears in the bottom window, and a green dot appears to the left of the action's line in the listing.
    # click OK button to close the windows.

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to launch JavaScript functions in PDF

    I will give you the example of javascript that mark misspelled words with squiggle in Pdf document.

    Code:
    var chWord123, numWords123;
    for (var i = 0; i < this.numPages; i++)
    {
        numWords123 = this.getPageNumWords(i);
        for (var j = 0; j < numWords123; j++) {
            ckWord = spell.checkWord(this.getPageNthWord(i,j))
            if (ckWord123 != null) {
                this.addAnnot({
                    page: i,
                    type: "Squiggly",
                    quads: this.getPageNthWordQuads(i,j),
                    author: "my self",
                    contents: ckWord123.toString()
                });
                }
            }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,297

    How to launch JavaScript functions in PDF

    This a javascript code for extract ISBN numbers From the Pdf Document.


    Code:
    var reISBNban=/(ISBN[\:\=\s][\s]*(?=[-0-9xX ]{13})(?:[0-9]+[- ]){3}[0-9]*[xX0-9])|(ISBN[\:\=\s][ ]*\d{9,10}[\d|x])/g;
    
    var strExtban = "_Extracted_ISBN.pdf";
    var strIntroban = "ISBN numbers extracted from document: ";
    var strFinalban = "Total number of ISBN numbers extracted: " ;
    
    ExtractFromDocument(reISBNban,strExtban,strIntroban,strFinalban);
    
    function ExtractFromDocument(reMatch, strFileExt, strMessage1, strMessage2)
    {
    var chWordban, numWordsban;
    var filenameban = this.path.replace(/\.pdf$/, strFileExt);
    try {
        var ReportDocban = new Report();
        var Outban = new Object(); 
        
        ReportDocban.writeText(strMessage1 + this.path);
        ReportDocban.divide(1);    
        ReportDocban.writeText(" ");     
        for (var i = 0; i < this.numPages; i++)
        {
            numWordsban = this.getPageNumWords(i);
            var PageTextban= "";
            for (var j = 0; j < numWords; j++) {
                var word = this.getPageNthWord(i,j,false);
                PageText += word;
                }
        
            var strMatchesban = PageText.match(reMatch);
            if (strMatchesban == null) continue;
                  for (j = 0; j < strMatches.length; j++) {
                Out[strMatches[j]] = true; 
                }
        }
            var nTotalban = 0;
        for (var prop in Out) 
        {
            ReportDoc.writeText(prop);
            nTotal++;
        }
            ReportDocban.writeText(" "); 
        ReportDocban.divide(1); 
        ReportDocban.writeText(strMessage2 + nTotal);
        
       ReportDocban.save(
            {
            cDIPath: filename
            });
    
    }
    catch(e)
    {
    app.alert("Processing error: "+e)
    }
        
    }

Similar Threads

  1. Can I Define and Call my Own Functions in JavaScript?
    By Rob Dizzle in forum Software Development
    Replies: 5
    Last Post: 09-02-2010, 05:18 AM
  2. Replies: 7
    Last Post: 21-11-2009, 10:45 AM
  3. Help With Serveral Functions in Javascript
    By twiitegxa in forum Software Development
    Replies: 0
    Last Post: 21-07-2009, 04:20 AM
  4. Replace you Quick Launch Bar with True Launch Bar
    By Jimmy24 in forum Customize Desktop
    Replies: 3
    Last Post: 26-03-2009, 01:50 PM
  5. Functions in PHP
    By Gyan Guru in forum Guides & Tutorials
    Replies: 3
    Last Post: 13-12-2008, 06:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,114,905.80477 seconds with 16 queries