Q: We are trying to use 'pdftron.PDF.Convert.ToPdf()' and
ToSilverlight() to convert MS Office documents (mainly Word) to PDF
and Silverlight XPS.
It works great in the console application but when we move the code to
our ASP.NET application (Windows 2008 x64 Web edition SP 2) we run
into the followng issue:
Message: An error occurred while converting the file.
Unable to find printer
at pdftron.PDF.Convert.ToPdf(PDFDoc in_pdfdoc, String in_filename)
All other operations in PDFNet work without errors or exceptions.
A: Although it is not related to your issue/exception the following
note applies when using 64-bit version on PDFNet on a 64-bit server:
// Note that when using the 64-bit version of PDFNet, it must be run
in a 64-bit web server.
// The Microsoft development web server is 32-bit only. The options
are to use the 32-bit version of PDFNet
// for development purposes, or to configure Visual Studio to run an
alternate, 64-bit web server, such as IIS.
Going back to the issue:
'pdftron.PDF.Convert.ToPdf()/ToXps()/ToSilverlight()' will fail to
conver MS Office documents if the application pool's identity is set
to "NETWORK SERVICE" or lower. This is because "NETWORK SERVICE"
identity has a very limited set of privileges (e.g. no access to
registry, no full access to file system, etc).
When 'Convert.ToPdf' is ran under "NETWORK SERVICE", converting
Microsoft Office documents fails because MS Interop itself does not
work under "NETWORK SERVICE". This will cause the Convert.ToPdf()
method to revert to the PDFNet printer. Using the PDFNet printer also
requires higher permission level in order to read and write entries to
the registry which is not allowed under "NETWORK SERVICE", so this
method will fail as well.
In order to resolve the issue, it is necessary to grant the required
permissions. Using the identity "LOCAL SYSTEM" works, but other
solutions are possible.
The solutions that we tried on our end require an actual user account
(possibly only with permissions needed by PDFNet). The "limited" user
account can be used as the IIS application pool identity instead of
The other solution is to associate ASP.NET application to use
"limited" user's credentials via "ASP.NET Impersonation":
As mentioned by that article, adding the following code to web.config:
<identity impersonate="true" userName="computer\LimitedUser"
will use this "limited" user account's credentials instead of "NETWORK
SERVICE" for this specific application.