Archive for the 'C#' Category

Print a PDF in c#

Adobe does not make it easy to print a PDF from code unless you buy expense libraries. So the easiest way is to have AcroRd32.exe (Reader) print it by starting external process and passing commandline args.  Not the cleanest solution, but it works.  You can also queue multiple documents by changing the Arguments and calling Start() again.  This queues another request that the reader will pickup after printing current document.

public static void PrintPDF(string path, string printerName)
    //Args -

    // This does leave the Acrobat reader open. No easy way to close it after print.
    string args = string.Format("/t \"{0}\" \"{1}\"", path, printerName);

    Process process = new Process();
    process.StartInfo.FileName = @"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
    process.StartInfo.Arguments = args;
    process.StartInfo.UseShellExecute = false;

Print multiple PDF’s:

public static void PrintPDF(string[] paths, string printerName)
    Process process = new Process();
    process.StartInfo.FileName = @"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
    process.StartInfo.UseShellExecute = false;
    foreach (string file in paths)
        string args = string.Format("/t \"{0}\" \"{1}\"", file, printerName);
        process.StartInfo.Arguments = args;

DigitalPersona vs Griaule fingerprint SDK

Have switched my TimeExpress biometrics app to using DigitalPersona and am pretty happy so far.  I originally developed my app with the Microsoft Reader and the Griaule SDK.  However, after looking at deployment issue, I found this was not going to work well for me or my customers.  I then purchased a digitalPersona U.are.U 4500 reader and downloaded their free SDK to test it out.  In about a day, I fixed my app to work with new sdk. Both products worked for me and both have pros and cons in the sdks.  Both products seem to have “over-built” these SDKs and seem to think the focus of your app is there SDK, which is not the case.

Griaule Pros:
1) Works with many readers (including MS Reader)
2) Faster on verify

Griaule Cons:
1) Complex deploy. requires many files.
2) Poor or incomplete documentation.
3) Licensing. Requires each client have a txt license tied to machine id. This complicates deployment and support greatly.
4) API tied to windows UI controls.  This is unneeded and awkward for many .Net projects and does not allow console or server side verify.
5) Does not support other hardware so does not work with Microsoft reader (which is strange because the MS internals use DP hardware)
6) Grtools tray app installed and wants to take over your machine.  It also randomly takes 100% cpu. This is most annoying thing and I was prompted to look elsewhere for this reason.

Digital Persona Pros:
1) Better SDK and documentation.
2) Has good .Net support.
3) Libraries support UI and non-UI apis.
4) Does not require any client license (just the hardware).
5) OneTouch for Windows SDK is free.
6) Hardware good.  The finger reader just feels good and built well. It has “weight” and stays on the desk better then MS reader (which would need to be taped down in a production environment).
7) Windows Vista recognized and installed the driver on plug-in without the CD. Was not expecting that. In my mind, this is a big deployment winner without needing another setup step for customer.
8) Can serialize the fingerprint sample and send it over the wire for server verify.

Digital Persona Cons:
1) .Net Samples seem strange. Almost like they are ported from java or something. .Net naming standards not followed.  The event model seems strange also.
2) Could be abstracted more and remove a lot of un-needed code and namespaces.  I mean 90% of time, you want a finger press event and a Verify function and that is it.  Too much “stuff” in the way.  That said, the .Net support seems cleaner then Griaule’s.
3) Supports only DP hardware.
4) Performance is acceptable, but feels a tad slower then Griaule sdk and MS Reader.
5) The have another sdk they charge 600 bucks for. I don’t get this idea of charging for an sdk when you have to buy there hardware anyway. Seems like a money grab that only will put off new developers.  This may even push people over to Griaule and MS reader.
6) .Net libraries included, but requires 4 references to different dlls to get enroll and verify working.  Again, they need to get over themselfs and rollout a single DLL with 2-4 public methods and call it a day. Maybe also put up a ClickOnce site for point and click deploy of sdk and driver updates. 

In the end, I give DP 4 stars and Griaule sdk 3 stars.

Digital Persona reader and OneTouch SDK.