I am writing something that you may call notarial acts application. In this application it is extremely important to preserve the pdf templates provided by government.
I am using PDFSharp to read fields, it is pretty straight forward, however there is one thing, text field formatting. I am stuck with it, because i am unable to find in spec anything about formatting, it seems as if it was deliberately missed.
Whenever there is a field that accepts only dollar sign , or date, or any special value that is limited ( for example from 10 to 30 ) I am unable to read that into app and make it visible anyhow to the user ( the user has his own fields, like autofill in the browser which are automatically filled for him, if there is 100% chance of it beeing correct value , otherwise there is autocomplete ).
var ts = new TypeSwitch().Case((PdfTextField x) =>
{
item1.CharactersLimit = x.MaxLength;
item1.IsMultiline = x.MultiLine;
item1.IsRequired = x.IsRequired();
// what should i do here to read that this field is only 4 places and 2 places after coma, or simply a percentage ?
}
My question is: Is there a way in PDFSharp to read these formatting properties, and if there is not, how you guys have parsed these, if you ever had to.
Okay the only solution I was able to make out of it is this:
var formatting = (((field.Where(item => item.Key == "/AA")
.Select(item => item.Value)
.First() as PdfDictionary).Where(item => item.Key == "/F")
.Select(item => item.Value)
.First() as PdfSharp.Pdf.Advanced.PdfReference).Value as PdfDictionary).Where(item => item.Key == "/JS")
.Select(item => item.Value).First() as PdfString;
After that I was able to extract some of the information about the formatting to make a custom regex to make validation possible, but that was all I could do.
It is PDFSharp, unfortunately.