// Fill out PDF PdfReader.unethicalreading = true; var inputFile = new PdfReader("Templates/bv_form.pdf"); var outputStream = new FileStream("Exports/export.pdf", FileMode.Create, FileAccess.Write); var pdfStamper = new PdfStamper(inputFile, outputStream); // Display form field names found in document foreach (var field in pdfStamper.AcroFields.Fields) { var line = string.Format("[{0}]", field.Key); Console.WriteLine(line); } pdfStamper.AcroFields.SetField("1.1", "This value is set by C#"); pdfStamper.AcroFields.SetField("1.12", "12-12-2012"); pdfStamper.AcroFields.SetField("3.8", "This value is set by C#"); pdfStamper.AcroFields.SetField("2.11", "This value is set by C#"); // close writers and clean up inputFile.Close(); pdfStamper.Close(); outputStream.Close();If an 'owner password' is set on the PDF, you need to set the 'unethicalreading' property to true. There are tools to remove the password from the file, but most also remove the form-fields. Setting checkboxes is a bit tricky - you need to use SetField() and provide the value of the checked box. This is typically "On" or "Off", but in the forms we were using, they used custom values. I found these values by checking the forms, saving the forms and then finding the field values in code. Anyways - good stuff, easy to use, check it out!
Thursday, January 24, 2013
Filling out PDF forms with iTextSharp
We're looking into ways to help SME's fill out our Dutch Chamber of Commerce forms. These are typically PDF forms and we want to help them out with filling out the form with as much info as possible, to save them the trouble.
iTextSharp makes this a breeze ( NuGet site ):
Saturday, January 19, 2013
JavaScript unit testing using QUnit
In one of the recent hanselminutes, Scott talks to one of the creators of SignalR, a real-time web library ( this episode ). Two things I found really interesting in this talk:
There's no need to talk about this much longer. It works out-of-the box, no prerequisites and very helpful. We'll be using it!
Microsoft allowed the creators to work on their 'garage project' using company resources
SignalR started out as a garage project from two guys at Microsoft, working on it in their own timem. However, after talking to their employer, the project was adopted by Microsoft and now they have a team of 6 or so, helping them on the project. Basically, now their working on their pet project in the boss's time.SignalR is using Git, TeamCity, BrowserStack, TestSwarm and QUnit
During the podcast, their Continuouse Integration (CI) setup is mentioned. So apparently they use
- Git for source control
- TeamCity for automated building and deployments - find it here: http://ci.signalr.net/
- Testswarm for coordinating the JavaScript tests
- QUnit for writing JavaScript unit tests
- Browserstack for running the tests on all the different browser versions
Pretty cool setup there. Apparently their TeamCity server creates jobs for the Testswarm installation, to run the tests.
But, what I wanted to look into was QUnit for now, so I wrote a few lines to see how this thing works.
QUnit - A JavaScript unit testing framework
Honestly, I haven't tested much of my JavaScript code thusfar. However, There's no reason not to anymore, because QUnit makes it extremely simple.
You don't need to download anything, just get both style and JavaScript files from a CDN. A 'hello world' is quickly written like so:
Which will result in the following tests results:QUnit Example
There's no need to talk about this much longer. It works out-of-the box, no prerequisites and very helpful. We'll be using it!
Wednesday, January 16, 2013
Great tool: YUMI – Multiboot USB Creator (Windows)
I'm experimenting with VMWare ESXI and I needed to create a bootable USB stick for in order to get this onto one of our servers. My colleague pointed out this application: YUMI. Not only allows it to quickly create a bootable USB stick, but it also allows you to quickly download and place Linux distributions onto the USB stick.
On boot - a menu shows that allows you to select the ISO that will be used to boot. Sweet, quick and easy.
Monday, January 14, 2013
Scott Hanselmann and Rob Conery on Mid-life crisis
The latest 'hanselminutes' podcast by Scott Hanselman and Rob Conery talks about .... ehm ... well ... life. No techy stuff this time and I love it. I can sum up what it's about, but I recommend you just check it out:
http://www.hanselminutes.com/353/coneryminutes-2-the-mid-life-crisis
http://www.hanselminutes.com/353/coneryminutes-2-the-mid-life-crisis
Subscribe to:
Posts (Atom)