Hello everyone,
I’m trying to print a PDF file without showing the print dialog to the user. I’m using Gtk.PrintOperation and Gtk4. I saw here (Gtk.PrintOperationAction) that the GTK_PRINT_OPERATION_ACTION_PRINT start to print without showing the print dialog, I implemented it but I’m still having the dialog. Here is my code :
Those are build options; the GDK_DEBUG environment variable should be set when running the application—but it’s a debugging tool, and should not be used in normal operations.
In practice, what you want to do is not possible with recent GTK, as we default to using the portals across the board on Linux.
It’s not “impossible”, but it requires you to use the GtkPrintDialog API instead of the print operation API. If you pass a NULLGtkPrintSetup object to gtk_print_dialog_print(), for instance, the GtkPrintDialog will attempt to print without directly without user interaction.
Thank you for your answer, but I think there’s a mistake:
Traceback (most recent call last):
File "/app/share/test/test/main.py", line 113, in print_file
dialog.print_(None, page_setup, None, on_print_finished)
TypeError: argument setup: Expected Gtk.PrintSetup, but got gi.repository.Gtk.PageSetup
It looks like Gtk.PrintDialog.print_() expects a Gtk.PrintSetup, not a Gtk.PageSetup. Do you know how to properly create a Gtk.PrintSetup from my page_setup.conf and print_settings.conf files?