The following guide describes how to configure ABCpdf .NET to read Microsoft Office documents using the MSOffice read module. Once read they can be saved as PDF or any of the other formats supported by ABCpdf. The MSOffice read module was introduced in ABCpdf version 8. To convert Office documents using the XpsAny module, used with older versions of ABCpdf, please refer to this page...
It can be difficult to configure MS Office and ABCpdf to convert Office documents as part of a Windows service. This is for the following reasons.
- Windows services do not, by default, have the permissions required to launch MS Office tasks.
- The Windows service and any MS Office task need to run as the same user so that they can communicate correctly.
- Microsoft Office is primarily designed to run as an interactive application.
- Services run in Session 0 on later versions of Windows and the fact that Session 0 prohibits user interaction makes it difficult to troubleshoot configuration issues.
Further, please be aware that there are risks running MS office server side, so please read "Considerations for Server-side Automation of Office".
Please ensure that your use of MS Office is in compliance with the MS Office license agreement.
Please ensure your server software is up-to-date and a recent version of the .NET Framework installed. We normally test with .NET 4.0. Make sure your ABCpdf Version is up-to-date - Version 9124 or later.
Make sure you are using a recent version of Microsoft Office. We test ABCpdf.NET with Microsoft Office 2010, 2013 and Office 365. Office 2010 is our preferred version. Versions prior to Office 2007 may work but are unsupported.
If you are using Office 2007 without service pack 1 you'll need to install an export add-on from Microsoft, available here: 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS
Make sure your MS Office installation is fully complete and activated. Attempting to automate MS Office with a partial installation may cause the MS Office setup executable to launch and block the automation. Open some documents manually to check that Office is working correctly. Make sure that you can open documents smoothly without any dialog boxes popping up.
You may wish to disable any Microsoft Office start up utilities to ensure that Office processes are shut down after use rather than kept alive in the background. This may be important if you are going to be changing the user at a later stage.
You may wish to disable any Microsoft Office auto-save and auto-recovery features to improve speed and resilience.
Microsoft's XPS Document Writer is required for Excel to PDF conversions. We recommend setting this up as the default local printer.
For ASP.NET applications, you'll need to tell IIS to load the user profile for its application pool.
Open the Advanced Settings dialog for the application pool in IIS Manager and set Load User Profile to true.
Build and run the doc2pdf project. If it fails then this would imply a generic configuration issue - please re-check your installation of Microsoft Office, let us know if you cannot see a cause. If it succeeds (as invariably it will) it will imply a permissions issue under ASP.NET.
Using the MSOffice Read Module
You need to specify the MSOffice read module in XReadOptions since it is not used by default. You can enable it like this:
using(XReadOptions ro = new XReadOptions())
using(Doc doc = new Doc())
ro.ReadModule = ReadModuleType.MSOffice;
As a first step, check whether MSOffice conversion works for an interactively logged on user. You can test this easily in a Windows application. While logged in interactively, you can use the
MSOfficeShowsetting to detect any problems during Office automation. (Please see "Registry Keys" from the documentation for more information).
Give the user account access permissions to the following folders, as indicated on the right.
For 64-bit systems: C:\Windows\Temp
(Create it if it doesn't exist)
For 32-bit systems: C:\Windows\Temp
(Create it if it doesn't exist)
Some clients have reported that they need to set the default printer to XPS Document Writer.
Some clients have reported that they need to set the 32-bit folder preferences (detailed above) in addition to the 64-bit preferences on 64-bit systems running 64-bit versions of Microsoft Office.
Use Process Monitor to drill down any permission issues by looking at FILE NOT FOUND or ACCESS DENIED errors.