V18.1 produce corrupted pdf (on mac, win ?)

I’m refactoring my printer output, in v18.1 and I get a corrupted pdf on mac (not tested on win).

Any ideas ?

_O_PAGE SETUP($table->;$form_name)
$path_file_pdf:=System folder(Desktop)+"toto.pdf"
SET CURRENT PRINTER(Generic PDF driver)  // before
SET PRINT OPTION(Destination option;2;$path_file_pdf)
SET PRINT OPTION(Destination option;0)

Then the pdf gives :

Many thanks.

But if I use the following line, without any change to the current printer, the generated pdf is readable.

		  SET PRINT OPTION(Destination option;3;$path_file)

But the initial goal was to avoid “3” on windows in order to avoid PDFcreator anymore.
So I’m stucked…

Same issue in v18R2. No one got this?

Even the given code in documentation do not work, give a corrupted pdf.

On mac ! On windows, I don’t know, but is it not supposed to work on mac too ?


There is an error in the documentation, the sample code is not correct.
To generate pdf with “Generic PDF driver” you must use Destination option 3 on both platform.

Destination option 2 produce postscript on macos, not pdf


1 Like

Oh :open_mouth:

Ok but then, there is something strange. On mac os, if I use the syntax with 3, there is no need to change the printer, a pdf file is automatically generated. Do you confirm?

On windows, if I use 3, it seems that PDFcreator is used.

So I’m really confused about telling 4D in one hand to use a generic pdf printer, then telling it again with the 3 syntax (giving at the same occasion the path).
I don’t understand why this double need from long time back.

Documentation :

Yes, because on mac os pdf is builtin

If the current printer is NOT Microsoft print to pdf (“Generic PDF driver”), 4d will try use PDFCreator for the next printing job. At the end of the job, 4d will restore the current printer. This emulate the mac behavour

If the current printer is Microsoft print to pdf (“Generic PDF driver”), selector 3 will set the pdf file path (same as selector 2)

1 Like

:sweat_smile: :sweat_smile: You had a lot under the hood!
Now everything is clear, lets program and make it run: a BIG thanks.

Ce souci existe aussi en V17.3

on windows, I have to share some results I get…

On mac
(9;3;path) is ok without the need to set the printer before (this is not 2).

On Win
(9;3;path) after having set the printer to “Microsoft Print to PDF”, I get an empty pdf file…
I needed to use the syntax (9;2;path) !!!

So (9;3;path) on mac, and (9;2;path) on Win :thinking:

Doing this, my generic manager works now.

And on windows 10, with a clean and fresh install,
If I use:


I get an error “XPS Viewer not installed” on:


Woaow ! Thanks windows.

And in the

PRINTERS LIST($T_printers)

I get “Microsoft XPS Document Writer” in it: shall I use this printer, same as pdf, to get my preview ?
Why the 4D preview do not work ?

Hello Olivier,
There are two programs on Windows 10. XPS Writer and XPS Reader. The reader does the print preview in 4D. Not all versions of Windows 10 install it automatically. It is quite easy to install in Settings.

More researches… and more I use windows, more I get angry with this os…

Oh thanks David. I just got your answer.
But I’m not able to open properly XPS files, after 2 hours of fighting…
I installed XPS reader, but if I want to associate xps file to that reader, it is not in the listed app.
Only Internet Explorer is available, or “Find an app on the microsoft store” which contains only pdf stuff…
If I open files with Explorer, no display occurs, only a save dialog with open dimmed…

Ok, it seems too that Krosoft is no more supporting XPS, so I’m with 4D’s preview linked to xps, and XPS files no more supported.

I thing I’ll manage even the previews in 4D with the pdf printer…
What a miss !

strange, there is no need to associate, that is done from Microsoft installer automatically?

Just to avoid misunderstanding, you used the Microsoft viewer, not a 3rd party one?
Installed via “Features on demand”, not downloaded somewhere?


Hi Thomas,
Yes I used the driver you say, how you say.

Why I have to associate xps again is before installing the xps viewer, I opened and associated an xps file to explorer.
And I can’t find any other program to associate to xps but explorer…

Set Current Printer(Generic PDF driver)
instead of
Set Current Printer(“Microsoft Print to PDF”)

Why ?

Does @patrick_poly’s answer work for you?

In fact, I gave up using the 4D preview in XPS.
As all my output traitement is now fully generic and common, I changed in a snap that for PC, previews are made generating pdf in temporary folder and open the generated file…

Double benefice: first xps in no more maintained and second I solved my issue (without understood why I have to admit :sweat_smile: