What exactly provides Print to PDF "printer"?

I am trying to have a sandboxed (firejail) instance of okular be able to print to the “Print to PDF” pseudo printer. But the list of printers in the print dialog is empty.

I’m not sure what provides that “printer”. My system doesn’t have cups or even /etc/cups (it does have libcups). I am at a loss on what I must allow for the sandboxed instance to restore access to print to PDF.

QT docs are hard to follow to find actual implementation details

Likley a combination of ghostscript and cups-pdf (which depnds on it) or similar. It has nothing to do with the toolkit or desktop GUI, I think.

1 Like

Likley a combination of ghostscript and cups-pdf (which depnds on it) or similar. It has nothing to do with the toolkit or desktop GUI, I think.

that’s not what i’ve read on the QT docs (linked on the 1st post). It clearly says that QT provides PDF creation/rendering support. But offer zero clues besides API interfaces.

I’ve found a really old blog post where they say they ported some pdf library. But i bet they already moved to something else. And none of the info i’ve found explain why I have that printer without the firejail sandbox, and I do not have it with the sandbox (using firejail git and arch provided okular profiles)

Only cups package I have on the system is libcups. nothing else (the KDE printer setting just say “no backend” or something to that end. Yet, all apps have the Print to PDF pseudo-printer.

In fact, some (outdated) places suggest adding a Print to PDF printer in CUPs to use different generators than QT to work around bugs.

any other suggestions? i’m lost on this still

Best i could find was that it depends on user dbus, but haven’t found docs on it.

looking at QT’s source, i see the var PPK_PrinterProgram is involved, but I cannot see where that is ever set. Also found it have some index of 14 in some places, but still no closer to an answer.

From the QT6 documentation :

"### void QPrinter::setOutputFileName(const QString &fileName)

Sets the name of the output file to fileName.

Setting a null or empty name (0 or “”) disables printing to a file. Setting a non-empty name enables printing to a file.

This can change the value of outputFormat(). If the file name has the “.pdf” suffix PDF is generated. If the file name has a suffix other than “.pdf”, the output format used is the one set with setOutputFormat().

QPrinter uses Qt’s cross-platform PDF print engines respectively. If you can produce this format natively, for example macOS can generate PDF’s from its print engine, set the output format back to NativeFormat."

Probably you want to look at QPdfWriter for the details.

1 Like

Thank you Mholscher! That is actually where I started (i link to the doc you quote on my 1st post)

Today I decide to look at the QT source, since the documentation doesn’t offer any hope. But the further I went with the code is the variable I ask above, PPK_PrinterProgram. It was a dead end.

I decided to sandbox okular and add things one by one to the limited env until i could see the virtual printer show and and then get a pdf out of it. It was a extremely boring, but in the end I figured out it execs /usr/bin/ps2pdf for that functionality. So, something in the build systems used by QT, or KDE, or my distro, sets this PPK_PrinterProgram value to ps2pdf. Which is what ultimately produces the PDF.

But I would love an answer for someone who actually knows who all that actually happens. I’m mostly blackboxing it now.

This is driving me insane.

okular cannot print to pdf without access to ps2pdf, but kate can…