Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Identify if the form is of type Static PDF Form or Dynamic XML Form programmatically

Avatar

Level 1

Hi,

We have an Adobe Plugin in which Adobe form is used. With Adobe LiveCycle Designer, Staic PDF Form and Dynamic XML Form can be created. We want to distinguish between these two types. Is there any Adobe API available which will return the type of the PDF Form; Static PDF or Dynamic XML Form?

Thanks - Apeksha

1 Accepted Solution

Avatar

Correct answer by
Level 5

Your script failed for me but when I used the following modified version it detected the form type correctly ( as long as the pdf is saved from designer using either save as static or save as dynamic )

Dim app, pddoc

Dim js

Set app = CreateObject("AcroExch.App")

Set pddoc = CreateObject("AcroExch.PDDoc")

If pddoc.Open("E:\Untitled1.pdf") Then

     Set js = pddoc.GetJSObject

     If Not js Is Nothing Then

          If js.dynamicXFAForm Then

              MsgBox "It's a dynamic form!"

          Else

              MsgBox "It's a static form!"

          End If

       End If

End If

Set app = Nothing

Set pddoc = Nothing

As for the 2nd approah, I dont have a sample that can be shared but essentially, its a matter of using the COS API calls to open the XFA stream within the PDF and determining what the rendering type is.

You can also execute javascript using the API / C code

View solution in original post

4 Replies

Avatar

Level 5

Is the form already open, which your plugin is trying to examine or is it before loading the pdf into acrobat? If its already open then it is proably easiest to execute script to examine the "dynamicXFAForm", "xfa" and "XFAForeground" properties on the Doc object. If not through script, you will have to examine the XFA cos object itself to determine what the render property should be.

Avatar

Level 1

Yes, the form is already open. Earlier, I had tried a VB Script to check if the PDF file is Static PDF Or Dynamic XML as per the value of 'dynamicXFAForm' but it returned 'true' for both type of PDFs created by Adobe X LiveCycle Designer. :|

Please correct me if I am doing anything wrong.

<code snip>

app = CreateObject("AcroExch.App")

pddoc = CreateObject("AcroExch.PDDoc")

If pddoc.Open("c:\Usage Example Form.pdf") Then
     js = pddoc.GetJSObject

     If Not js Is Nothing Then
          If js.dynamicXFAForm Then
              MsgBox "It's a dynamic form!"
          Else
              MsgBox "It's a static form!"
          End If
       End If
End If

</code snip>

Our plug-in is written in C++ and we use Adobe APIs to work with Adobe Forms. Could you please guide me how to do it using XFA cos object?

Thanks - Apeksha

Avatar

Correct answer by
Level 5

Your script failed for me but when I used the following modified version it detected the form type correctly ( as long as the pdf is saved from designer using either save as static or save as dynamic )

Dim app, pddoc

Dim js

Set app = CreateObject("AcroExch.App")

Set pddoc = CreateObject("AcroExch.PDDoc")

If pddoc.Open("E:\Untitled1.pdf") Then

     Set js = pddoc.GetJSObject

     If Not js Is Nothing Then

          If js.dynamicXFAForm Then

              MsgBox "It's a dynamic form!"

          Else

              MsgBox "It's a static form!"

          End If

       End If

End If

Set app = Nothing

Set pddoc = Nothing

As for the 2nd approah, I dont have a sample that can be shared but essentially, its a matter of using the COS API calls to open the XFA stream within the PDF and determining what the rendering type is.

You can also execute javascript using the API / C code

Avatar

Level 1

Hi dohanlon,

The script worked perfectly well.

Thanks a lot for your help!!!

Best regards,

Apeksha