Archive for February, 2008

.net PDFViewer Component

Today I wanted to Integrate a PDFViewer component into my own .net (C++/CLI) application. In the beginning I hoped to find an opensource component for this. There are several opensource library’s for creating PDF’s with .net but none of them provided a PDFViewer component. There are several commercial solutions available but since they usually provided much more than I needed I was not really interested. On Linux or with other GUI toolkits (GTK, QT4 or Java) there are opensource alternatives available for the viewer but not for .net.

After a while I found a description that it is possible to integrate the Adobe Reader via ActiveX. Armin sent me a short C# example how to do it. Sadly I could not find the necessary dll’s. After some search for this dll’s I found the documentation page of Adobe where they provide examples for the usage of the Adobe Reader within a C# application. After compiling this application I found the needed dll’s in the output directories of this project and then I could set up my application just fine.

The only problem with the examples where that they where unnecessary complicated. I reduced the example to a minimum needed and created a small example application. The example including a short description can be found in the enterpriselab wiki:

Some more interesting links I found during my research:

getopt vs. optparse

Last week I was getting the MessageBroker started for the DustBot project. I needed some code for logging, and starting the server. Since I wanted to have a simple way to specify command line parameters for the MessageBroker I thought about writing some getopt code to do this. This was the time I stumbled upon Poco. Poco is a C++ library that helps to build networking application. One such module provides easy networking to C++. In addition it also provides some helper classes to easily set up a deamon application including parsing the command line parameters.

To parse the command line parameters with Poco was much easier then with getopt and was done very quickly. At this point I thought why do I not have something like this in Python? After a quick search I found optparse a Python module that helps to parse the command line parameters in a much easier way then getopt. To check if it works as easy as it looked like I integrated it into the regexplace script I posted earlier (Change of multiple files). The new version is uploaded to the wiki and can be downloaded from here.
If you need to parse command line parameters with python I recommend the optparse module. Since it really works well and is much easier to use then getopt.