Modify Vista and Office 2007 File and Attachment Preview Handlers to Support Foxit PDF Reader

»»»Modify Vista and Office 2007 File and Attachment Preview Handlers to Support Foxit PDF Reader
Windows Vista’s File Explorer and Microsoft Office Outlook 2007 have a feature that allows you to preview an attachment in email message from within the Outlook 2007 itself directly after click on the preview option when you select an attachment, or the content of a file in Vista File Explorer when highlighted. The preview will be shown in preview pane in Windows Vista and Outlook 2007, and thus users need not to open the files in external programs or applications.

Vista Preview Pane
XML file preview in Windows Vista

By default, the built-in native preview feature has only a few supported handlers for limited file types and extensions such as Word documents, PowerPoint presentations, Excel spreadsheets, font files, video and audio files, and a variety of other file types that are commonly sent as attachments. PDF (Portable Document Format) documents which is popular and widely used is left out. However, Microsoft Developer Network (MSDN) provides a sample preview handlers which you can download and install in order to has the ability to preview Adobe PDF documents in Vista and Outlook 2007. However, the developer use Adobe ActiveX control for the Acrobat PDF reader implementation, which will require users to have Adobe Reader or Adobe Acrobat Reader installed.

If you’re using alternative Acrobat PDF reader like Foxit Reader, then you will need to modify the PDF preview handler source code so that Windows Vista and Office Outlook 2007 can support Foxit Reader API properly, as advised by timheuer.

The file to modify is PdfPreviewHandler.cs from the free sample preview handlers add-on downloaded from MSDN mentioned above. Go to about line 41 and change to the following:

// Foxit Reader ActiveX
public PdfAxHost()
    : base("d46a7492-4b6c-446f-8100-4812edf406c9") { }

Next, the pinvoke method has to be changed as Adobe ActiveX control and API uses a LoadFile() signature, but foxit uses an OpenFile() signature. Foxit also uses a second parameter which is the starting page of the document. So locate the LoadFile in the file, and change to OpenFile to looks like the following:

_ocx.GetType().InvokeMember(
  "OpenFile", BindingFlags.InvokeMethod, null, // changed to OpenFile
   _ocx, new object[] { fileName, 0 }, CultureInfo.InvariantCulture); // added 0 parameter to array

Save the file, compile and deploy. And now you will have PDF preview capability in Windows Vista and Office 2007 without the need of Adobe Acrobat Reader. Note that you will need to get Foxit Reader SDK (ActiveX) in order for this modified version of Foxit PDF previewer to work, with charge or license fee applied, not just installing Foxit Reader.

By |2016-12-09T08:40:27+00:00December 9th, 2016|Categories: Utilities|Tags: , , |1 Comment

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.