Q:
Thanks for the quick response. I tried this change but console echo'd
the following:
Exception:
Message: GetDecodedStream() can't be invoked on Obj of this
type.
Function : PDFTRON::SDF::Obj::IllegalFunctionException
---
A: The problem is that JavaScript field may be also a PDF string.
You may want to try the following snippet instead.
Field f = ...
// Get additional-actions dictionary defining the field's behavior
// in response to various trigger events
Obj aa = f.GetSDFObj().FindObj("AA");
if (aa != null) {
// Get JavaScript action to be performed before the field is
// formatted to display its current value. This action can
// modify the field's value before formatting.
Obj fmt = aa.FindObj("F");
if (fmt != null) {
// extract embedded JavaScript...
Obj js = fmt.FindObj("JS");
if (js != null) {
if (js.IsString()) {
string java_script = js.GetAsPDFText();
}
else {
// Obj stm = js.GetDecodedStream();
// FilterReader reader = new FilterReader(stm);
// reader.Read(...extract JS ....);
}
}
}