Basic VB.net and Javascript help

Ask a Question related to Adobe Acrobat SDK, Design and Development.

  1. #1

    Default Basic VB.net and Javascript help

    I am working on a VB.Net program with the JS interface object. I am trying to use the method addWaterMarkFromText from the JSObj. I can't find good documentation on the variables required as well as constants that can be used. Seems like an easy situtaion. Any pointers?
    Michael_O_Dell@adobeforums.com Guest

  2. Similar Questions and Discussions

    1. Include javascript in a javascript file
      Hello, Is there a way to include a javascript file from WITHIN a javascript file? Something similar as in the "#include" directive in C++? ...
    2. 3D basic
      I'm having some problems in 3D basic programming: 1. how can i remove one or more model in a 3D sprite on the stage? 2. how can i get the model's...
    3. output text in control location; calling control javascript from page javascript
      Hi; If you don't know, I'm just learning javascript and aspnet, but I have a pretty good grounding in windows programming. I'm trying to build a...
    4. Dark basic pro VS blitz basic 3D VS 3d game studio VS shockwave VS jamajic
      What are all your thoughts on the other leading 3D indi game creation packages out there? Are there others that I didn?t mention? here are a few...
    5. need javascript staff (anyone who knows javascript peroid) (READ)
      hey its me ultimategamerx and im back in some clothes lol i need some people who know java script i need help please reply if ya know some
  3. #2

    Default Re: Basic VB.net and Javascript help

    The JavaScript documentation has everything you should need...
    Leonard_Rosenthol@adobeforums.com Guest

  4. #3

    Default Re: Basic VB.net and Javascript help

    I already checked it out. It isn't the most descriptive API I have used. How do I get a single instance of App to use the constants that are described in the API?
    Michael_O_Dell@adobeforums.com Guest

  5. #4

    Default Re: Basic VB.net and Javascript help

    there only is one instance of app...
    Leonard_Rosenthol@adobeforums.com Guest

  6. #5

    Default Re: Basic VB.net and Javascript help

    I feel like you know something that is probably really easy to explain. I have a VB.Net project with the JS object in it. Now how do I use the constants in "app?" I looked at the API I saw examples but in the VB.Net it says that the variable isn't defined which means I need to get the instance, which I understand is singleton. Please a little more help than just a single line ending in a ... would help.

    Thanks,
    Michael O'Dell
    Michael_O_Dell@adobeforums.com Guest

  7. #6

    Default Re: Basic VB.net and Javascript help

    Hi Michael.

    I've been working on something similar. Hopefully we can help each other out.

    I created the following method that adds watermarks to a PDF file. It looks ugly in this text box but should copy into vb ok. Perhaps if you get it working you could please tell me how to get the instance of Acrobat to let go of the file. I.E. The method opens Acrobat to add the watermark, saves the files and closes it but Acrobat.exe is still left running in the TaskManager/Processes list. Until you terminate this process you cannot delete the file that you just added the watermark to because Acrobat is still using it.

    Anyway. I hope this helps and look forward to hearing back from you.

    Thanks,
    Joel

    Public Sub AddWaterMark(ByVal pdf_File As String, ByVal pdf_WaterMark As String)

    If pdf_WaterMark <> "" Then
    Dim pdf_PdDoc As New Acrobat.AcroPDDoc
    Dim pdf_JSO As Object

    If pdf_PdDoc.Open(pdf_File) Then

    'Get JSO object
    pdf_JSO = pdf_PdDoc.GetJSObject

    'Set WaterMark color
    Dim oColor As Object
    oColor = pdf_JSO.color.black()

    'Get page size for stamp placement
    Dim pdf_Page As Acrobat.CAcroPDPage
    Dim pg_Size As Object
    Dim pg_Rotation As Object

    pdf_Page = pdf_PdDoc.AcquirePage(0)
    pg_Size = pdf_Page.GetSize
    pg_Rotation = pdf_Page.GetRotate

    'You have to play with these numbers to get the watermark exactly where you want it
    Dim s_X As Double = 0
    Dim s_Y As Double = 0
    Dim s_Angle As Double = 90

    'Add a text watermark.
    'Function prototype:
    'AddWatermarkFromText(cText, nTextAlign, cFont, nFontSize, oColor, nStart, nEnd, bOnTop, bOnScreen, bOnPrint, nHorizAlign, nVertAlign, nHorizValue, nVertValue, bPercentage, nScale, bFixedPrint, nRotation, nOpacity)
    pdf_JSO.addWatermarkFromText(pdf_WaterMark, 0, "Helvetica", 16, oColor, 0, 0, True, True, True, 0, 0, s_X, s_Y, False, 1, False, s_Angle, 1)

    End If

    'Save doc
    pdf_PdDoc.Save(Acrobat.PDSaveFlags.PDSaveIncrement al, pdf_File)

    'Clean Up
    pdf_JSO = Nothing
    pdf_PdDoc = Nothing

    End If

    End Sub
    jswota@adobeforums.com Guest

  8. #7

    Default Re: Basic VB.net and Javascript help

    Hi Joel,
    My code does not have that problem, I compared our code and mine has this at the end:

    ' to clean up, get the Acrobat application,
    ' close Acrobat if there are no open documents.
    Dim gApp As Acrobat.CAcroApp
    gApp = CreateObject("AcroExch.App")
    If gApp.GetNumAVDocs = 0 Then
    gApp.CloseAllDocs()
    gApp.Exit()
    End If

    Throw that in there and that seems like it would be the problem.
    Michael_O_Dell@adobeforums.com Guest

  9. #8

    Default Re: Basic VB.net and Javascript help

    Thanks Michael. I'll check it out.
    jswota@adobeforums.com Guest

  10. #9

    Default Re: Basic VB.net and Javascript help

    It seems like it is closing all of the open instances which should be one.

    The one big problem that is minor is the text alignment. I would like it centered and I played wiht the numbers and I can only make it aligned left or right. Did you figure anything out with that?
    Michael_O_Dell@adobeforums.com Guest

  11. #10

    Default Re: Basic VB.net and Javascript help

    When i used the nHorizAlign and nVertAlign in the addWatermarkFromText method i couldn't get the text where i wanted it so i opted to extract the page size and rotation so i could specifically calculate the location ot the text. You don't need to do this if you just want your text centered. I believe if you change the nHorizAlign to 1 and nVertAlign to 0 it will center your text on the page but don't quote me on that. Those are the numbers you want to play with. The possible value i think are 0,1,2.

    The commented line just above the method lists the required parameters. Play around with these numbers to get exactly what you want. I wasn't able to get the nVertAlign to do anything by changing the values. Not sure why.

    I posted something similar to this a couple of weeks ago that goes a little deeper into this matter at:
    <http://www.adobeforums.com/webx/.59b703ca/0>

    Hope this helps.

    P.S. Thanks for the advice earlier. It looks like it will help. Also, if you good code for combining PDF files i would love to see it. I have it going but it's pretty buggy.

    Thanks,
    Joel
    jswota@adobeforums.com Guest

  12. #11

    Default Re: Basic VB.net and Javascript help

    I'm new to Adobe programming. How can include adobe acrobat page in visual basic 6 application.

    Thanks

    Antony

    Get your dream Engineering Job
    <http://antoonlinejobs.blogspot.com/>
    Antony_Thomas@adobeforums.com Guest

  13. #12

    Default Re: Basic VB.net and Javascript help

    In java script how to iterate a loop?

    Thanks

    <http://piping-jobs.blogspot.com>
    Antony_Thomas@adobeforums.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139