PDF format is a viable alternative to XPS for print previewing on Windows, providing users with a more accessible option. Microsoft’s decision to make the XPS Viewer an optional Windows feature has caused issues for many users when deploying applications, resulting in end-users being unable to preview their printings. Although installing the free XPS Viewer is straightforward, some administrators are hesitant to install additional features, particularly on Remote Desktop environments.
Fortunately, 4D v20 now offers the option of using the PDF format for print previewing. Since almost all current Windows versions have either XPS or PDF pre-installed, end-users should no longer encounter issues with print previewing. This new option offers a more flexible and efficient solution that meets the needs of both end-users and administrators.
How DOES it work?
In fact, you have nothing to do to benefit from the PDF format with a print preview on Windows!
4D detects if an XPS printer and an XPS viewer are available in the system and, if not, automatically switches to PDF format.
If a PDF printer or viewer is missing, a message is displayed instead of the print preview checkbox at the bottom of the printing dialog. And if you have chosen to hide the printing dialog or an error is thrown in this case.
As the XPS format still has advantages, such as embedding printer settings, we didn’t replace the XPS format with the PDF.
Keep control
Everything is automatic, but you can also keep control over the automatism.
With 4D v20, the SET PRINT OPTION command supports a new selector Print preview option. You can define if the print preview uses the automatic algorithm or force the format used to XPS or PDF:
SET PRINT OPTION(Print preview option; kp preview automatic)
SET PRINT OPTION(Print preview option; kp preview XPS)
SET PRINT OPTION(Print preview option; kp preview PDF)
The GET PRINT OPTION supports the new Print preview option too. It returns the option set in the second parameter and the option used in the third.
This last option is handy for checking if your settings are ok before launching a print preview instead of launching the print preview and catching the errors. For example, if you set kp preview PDF and the PDF printer or PDF viewer is missing, the option will return kp preview none. Here is a sample to check which print preview format is really used in the system:
SET PRINT OPTION(Print preview option; kp preview automatic)
GET PRINT OPTION(Print preview option; $optionSet; $optionUsed)
Case of
: ($optionUsed=kp preview XPS)
// XPS format
: ($optionUsed=kp preview PDF)
// PDF format
: ($optionUsed=kp preview none)
// No print preview available
End case
Note that this new behavior does not affect macOS because the print preview format is always PDF.
We are confident that the PDF format option for print previewing will significantly improve the user experience of your deployed applications. By offering this new option, we aim to save you valuable time and effort while ensuring end-users are satisfied with the application’s functionality.
We constantly strive to provide our users with the best possible experience, and we encourage you to share your thoughts and feedback on the 4D forum. Your feedback helps us better understand your needs and continuously improve our products and services.