c# - iTextSharp - XFA fill date/time field -
the workflow this:
- we download template form, prefill values static, export xml template
- the xml parsed .net forms app, dynamic values added
- the resulting xml needs imported pdf template
all goes using mergexfadata method on itextsharp, reason, date/time fields not being filled in (textfields , checkboxes work ok). cannot figure out why. searching through forums discovered saying xfa works textfields. why , how work around?
also next step need attach attachment pdf form. attachments pdf itextsharp not attach them. have searched many forums none of mentioned methods works me.
thank answers
@yuri, tried date/time field , worked perfectly. create simple pdf in live cycle 2 fields, 1 text , 1 date/time, , 2 buttons, submit , print. sample pdf here:
i filled out form , got xml:
<?xml version="1.0" encoding="utf-8"?> <topmostsubform> <text1>chris</text1> <datetimefield1>2012-04-12</datetimefield1> </topmostsubform> when imported pdf , viewed pdf in acrobat date/time field filled out. i'm using itextsharp 5.0.5.0 following code:
option explicit on option strict on imports itextsharp.text imports itextsharp.text.pdf imports system.io public class form1 private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load dim pdf_input_file string = path.combine(my.computer.filesystem.specialdirectories.desktop, "input.pdf") dim pdf_output_file string = path.combine(my.computer.filesystem.specialdirectories.desktop, "export.pdf") ''//create our reader dim reader new pdfreader(pdf_input_file) ''//create our file stream output using fs new system.io.filestream(pdf_output_file, filemode.create, fileaccess.write, fileshare.read) ''//create stamper dim stamper new pdfstamper(reader, fs) ''//just loading xml raw instead of reading disk, less files attach post dim bytes = system.text.encoding.utf8.getbytes("<?xml version=""1.0"" encoding=""utf-8""?><topmostsubform><text1>chris</text1><datetimefield1>2012-04-12</datetimefield1></topmostsubform>") using ms new memorystream(bytes) ''//fill out form stamper.acrofields.xfa.fillxfaform(ms) end using stamper.close() end using reader.close() me.close() end sub end class
Comments
Post a Comment