Stack: GTK4, Webkit 6, Python, Flatpak.
In a Flatpak app, I’m trying to use WebKit.PrintOperation.print_ (the underscore is for the Python bind) to save a page as a PDF. Everything seems to work; the try-except block says the file was saved, but the file isn’t created.
My suspicion is that WebKit.PrintOperation.print_ isn’t correctly handling the portal URI I get via Gtk.FileDialog.
WebKit.PrintOperation.run_dialog exports the file normally after choosing to print to a file. Here is a representative excerpt of the code.
try:
gfile = dialog.save_finish(result)
print_operation = WebKit.PrintOperation.new(self.webview)
uri = gfile.get_uri()
settings = Gtk.PrintSettings()
page_setup = Gtk.PageSetup()
settings.set(Gtk.PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "pdf")
settings.set(Gtk.PRINT_SETTINGS_OUTPUT_URI, uri)
print_operation.set_print_settings(settings)
print_operation.set_page_setup(page_setup)
print_operation.print_()
…