Saturday, March 04, 2017

How to Fix: Microsoft Print to PDF (or Microsoft XPS Document Writer) Printer Not Working

How to Fix: Microsoft Print to PDF and Microsoft XPS Document Writer Printer Not Producing Output File

Symptoms: Print to PDF or Print-to-XPS Fails Silently, with no PDF File Created or no XPS File Created, in Microsoft Windows or Microsoft Office

This Microsoft Windows and/or Microsoft Office bug (or Windows "Feature") drove me crazy for a bit of time — when I wanted to print a document or spreadsheet, I would choose Print, then select either "Microsoft Print to PDF" or "Microsoft XPS Document Writer" as my target printer, proceed with printing to a file, where I would be prompted for the filename and file-location (directory), and choose to "Save" the file, and, even though all indications were that printing was functioning correctly, no XPS or PDF file was created!

Maddening!  In the end, it turns out that actually, this appears to be an issue (or problem or bug or feature) with Microsoft Windows that has to do with how the Windows Printer Driver functions (or does not function or work in certain situations), in particular with some security settings that mess it up.  I was using Microsoft Windows 10 and Microsoft Office 2013 (running in a Vmware Virtual Machine — which I mention only because this bug also prevents printing documents to PDF or XPS files via Vmware's ThinPrint driver too).

This is my list of available printers, and the two virtual printers (print to PDF or XPS file) experiencing this problem printing to a file are highlighted with a green box:
Printers: including Microsoft Print to PDF and XPS Document Writer

The problem cause, and how to fix this printing problem...

This took some time to figure out, but the root-cause of this printing problem was file-system directory security settings. It turns out that both the Microsoft Print-to-PDF and Microsoft XPS Document Writer need appropriate permissions in your temporary directory.

I tend to redefine my default Microsoft Windows temporary directory to some easier-to-quickly-locate place, like, e.g., "C:\temp" or "C:\tmp" (vs. buried in their default user subdirectories).  It turns out that creating that non-standard / non-default temp-directory is what led to my particular problem with the PDF / XPS driver not working.

In Windows 10 (or Windows 7 or whatever), your temporary directory is defined under Control Panel, System Properties, Advanced, Environment Variables, User Variables / System Variables, with the Variables of "TEMP" and/or "TMP" pointing to your temporary directory of choice, and whereby I have remapped my temp dir to be "C:\temp" or whatever.  I never even considered that changing my temp directory could break my Windows Printing (to file) features!  But, it did!

So, how to fix the fact that PDF files and XPS files were acting like they were printing, but nothing is being generated, not even in the print-queue? Easy: set the permissions on your newly chosen temporary directory location as follows:

Here is what the default permissions on my custom temp directory looked like when the PDF and XPS files refused to print:

Default custom-temporary-directory permissions

Now, this is all it took to fix the problem — one simple check-mark (see green circle), changing the permissions on the temp directory:

That did it! Enabling Authenticated Users to have Full Control of the temporary-directory fixed the Microsoft XPS Document Writer and Microsoft Print to PDF feature.

It is hard to believe that a system-level print-driver needs some special permissions on a temp directory (the same directory all sorts of program installers and software update logs go into, etc.) in order to create a PDF or XPS temp file, but that seems to be the case.  And, without that permission, you click Print and nothing happens... no file is produced... no printing errors during the PDF / XPS production process, no indication of failure... just no file produced. Period.  Ughhh.  But, now I know. I hope this saves some readers a bit of time and frustration.

This issue was as crazy as the one that forced me to write a blog about How to Fix: "Unable to find Adobe PDF resource files" - Adobe PDF Converter.joboptions - in Acrobat Pro a while back.  Equally ridiculous.

Continue to read this Software Development and Technology Blog for computer programming articles (including useful free / OSS source-code and algorithms), software development insights, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Delphi, Nvidia CUDA, VMware, TypeScript, SVG, other technology tips and how-to's, plus my varied political and economic opinions.