XML到可填写的PDF表单? [英] XML To Fillable PDF Form?

查看:114
本文介绍了XML到可填写的PDF表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过xml文档创建可填写的PDF表单吗?

I would like to create a fillable PDF form via an xml document?

我们目前有一个数据库,其中包含用于清单的行项目,然后将其输出为xml格式.我们可以产生一些不错的HTML 5清单,但是现在我们正在向PDF表单迈进.

We currently have a database with line items for a checklist which we then output in to an xml format. We can produce some nice HTML 5 checklists but we are now moving towards PDF Forms.

我已经进行了一些搜索,但是实际上并没有确定的从XML创建PDF的信息.我们希望能够定义必填字段,下拉菜单,文本框等.

I have done some searches already but there is nothing really definitive out there to create PDF's from XML. We want to be able to define which fields are required, dropdowns, textboxes, etc.

如何在给定XML文档的情况下创建PDF可填写表格?

How can I create a PDF fillable form given an XML document?

推荐答案

附录(请参阅注释)::我是iText软件集团的首席执行官,该公司是iText(开放源代码)的原始开发者PDF库),以及曼宁出版的两本"iText in Action"书的作者.我是NBN(比利时标准局,包括ISO-32000和相关的PDF标准)的成员.我不隶属于Adobe,Open Office等...

Addendum (see comment): I'm the CEO of the iText Software Group, the original developer of iText (an open source PDF library), and the author of two 'iText in Action' books published by Manning. I'm a member of the NBN, which is the Belgian Office for Standards (including ISO-32000 and related PDF standards). I'm not affiliated with Adobe, Open Office, etc...

PDF中有两种样式"表单:基于AcroForm的表单和XFA表单.

There are two "flavors" of forms in PDF: AcroForm-based and XFA forms.

在基于AcroForm的表单中,表单是使用PDF语法描述的,并且每个字段都有固定的坐标.可以将其视为数字纸.如果您有代表发票的表格,则该表格可以提供20条发票行.假设您需要的行数更少,那么您将拥有许多未使用的字段,这些字段将保持可见状态.假设您需要更多行,那么您将无法将它们全部放入表单中.我已经在我的书的第6章中描述了如何使用Open Office创建这样的表单(a请参阅第6.3.5节).与XML的唯一链接是,您可以以XFDF格式导入/导出这种格式,该格式是ISO-32000-1中引用的规范.这是表单数据格式(FDF)的XML版本.如果您想以XML形式将人们的响应存储在服务器上,那么这可能是理想的选择.您可以在此处进行测试.填写表格,然后选择XFDF按钮.接收到您的请求的servlet将返回Adobe Reader发送到服务器的流.

In AcroForm-based forms, the form is described using PDF syntax, and every field has fixed coordinates. Think of it as digital paper. If you have a form representing an invoice, then such a form could provide 20 invoice lines. Suppose that you need less lines, you'll have a number of unused fields that will remain visible. Suppose that you need more lines, you won't be able to fit them all into the form. I have described how to create such a form using Open Office in chapter 6 of my book (see section 6.3.5). The only link with XML is that you can import/export such a form in the XFDF format, which is a spec that is referred to in ISO-32000-1. It's the XML version of the Forms Data Format (FDF). This could be ideal if you want to store people's responses on a server in the form of XML. You can test this here. Fill out the form and choose the XFDF button. The servlet that receives your request will return the stream that was sent to the server by Adobe Reader.

看看XML Forms Architecture(XFA)也可能很有趣.在这种情况下,PDF充当XML流的容器.嵌入式XML由不同部分组成,其中最重要的是模板和数据集.在模板中,使用特定的语法定义表单的外观(必须由Adobe Reader呈现的形式).数据集部分由类似于XSD的dataDescription和数据组成. XFA的主要优点之一是,数据由使用所需XML的XML组成. XFA表单通常使用Adobe LiveCycle Designer创建,您可以在其中导入自己的XSD作为数据源,然后开始设计表单.结果将是一个空模板.填写表单就像将XML注入数据标签一样容易.

