-1

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.

Friedl Crafts
  • 47
  • 1
  • 7
  • I used BitMiracle.dll to parse all the formatting and spacing for My task to read PDF's those guys have the best stuff to parse the PDF but sadly it is paid but you might want to go through those in trial P.S. the project is worth every bit of penny they charge @Bobrovsky is the developer of the project – Lucifer Apr 16 '18 at 09:35
  • 1
    Well it is pain in the ass with PDFSharp, but I am bound to it, cause I have to use free software only. – Friedl Crafts Apr 19 '18 at 10:36

1 Answers1

-1

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.

Friedl Crafts
  • 47
  • 1
  • 7