I'm trying to make a printing routine without the dialog window, I understand that this is done using the PRINT option instead of PRINT_DIALOG.
Gtk.PrintOperationAction.PRINT_DIALOG
Gtk.PrintOperationAction.PRINT
The routine with the dialog option works accordingly, these options are captured with the "print.toFile(...)" function and read in the lines:
pageSetup.loadFile(Assets.absoluteFilePath('pagesetup.conf'));
printSettings.loadFile(Assets.absoluteFilePath('printsettings.conf'));
they appear in the logs.
But nothing happens, none of the events are fired ('begin-print', 'draw-page', or whatever).
I'm using the node-gtk package together with Meteor, this is evidenced in the "Assets.absoluteFilePath" ( Meteor ) function and on all the other lines, which are in camelCase (node-gtk does this )
I don't believe these packages are the cause of the problems, it seems to me that something is missing, since the result is three (3 -> IN_PROGRESS).
And all the examples I find use the PRINT_DIALOG routine
botao2.on('clicked', () => {
let printSettings = new Gtk.PrintSettings();
let pageSetup = new Gtk.PageSetup();
pageSetup.loadFile(Assets.absoluteFilePath('pagesetup.conf'));
printSettings.loadFile(Assets.absoluteFilePath('printsettings.conf'));
let print = new Gtk.PrintOperation({
//'allow-async': true,
});
print.setUnit(Gtk.Unit.NONE);
print.setPrintSettings(printSettings);
print.setDefaultPageSetup(pageSetup);
print.setUseFullPage(true);
print.setShowProgress(true);
console.log({ pageSetup, printSettings });
print.on('begin-print', (printContext, num) => {
print.nPages = 1;
width = Math.floor(printContext.getWidth());
height = Math.floor(printContext.getHeight());
});
print.on('draw-page', (printContext) => {
console.log('draw-page', printContext);
});
print.on('status-changed', (...args) => {
console.log('status-changed', args);
});
print.on('done', (res) => {
console.log('done', res);
});
console.log(print.run(Gtk.PrintOperationAction.PRINT)); // always 3 -> IN_PROGRESS
});