1

When I try to open a regular PDF (which doesn't contain an XFA form) using Adobe LiveCycle ES4 Designer it prompts a window (New Form Assistant) and asks me to select how I want to work with the PDF. The options are:

  • Create an Interactive Form with Fixed Pages
  • Create an Interactive Form with a Flowable Layout

I choose the first one and continue. Then, without doing anything I save the file (using save as). Save as type is 'Acrobat (Static) PDF Form (.pdf)*', and as a matter of fact that's the only option for this scenario. After I save the file, I figured out that, although both files are visually same in the PDF reader, the saved and the original files are different, such that, saved file contains XFA form. In my case XFA form is as follows:

<topmostSubform xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup"/>

I have two questions about this.

  1. Can I open a regular PDF and add an XFA form to it without corrupting the original PDF content, using the API?
  2. If the first one is possible, can I add invisible fields to that PDF, again using the API?

In short, what I want to do is adding a filled XFA form to a regular PDF and I'm asking if it is possible, using the API?

guneykayim
  • 5,210
  • 2
  • 29
  • 61

2 Answers2

1

When you select “Create an Interactive Form with Fixed Pages”, what is happening conceptually is that you are creating an XFA “overlay” on the existing PDF. You can add fields but not boilerplate.

The intended use case, is that you have an existing paper form that you have in PDF format and that you want to quickly add fields to it in order to make it interactive. You are essentially augmenting the existing PDF with some additional XFA functionality. Since the artwork remains in PDF, no conversion has occurred on it and it remains identical to the original unaltered document. You are, however, not creating a true XFA form because only the fields are defined in the XFA format so you cannot store it as an XDP. It can only be re-saved as a PDF. Also, since the PDF artwork is not broken down into moveable pieces (i.e. subforms), the form cannot grow/shrink dynamically. This is why it can only be saved as a static PDF. See the Adobe LiveCycle Designer help here and here.

When you select “Create an Interactive Form with a Flowable Layout”, Designer is converting the PDF into the XFA XML format. You can interact with the design just as if you had created everything from scratch using LiveCycle Designer.

Since this approach actually converts the PDF artwork into XML, there is a higher likelihood that some of the artwork may not convert exactly the same. It may require some manual fixups to get the form looking exactly as it did before. Some complex PDFs may not convert well at all. Fonts may not be available, etc. Again, this is covered under the Adobe LiveCycle Designer help here.

The benefit of this latter approach is that you have a full XFA form definition that can be used anywhere that a form that was developed from the ground up in LiveCycle Designer can be used. It can be modified to add dynamic sections that grow or shrink to match the data. The entire expressive power of an XFA-based form is opened up.

WRT your questions:

  1. You can open a regular PDF and add XFA fields to the form. You can then use those fields to capture data and save that data out as XML data.

  2. You can add invisible XFA fields as well.

Rob McDougall
  • 328
  • 1
  • 10
  • You got my question wrong. I'm aware that I can do those thing using the **Designer** and I know whats happening in the backend, what I'm asking is, if it is possible to do those things using the provided **API**. I want to do these thing programatically. – guneykayim Dec 18 '14 at 18:01
  • Again, I think the phrasing of your question makes an answer difficult. When you say "the provided API", which API are you talking about? There are a variety of APIs provided with LiveCycle server and a lot depends on what modules you've purchased. Also, I'm still not really understanding what you're looking to achieve. When you say "add an XFA form to the PDF content" are you talking about adding an XFA form that only contains fields as an overlay or will their be boilerplate as well? Maybe if you outlined your use case in a little more detail I can provide an alternative approach. – Rob McDougall Dec 18 '14 at 23:29
  • well, actually I don't know which API it is. I just need an API which will let me add XFA form to PDF. I want XFA form as an overlay. I'll be glad if you can help. – guneykayim Dec 18 '14 at 23:36
  • OK, I've gone back and reviewed some of your other questions that I hadn't previously seen. I think I understand what you are trying to do now. – Rob McDougall Dec 18 '14 at 23:36
1

There is no API in Adobe LiveCycle that lets you insert an XFAF (XFA Foreground) form into a PDF.

It should be doable using various PDF libraries however. You need to create the form you want to add and then insert it into the PDF using a PDF library like iText, PDFBox or Big Faceless. Inserting is a little tricky however as the XDP is broken into sections in the PDF. I would generate a XFAF PDF using LiveCycle Designer and then examine it using the same PDF library that you intend to reproduce the process with.

The presence attribute isn't specifically excluded from the XFAF profile, so invisible fields should work, however I would test it with LiveCycle Designer first. If you add invisible fields into a Fixed Page PDF and it works (i.e. you test the resulting PDF - I have no doubt that it will let you add them but it's possible that it doesn't make them invisible) then you should be able to emulate that using a programatically constructed XFAF PDF.

Just a word of caution. This is not something that I think many people outside of the LiveCycle Designer team have tried. If you head down this route you will be blazing the trail.

Rob McDougall
  • 328
  • 1
  • 10
  • This was quite enlightening. Developer of iText told that, this can't be done using it, I will try others you mentioned. Just to clarify, creating an XFA overlay on a regular PDF is the same with inserting XFAF form into PDF. Just different terms, but have the same meaning, right? – guneykayim Dec 19 '14 at 00:04
  • Yes, I believe so. I'll be honest, I haven't looked closely at a PDF with an XFA overlay however I don't see any reason why it wouldn't be the same as a static PDF generated from an XDP. The only difference should be the way the PDF portion is generated. In the static PDF case, the PDF layer is generated from the XDP and then the XDP is inserted into the XFA section. In the XFAF case, it should be just inserting the XFAF XDP into the XFA section of a previously generated PDF. That should be doable with iText or any other PDF library. – Rob McDougall Dec 19 '14 at 16:55
  • Just FYI - If you're comfortable with PDF internals (i.e. you've at least read/skimmed the PDF spec), then there are tools for looking at the PDF contents. I typically use either Acrobat (Tools/Print Production/Preflight Options/Browse Internal PDF Structure) or the [PDFBox debugger](https://pdfbox.apache.org/commandline/#pdfDebugger). – Rob McDougall Dec 19 '14 at 17:02
  • I have thought about it a little more and you may also need to add the acrobat field annotations with names that match SOM expressions into the XFA layer. A static XFA PDF has AcroForms fields in it but they are logicless. The name of the field ties it back to the XFA and the XFA code keeps the two in sync. In the end, this is really a reverse engineering exercise. You'll need an example XFAF PDF that was generated out of Designer as your guide. – Rob McDougall Dec 19 '14 at 17:05