Show PDF-Documents in a C# WPF Application

The easiest way to do this is to display the Adobe Reader Browser Plugin. This can be done with a UserControl which can be hosted in a WindowsFormsHost control in a WPF Form. You require a reference to the dlls AxInterop.AcroPDFLib.dll and Interop.AcroPDFLib.dll which you can find in the Reader SDK on the Adobe Developer Homepage. The code for a UserControl is shown below:

PDFControl.Designer.cs:

 

PDFControl.cs

In the WPF Form you can host it like:

And initialize it like:

To show a document:

C# Automating Exel – Document not saved error

If you try to automate Microsoft Excel in the background with a C# Application (Microsoft.Office.Interop.Excel) after processing some documents sometimes an error "Document not saved" pops up. If you do not wish to save the document you can supress the message like this:

 

C# Convert Excel, Word- and PowerPoint-Documents to XPS

You can easily automate the office apps to convert office documents to the XPS-Format. With Microsoft Word you can as well convert RTF, HTML and TXT Documents to the XPS Format.

You need to reference the following Assemblies:

– Microsoft.Office.Interop.Excel

– Microsoft.Office.Interop.PowerPoint

– Microsoft.Office.Interop.Word

– Office