简体   繁体   中英

Dynamic XFA PDF Forms

I have a number of Dynamic XFA PDFs that were created with Livecycle Designer. These PDFs are used as templates for various individuals to complete. 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.

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.

We are doing this now with Acroforms but need to do the same for Dynamic XFA forms as well. 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. 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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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