Enter the JavaScript Code in JavaScript Action of link Annotation dictionary

Hello

It is for the plugin Dev with Acrobat SDK (XI) in C++

having problem to get Javascript code into my cosdict of javascript action.

(If you're wondering, yes I read the reference PDF and Acrobat SDK - livedocs, samples, and QAnywhere ^^ but I am new to Acrobat Dev and C++)

I can't understand how to correctly create the dictionaries of the action (it was necessary for the subtypes "JavaScript" and "GoToE")

and then re-branded to existing annotations (subtype 'link', old action is "URI").

PDF reference, I would say I need to "S" and "JavaScript" key in my CosDict.

If I just wrote: (myPDDoc is my open PDF Document)

NewAction PDAction is PDActionNew (myPDDoc, ASAtomFromString ("JavaScript"));.

PDLinkAnnotSetAction (annot, newAction);

in Acrobat, can I get a link-JavaScript Annotation - but no code (this is why it is not included).

If I try to build the dictionary I get a broken action or the same result without javascript code.

NewAction PDAction is PDActionNew (myPDDoc, ASAtomFromString ("JavaScript"));.

CosDoc myCosDoc = (myPDDoc) PDDocGetCosDoc;

CosObj cosAction = CosNewDict (myCosDoc, false, 3);

cosAction = PDActionGetCosObj (newAction);

String jsText = "here comes my javascript code.   It comes to std::string

CosDictPut (cosAction, ASAtomFromString ("S"), CosNewName (PDDocGetCosDoc (myPDDoc), false, ASAtomFromString ("JavaScript")));

CosDictPut (cosAction, ASAtomFromString ("JS"), CosNewString (PDDocGetCosDoc (myPDDoc), false, jsText.c_str (), 0));

newAction = PDActionFromCosObj (cosAction);

PDLinkAnnotSetAction (annot, newAction);

What is the correct way for the construction of the cosDicts action?

Are there examples for these dicts. or linkAnnotations generally?

Because the livedocs for textAnnotation example but not enough to linkAnnotation.

OK Please forgive me, got the answer myself.

CosDictPut (cosAction, ASAtomFromString ("JS"), CosNewString (PDDocGetCosDoc (myPDDoc), false, jsText.c_str (), 0));

must be

CosDictPut (cosAction, ASAtomFromString ("JS"), CosNewString (myCosDoc, false, jsText.c_str (), jsText.length ()));

Feel a little stupid, had in mind that this number is optional and can be 0.

Tags: Acrobat

Similar Questions

Maybe you are looking for

  • ITunes can't connect after update to iOS10 - invalid response

    My iPad or IPhone 6 Air can connect to iTunes on my PC Windows 10 after the Apple iOS 10 software update yesterday.  The error message is "iTunes could not connect to the iPhone because of the invalid response was received from unit. Short of wiping

  • Set the status of the project window - minimize maximize

    Hello Does anyone have an idea how to set the status of the project (and also diagrams vi) window using scripts.  I want to be able to ensure that this window is one to a decent size at any time - as otherwise labview tends to block everything behind

  • Driver Iomega for citizen Floppy more works for floppy drive, but not for memory cards.

    Original title: HELP? Driver Iomega for their citizen disk more.  Œuvres for floppy drive, but not for memory cards. CF/Micro drive.  He is listed, but does not work.  Any suggestions?    use of PSE * address email is removed from the privacy * got h

  • Print from ipad to printer usb via a wireless router

    Is it possible to print from the ipad to DeskJet 882c via a wireless router that supports usb (like Linksys EA3500) print? Thank you

  • replace the adapter - wpc54g

    I think I have a bad adapter. I struggled to get the wpc54g to connect. I had finally installed it and it worked very well. But as soon as I turned off the laptop computer, the next time that I started it, the card could not find the network. I got p