April 2008 - Posts

I've stumbled upon a free .Net obfuscator--Eazfuscator.NET. So far, it works well for my purposes. Most obfuscators are costly--ranging from $200 to $2000! But this one is freeware and it works better than the free one bundled with Visual Studio 2005.

It is free and easy to use!
Okay, after almost a year and an offshore assignment, I finally had a chance to update this blog.

I was developing a .Net 2.0 C# windows application wherein I basically have to print PDF files from a Windows application. I tried to use the Adobe Acrobat Reader ActiveX object embedded in my form to preview and print PDF documents. It worked fine; I just have to import the COM component and Visual Studio will do most of the Interop work for me. I then have to locate the file and load it to the AxAcroPDF control:

axAcroPDF1.LoadFile(pdfFileName);

I'd then delete the PDF file immediately afterwards to somehow obscure it from the user. The ActiveX object seems to save it in memory such that I can make a call like:

axAcroPDF1.Print();


...and all went smoothly. But when I ran it on another machine with the most recent version of Acrobat (8.1.2), I got an E_NOINTERFACE exception. After much research, I then decided to use a WebBrowser .Net 2.0 control instead. Thus, my codes looked like so:

webBrowser1.Navigate(pdfFileName);


...assuming of course that the user has a PDF reader installed and integrated into his web browser. This is a much easier alternative than to using unmanaged code. However, it does not go away without problems. When I try to call:

webBrowser1.Print();


I get nothing. I can't seem to force the browser to print its PDF contents. To keep the long story short, I had to tinker with the underlying ActiveX object of the WebBrowser control. First, I needed a reference to shdocvw.dll (windows system32 directory). Then, I did something like:

object n = null;
SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)webBrowser1.ActiveXInstance;
wb.ExecWB(OLECMDID.OLECMDID_PRINT
, OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER
, ref n
, ref n);

It worked! (MSDN says that the two pointers are optional so I just put null in there.)