How to execute javascript code in VBScript?

I'd like to execute similar javascript code for some particular PDF files(parameters for pagenumber are quite different),such as:
this.setPageLabels(0, [ "A", "", 3] );
this.setPageLabels(1, [ "r", "", 1] );
this.setPageLabels(16, [ "D", "", 1] );
How to write the code in VBScript?
Thanks in advance!
P.S. I try to add code but end up with error messages
=================================================================
path = "E:\test.pdf"
'//Write the first and last pagenumbers and label to a txt.
set oWs = CreateObject ("Wscript.Shell")
set fs = CreateObject("Scripting.FileSystemObject")
oWs.run "Acrobat.exe"
While not oWs.AppActivate("Adobe Acrobat") : Wscript.Sleep 1000 : Wend
Set objArgs = WScript.Arguments
if objArgs.Count = 1 then path = ObjArgs(0)
Set gApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
If (AVDoc.Open(Path,"")) Then
Set AVDoc = gApp.GetActiveDoc()
Set PDDoc = AVDoc.GetPDDoc()
Set JSO = PDDoc.GetJSObject
'// Write Bookmark JS to a variable
Ex = " var vTOC = """"; "&vbLF _
& " var s = """"; "&vbLF _
& " var i=0; "&vbLF _
& " p = i+1; "&vbLF _
& " vTOC += ( this.getPageLabel(i) +""|""); "&vbLF _
& " i= this.numPages-1 ; "&vbLF _
& " p = i+1; "&vbLF _
& " vTOC += ( this.getPageLabel(i) +""|""+p+""|""); "
' // Execute the JavaScript
Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
AForm.Fields.ExecuteThisJavaScript EX
' // Write Bookmarks to CSV (PageNr;Level;Text)
Set JSO = PDDoc.GetJSObject '//->renew JSO for some unknown reasons
xf = jso.vToc
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
objIE.document.parentwindow.clipboardData.SetData "text", xf
objIE.Quit
CsvFN = left(path, InstrRev(path, ".")-1) &"_page.txt"
set FL = fs.OpenTextFile(CsvFN, 2, true) '//-> 2=ForWriting
xWr = split(xf,"|")
for x=0 to UBound(xWr)
FL.WriteLine xWr(x)
next
FL.Close
Else
MsgBox "Failed to Open: " & Path
End If
Set JSO = Nothing
Set PDDoc = Nothing
Set AVDoc = Nothing
Set AForm = Nothing
Set gApp = Nothing

