Answered
Hi, I'm new to the PDF DOM, and I'm trying to delete some pages from a module made with LiveCycle Designer. I've tried all JS commands in the reference, but I suppose I've to use the XFA DOM. Can anyone give me an hint on how access it from VB and remove the nodes?
I'm blocked on this piece of code:
Set pddoc = aAVDoc.GetPDDoc
Set jso = pddoc.GetJSObject
Set oXFA = jso.xfa.resolveNode("form.modulo1[0].P1.Header[0]")
But I can't get anything from the retrieved object not even the rawValue property.
Any help would be appreciated. Thanks!
First, I'm not sure the JSO will even work with a LiveCycle PDF.
Second, if you can retrieve the JSO from an XFA PDF, there is a problem with passing DOM objects across the ActiveX interface. You can only pass simple generic objects. You're best strategy here is to create a function in a folder level JavaScript file that performs everything on JS side. Then call this function from the VB script.
Third, an XFA form doesn't have pages like a regular PDF. It has subforms that can be mapped into pages. You may or may not be able to delete a particular subform. Also, your code is trying to operate on the "form" model. This model holds the runtime hierarchy. Deleting subforms from here doesn't delete them from the file. You need to operate on the "template" model, which holds the real XFA structure.
Fourth, how is this file generated? Have you automated LiveCycle Designer in some way? Or do you mean you have one of the Livecycle servers? If either of these is true, then you must have control over the initial generation of the form?
The document should be designed up front to show or not show the pages it needs to. Operating on it after it has already be encapsulated into a PDF is risky and unreliable.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script