I would like to be able to use the FdfWriter class to send a Status message
back to the AcroForm that is displayed as an Adobe Javascript alert. This
allows me to perform server-side validation of some form inputs and return a
message to the user if something needs attention. This is similar to the
FdfDoc.FDFSetStatus(string message) method in Adobe's FDF Toolkit.
In order to support this functionality, I had to modify the FdfWriter class to
include this private variable and property:
private string statusMessage;
public string StatusMessage
{
get { return this.statusMessage; }
set { this.statusMessage = value; }
}
In the internal Wrt class, which is in the same class file as FdfWriter, I
added the starred code inside the WriteTo() method:
internal void WriteTo()
{
PdfDictionary dic = new PdfDictionary();
PdfArray fieldArray = Calculate(fdf.fields);
dic.Put(PdfName.FIELDS, fieldArray);
if (fdf.file != null)
dic.Put(PdfName.F, new PdfString(fdf.file,
PdfObject.TEXT_UNICODE));
* if (!string.IsNullOrEmpty(fdf.statusMessage))
* dic.Put(PdfName.STATUS, new PdfString(fdf.statusMessage));
PdfDictionary fd = new PdfDictionary();
fd.Put(PdfName.FDF, dic);
PdfIndirectReference refi = AddToBody(fd).IndirectReference;
byte[] b = GetISOBytes("trailer\n");
os.Write(b, 0, b.Length);
PdfDictionary trailer = new PdfDictionary();
trailer.Put(PdfName.ROOT, refi);
trailer.ToPdf(null, os);
b = GetISOBytes("\n%%EOF\n");
os.Write(b, 0, b.Length);
os.Close();
}
You may also notice that I've included a new PdfName called STATUS. I added
this line of code to the PdfName class:
public static readonly PdfName STATUS = new PdfName("Status");
Can this simple code change be considered for contribution to the iText code
base? Please let me know if you see any portability issues between C# and
Java, since I'm a Microsoftie.
Thank you,
Chet Potvin
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php