This project is read-only.

Pdf Orm

Do What?

Basically I got tired of having to write objects or looping statements to handle pdf forms, so I wrote an ORM using iTextSharp. In this project there's two parts, a class to be used in code behind and a console application that can be wired up as an external tool, or just simply ran as a command line.


This is the class/interface generator. In order for this to work, one thing is assumed - good formfield naming convention. Since this uses reflection to wire up your objects back to the form, a formfield key of {form[0].person[0].item[0]} isn't sufficient nor will this app support it (at least not yet). Any special characters !@#$%^&*()-=[]{},./;'\<>?:"| won't work and if you happen to have a regex for this, please drop me a note :-)

Usage is pretty simple, it expects 3 things as follows and I don't feel they need explaination

/class <classname>
/output <WhereDoYouWantIt?>
/source <WhatFormDoYouWantMeToUse?>
/q or /? will display the switch statements it expects


This is the class you will use in your own code to jam your generated objects back into the form. Using reflection, it attempts to tie the data back into the form that is in the objects. I also included a collection of fields not found, as well as a boolean. Usage for this is simple... for this example, assume "TimeOffForm" is the object name.

PdfReader reader = new PdfReader(myLocation);
MemoryStream stream = new MemoryStream();
PdfStamper stamp = new PdfStamper(reader, stream);

PdfInject inject = new PdfInject(TimeOffForm, stamp.AcroFields);


Also, you can use PdfTemplateInject to create a form that's filled out with the key values filled out. This is useful when you are working with a form ... and you have no idea what field is where (or even what it really means)

Last edited Dec 23, 2009 at 3:56 AM by jriley, version 4


No comments yet.