It might also be interesting to take a look at the XML Forms Architecture (XFA). In this case, the PDF acts as a container for an XML stream. The embedded XML consists of different parts of which the template and the datasets are the most important. In the template, specific syntax is used to define what the form should look like (how it has to be rendered by Adobe Reader). The datasets part consists of the dataDescription, which resembles XSD, and the data. One of the major benefits of XFA, is that the data consists of XML that uses whichever schema you want. XFA forms are typically created using Adobe LiveCycle Designer in which you import your own XSD as a data source, and then you can start designing your form. The result will be an empty template. Filling the form is as easy as injecting your XML into the data tag.

哪种类型的表格最适合您?

Which type of form is best for you?

AcroForms始终是静态的.如果您的表格需要与纸上现有表格完全匹配,则这是您的最佳选择.如果您需要可以动态增长的表单(非常类似于HTML),尽管有一些变通办法看起来很完美,但是您很快就会对AcroForms感到沮丧.

AcroForms are always static. If your form needs to be an exact match of an existing form on paper, this is your best match. If you need forms that can grow dynamically (much like HTML), you'll soon get frustrated with AcroForms, although there are workarounds that seem to work perfectly.

XML表单可以非常动态.例如,参见电影格式.它只有一页.现在,我们插入一个包含120部电影的 XML文件.结果是具有23页的表单.如您所见,一部电影的字段重复了120次.如有必要,也可以重复导演和制作电影的国家/地区.一个主要的缺点是只能在Adobe Reader中呈现这种形式的表格.它们不会出现在Apple的Preview和许多其他非Adobe PDF查看器中.

XML Forms can be very dynamic. See for instance a form for movies. It consists of only one page. Now let's inject an XML file with 120 movies. The result is a form with 23 pages. As you can see, the fields for one movie are repeated 120 times. The field with the director and the country where the movie is produced can also be repeated if necessary. One major downside is that forms like this can only be rendered in Adobe Reader; they don't show up in Apple's Preview and many other non-Adobe PDF viewers.

我不确定此答案是否对您有帮助.如果不是这样,请澄清一下,因为您似乎专注于复选框之类的细节.

I'm not sure if this answer helps you out. If not, please clarify as you seem to focus on details such as checkboxes.

附录:

啊哈,第二遍阅读您的问题,现在我发现我误解了这个问题.填写表单后,您不想创建XML输出.您想基于XML输入创建表单(问题中有关输入/输出的观点令人困惑).

Aha, reading your question a second time, I now see that I misunderstood the question. You don't want to create XML output after filling out a form. You want to create a form based on XML input (the point of view regarding input/output in your question is confusing).

因此:您没有使用Open Office,Adobe Acrobat或Adobe LiveCycle Designer创建表单.您想要将自己的自定义XML转换为交互式PDF.除了Adobe LiveCycle ES,我不知道有任何软件可以让您基于XML创建XFA表单.如果可以接受AcroForms,则需要为自定义XML编写解析器,并使用PDF库创建表单.这样的PDF库可以是iText(可能与XML Worker的自定义实现结合使用),但是请注意,这将需要一些额外的编程.

So: you're not using Open Office, Adobe Acrobat or Adobe LiveCycle Designer to create the form. You want to convert your own custom XML into an interactive PDF. I don't know of any software that allows you to create an XFA form based on an XML except maybe the Adobe LiveCycle ES. If AcroForms are acceptable, then you need to write a parser for your custom XML and use a PDF library to create the form. Such a PDF library could be iText (maybe in combination with a custom implementation of XML Worker), but note that this will demand some extra programming.

没有自动将自定义XML转换为交互式PDF格式的开箱即用"解决方案.

There is no "out-of-the-box" solution to automatically convert custom XML into an interactive PDF form.

这篇关于XML到可填写的PDF表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