If I remember right, I wrote this script a while back to demonstrate how java script can be direct executed and how you can get back the results. Didn't I wrote a commentary to that?
However the parts you need:
' // Write JS code from help file or whatever to a VBS variable:
JsFromHelp = " this.setPageLabels(0, [ ""A"", """", 3] ); "&vbLF _
& " this.setPageLabels(1, [ ""r"", """", 1] ); "&vbLF _
& " this.setPageLabels(16, [ ""D"", """", 1] ); "
' // Execute the JavaScript
Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
AForm.Fields.ExecuteThisJavaScript JsFromHelp
From the rest keep only:
end if
set .. = nothing
Untested, but should work - as far as you have a little bit more then only Reader.
HTH, Reinhard

Similar Messages

  • How to execute javascript?

    hi all,
    how to execute javascript code in our objective-c, is there any api? suppose i want execute the code
    <script type="text/javascript"
    src="http://www.google.com/jsapi?key=ABQIAAAAO1slybBNbjKwDVr_bO5qxQ3Ib9Aa-xgEU0YCgCQd4sHEEyygRTJoMiR_tlaeIJegVqgl85s-kvLA"></script>
    <script type="text/javascript">
    google.load("maps", "6");
    google.load("search", "1");
    how to execute this code please help for me..
    Regards,
    Karthik

    hi,
    thanks for reply, i am somewhat understand that UIWebView used to load the webview, but i want to use the google map api Javascript for my application, how to incorporate that, also how to load a google map link,
    Regards
    Karthik

  • How to execute javascript function then Code Behind in an ASP Button

    Hi Guys,
    I am currently working in a web application. I have a problem with calling a js function and codebehind.
    I have this asp button that when clicked, a javascript function should be called.
    My javascript function is like this:
    function Calculate(){
    // Set Route in google map
    // Store distance, lat/long in an array
    Then, after the Calculate function was executed, it should execute the code behind:
    protected void btn_calculate_onclick(object sender, EventArgs e)
    // Pull data stored in the array created by javascript
    // connect to db
    // store data
    But the javascript function doesn't execute.
    What should i do?
    Thanks in advance

    Hello,
       javascript function can not executed in server side, you can tranlate javascription fuction to c# function.
     if the reply help you mark it as your answer.
     Free
    Managed .NET
    Word Component(Create,
    Modify, Convert & Print)

  • OutputText executing Javascript Code

    [this forum|http://forums.oracle.com/forums/thread.jspa?threadID=897025]
    Hi everyone,
    I'm trying to include some javascript code to be executed when a jsff loads. In this sense, following the idea shown in this forum i wanted to include the script shown bellow:
    <af:outputText value="alert(&quot;in script&quot;);
    var x = document.getElementById(&quot;pg_scroll&quot;);
    x.scroll(0,0);"
    id="ot2"
    escape="false"/>
    (please, notice &quot; is the equivalent to ")
    The main idea is to retrieve the id of the element "pg_scroll" that is a PanelGroupLayout with its layout set to scroll, and the set the scroll to the Top using that javascript fuction. The reason is that when the page loads, the scroll goes directly to the bottom of the panelGroupLayout.
    When I tried it, the outputText is showing itself as it is. It is not executing the script. What am I doing wrong?
    Any suggestion, idea, workaround?
    Thank you very much!
    Rgds,
    Juanma.

    It worked, Sireesha!
    Probably it didn't work before because I was wrapping the script in a CDATA block... i don't know...
    Now struggling about how to retrieva a component I have in the jsff to set scrollTo(0,0)... I'm trying with AdfPage.PAGE.findComponentByAbsoluteId(_component_id_), but I don't know how to refer to the component.
    My PanelGroupLayout had id="pg_scroll", but
    var x = AdfPage.PAGE.findComponentByAbsoluteId("pg_scroll");
    x.scrollTo(0,0)
    didn't work.
    Any idea?

  • How to execute javascript file on event..

    Hi... I made a template form. After filling it, when user press the button, i want to execute a javascript code which is in a .js file. What do I have to write in the code related to the button? Thanks

    Acrobat JavaScript has some unique objects, properties, and methods that are unique to Acrobat. Adobe has poset a number of documents deatiling the Acrobat's JavaScript.
    JavaScript for Acrobat: http://www.adobe.com/devnet/acrobat/javascript.html
    Acrobat Documentation: http://www.adobe.com/devnet/acrobat/?view=documentation
    The location of the application folder, depends upon the OS and Acrobat/Reader version.
    Use or a folder level JavaScript, requires the JS file to be installed on each client computer
    To impliment a counter there are a number of ways. The easiest is to use a 'global' 'subscribed' variable. See the August 2004 (issue 34) of the Acument Traing Journal, http://www.acumentraining.com/acumenjournal.html, for information about how to do this.
    One can also use the ADBC, Adobe DataBase Connection or a submit to a web server script page to obtain data from a file.
    If you want to read and write a file in Acrobat/Reader there are a number of restrictions.

  • How to write javascript code in SERVLET

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.print("<HTML><HEAD><TITLE> DATA NET</TITLE></HEAD>");
    I have to write the following javascript code ......how to do??
    -------------------------javascript code--------------------------------
    <BODY onLoad="pageload();">
    <SCRIPT>
    function pageload()
    var time;
    time="200";
    URL="Default.jsp";
    self.setTimeout("top.location.href=URL;","time");
    </SCRIPT>
    </BODY>

    you are using this:
    out.print("<HTML><HEAD><TITLE> DATA NET</TITLE></HEAD>");
    to print the header of the HTML page...
    I will ask again... what makes you think that writing Javascript or any other contents of an HTML page would be any different?

  • How to execute separate code for the first item inside forloop?

    Hi All,
    I would like to execute "foreach (SPListItem item in items)". Here, for the first item i want to execute separate code and all other items should execute another code. How to achieve this?

    Basic .NET question... not really a SharePoint question...
    Option one, create a counter:
    int myCounter = 0;
    foreach (SPListItem item in items)
    if (myCounter == 0)
    else
    myCounter++;
    Option 2 - use a for loop
    for (int i = 0; i < items.count; i++)
    SPListItem item = items[i];
    if i == 0)
    else
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

  • How to execute some code in command line, and read its output?

    I'v found here http://www.sap-advisor.com/abap-coding/how-to-execute-operating-system-commands-from-within-sap/ that I can execute commands from the windows command line for example inside SAP.
    But I want to take it one step further and read its output. is it possible?

    Hi RagnaRock,
    one possible approach can be outputting the results of the command into a text file (i.e. "command >result.txt"), and then read this file from SAP/ABAP.
    I hope this helps. Kind regards,
    Alvaro

  • Executing javascript code for button click

    in my application i have report page where i am displaying table data when i click a button it selects first row and returns it using htp.prn() now i m getting that record in jvascript now i want to execute this java script code when the button is clicked i tried using onClick attribute but it didn't work can anyone tell me how to do it?

    Hi,
    I think this is related to Application express, right ?
    You could post your question in Application Express forum
    Oracle Application Express (APEX)
    Also please give more detail about your issue. Post e.g. code (pl/sql & javascript) you try to use.
    Also if you setup sample about your problem to http://apex.oracle.com will help others to help you.
    Help us to help you =)
    Br, Jari

  • How to use javascript code in a plugin ?

    Hi,
    I'd like to use javascript in my plugin but after reading the JS API reference, i still don't understand where the code should be placed, and to call it from my plugin.
    I'm quite new in Acrobat SDK and developping applications in Acrobat using Javascript, so I hope it's not a dumb question...

    >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

  • How to link Javascript code stored in a separate folder to a Form

    I have some Javascripts stored in a differnt Folder. If I want to achieve some different functionality in my forms , how and where do I link this folder. I tried in the Form Edit mode to attach it in the HTML code in the Script tag with the SRC attribute but not been successful.
    Help on this will be highly appreciated
    Thank you all in anticipation
    Cheers
    Nitin

    Hi,
    Simplest way would be to drag the script object to be under the root node (form1). On both pages would would then be able to reference the function by:
    testScript.doThisNow();
    If you leave the script object under page1, then from page2, the following should work:
    page1.testScript.doThisNow();
    Hope that helps,
    Niall

  • How to execute the Code-Behind of .aspx linked using XML Data Connection

    I have a dashboard with a live XML Data Connection tied to a Default.aspx file.  That .aspx file has a Default.aspx.vb code-behind file tied to it with some logic in the Page_Load sub routine.  If i open the .aspx on my own in the browser, the code-behind executes properly.
    However, when I tie the .aspx to my dashboard and launch it I know for a fact the .aspx is being called (i have a placeholder on the dashboard to let me know if it executed or not) but its code-behind file is not.  I can't seem to find a solution through Google, would anyone be able to lead me in the right direction with this?  My code is as follows:
    Default.aspx
    <%@ Page Language="vb" aspcompat="true" Debug="true" validaterequest="false" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="scheduleAppointment._Default" %>
    <%    
        'tester to see that script executes, this puts "ScriptExecuted" on a label on my dashboard
        Dim sXML As String   
        sXML = "<data><variable name=" + Chr(34) + "Range_0" + Chr(34)
                      + "><row><column>ScriptExecuted</column></row></variable></data>"
        Response.Write(sXML)
    %>
    Default.aspx.vb
    Imports Microsoft.Office.Interop
    Partial Public Class _Default
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                (I have code here creating a Microsoft Outlook appointment and saving/scheduling it. This is not being
                 executed when running the dashboard itself, but I know the code works if I run the .aspx on my own
                 in Internet Explorer browser)
        End Sub
    End Class

    Easy fix, apparently code-behind doesn't execute in Preview mode.  Exported to .swf and ran in the Internet Explorer browser and it worked.

  • How to Execute a code in form postSubmit event

    Dear all,
    I have a simple code which is executed perfectly when I put it in form :preSubmit: event but when i moved it to the :postSubmit: event it doesn't work at all .
    Please let me know where to put my code if I need it just to be executed once the form submitted ??
    Thanks in advanced,
    Mohammed Al-Mosleh

    Try using this code:
    var vMsg = ""; //message to display for the missing required fieldsvar successflag = 1; //flag to determine if any required field is null
    //validate all required text fields  
    for (var nPageCount=0; nPageCount<xfa.host.numPages; nPageCount++) { 
    var oFields = xfa.layout.pageContent(nPageCount,"field"); 
    var nNodesLength = oFields.length; 
    for (var nNodeCount=0; nNodeCount<nNodesLength; nNodeCount++) { 
    if (oFields.item(nNodeCount).mandatory == "error" ){  
    if (oFields.item(nNodeCount).rawValue=="" || oFields.item(nNodeCount).rawValue==null){ vMsg += oFields.item(nNodeCount).name + ", ";
    successflag = 0;
    ---------write your code
    if (successflag == 1)
    execute the insert into database code
    else
      xfa.host.messagebox(vmsg); //displays the missing field names
    Regards,
    Chaitanya

  • How to execute custom code only when a specific node is selected in infoset

    Hi,
    We have written a piece of custom code under a node (P1045). Not all users will have access to this Infotype as it is related to Appraisals. So, when users (w/no access to 1045) try to run a Query for other info types data, they are getting error message 'Can not access 1045'. Custom code is getting generated whenever user runs a query. Tried to control custom code with simple IF condition by giving user name. Still generating 1045 code.
    All users use same infoset, where a group of users has access to 1045 and another group does not have access to 1045.
    Appreciate your inputs to get this resolved.
    Thanks,
    Swapna.

    Why don't you try another aproach, instead of adding the infotype to the infoset, create a new table as an alias (with the fields you want to show in regards to infotype 1045) and fill it in the node depending on the authorization check for that infotype in the code ?
    I think that adding the infotype as a node will always get the data from the infotype regardless, that is why it's showing the error.

  • How to execute BC4J code on remote server using DBC Files

    Hi People,
    I have a requirement here that i do not know if it's possible to achieve. We have an Application Module that fetches some records and another Application Module that receives them as parameters and inserts these records in interface tables. However, the BC4J code is installed on the JAVA_TOP of the Development Instance, and will not be installed on the destination server. What i would like to do is to place the target instance DBC file on the FND_TOP/secure directory on the Dev instance, and instantiate the Application module pointing to this DBC file, so that the AM connections would point to the target instance (thus inserting the data on the correct tables). Is that possible?
    Please let me know if you want further clarification. I have seen something similar working on iSetup (extract from source env -> Load on dest env) but have got no clue about implementing that.
    Best regards
    Thiago

    Hi,
    you can follow this steps.
    1. Create a database link to the remote server
    CREATE DATABASE LINK remote_Server
    CONNECT TO apps IDENTIFIED BY apps
    USING 'remote';
    2. Create a Synonym for the table in the remote server
    CREATE SYNONYM po_headers_remote
    FOR po_headers_all@remote_Server
    3. Create entity object based on this synonym.
    4. Create View Object based on above EO.
    Through this view object you can udpate remote database...
    Hope this helps.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Encore and Windows 7

    I have successfully moved my Premiere 1.5 over to my new Windows 7 system.  I now want to get a version of Encore.  Does anyone know which versions are compitable with Premiere 1.5 AND Windows 7? Thanks in advance...

  • Myanmar Burmese text not showing properly on Richtextbox c#

    Hello Can't get Myanmar Burmese text to display properly on Richtextbox c#, I get some boxes instead of real text, any advise ? I've already tried several fonts without success, unless there is a font, that I don't know about, or is not installed in

  • Make VI or LLB Writable

    Hello, I have an LLB with VI's from an equipment vendor. I just upgraded to LV2012 and when I open the LLB or the VI's inside they are recompiled for the new LV version. When I exit labview it asks if I would like to save changes, i.e. the recompile,

  • CommandButton action executing while Page Refresh

    Hi, I am developing an Application in ADF. I have a method in Backing Bean. I am associating this method to action Property of CommandButton in jspx Page. <af:commandButton text="Submit" action="#{backing_blockingRowWhileLoading.doNotExecuteOnPageRef

  • Mapping data from two subrecords

    Hi I have a problem with a simple mapping. The source and the target are given. See image for more details: http://www.flickr.com/photos/38594397@N03/3548820512/sizes/o/ The problem is that when the second subrecord is not fillt the data of the secon