简体   繁体   English

动态XFA PDF表单

[英]Dynamic XFA PDF Forms

I have a number of Dynamic XFA PDFs that were created with Livecycle Designer. 我有许多使用Livecycle Designer创建的动态XFA PDF。 These PDFs are used as templates for various individuals to complete. 这些PDF用作各种个人完成的模板。 When a user requests a template we have to write a submit button with url pointing back to a .net application for processing and update some of the fields with information from the database into the PDF. 当用户请求模板时,我们必须编写一个提交按钮,其url指向.net应用程序进行处理,并使用数据库中的信息将某些字段更新为PDF。

Can I use iText(Sharp) with .net to update the dynamic xfa pdf to write into it a submit button and update fields and then use iText(Sharp) to process the returning form. 我可以将iText(Sharp)与.net一起使用来更新动态xfa pdf,以将其写入提交按钮并更新字段,然后使用iText(Sharp)处理返回的表单。

We are doing this now with Acroforms but need to do the same for Dynamic XFA forms as well. 我们现在正在使用Acroforms进行此操作,但也需要对Dynamic XFA表单执行相同的操作。 I can't find any confirmation information that this is possible. 我找不到任何可能的确认信息。 If it is possible does anyone have any code that they can share to show me how to do this? 如果有可能有人可以共享任何代码来向我展示如何执行此操作?

You can also achieve that putting the pdf's content inside an XmlDocument and working as you were working with an XML. 您还可以实现将pdf的内容放入XmlDocument并像使用XML一样工作。 This is the code I use to replace some placeholders written in textboxes. 这是我用来替换文本框中编写的某些占位符的代码。

PdfReader pdfReader = new PdfReader(path_pdf);
using (PdfStamper pdfStamp = new PdfStamper(pdfReader, new FileStream(temp_path, FileMode.Create), '\0', true))
{
    pdfStamp.ViewerPreferences = PdfWriter.AllowModifyContents;
    XmlDocument xmlDocument = pdfReader.AcroFields.Xfa.DomDocument;
    string pdfContent = xmlDocument.InnerXml;
    string newpdfContent = pdfContent
        .Replace("$CONTENT_TO_REPLACE_1$", "some_content")
        .Replace("$CONTENT_TO_REPLACE_2$", "some_other_content")

    xmlDocument.InnerXml = newpdfContent;
    Stream stream = GenerateStreamFromString(newpdfContent);
    pdfStamp.AcroFields.Xfa.FillXfaForm(stream);
    pdfStamp.AcroFields.Xfa.DomDocument = xmlDocument;
    pdfStamp.Close();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM