How can I write a method that prints without the print dialog?
I have a method that loops through a found set of records and prints form A and form B for each record. If form B does not contain data then it is skipped (not printed).
The looping and conditions are not a problem. I am stuck on what should be the easy part. When each form needs to be printed, how do I have the method print the form without having the print dialog come up?
I think there is a flag in controller.print allowing you to print without a dialog. At least it lets you print a whole batch showing the print dialog only once…
I have come across that, too, and found no solution. I’d be interested to hear if there is a way! I think the situation is a frequent one. I have one page that is portrait and one that is landscape. Both pages have to be printed for each single (!) record. I don’t want someone to sort those together manually from two piles. How do I do that?
What about [ShowPrinterSelectDialog] in controller.print? I use it to show the print-dialog only once when printing a batch of invoices. I set to true on the first print command, false thereafter.
if(plugins.dialogs.showQuestionDialog('Print','Batch Print Invoices?','Yes','No') == 'No') {
return '';
}
for ( var i = 1; i <= foundset.getSize() ; i++ )
{
foundset.setSelectedIndex(i);
if(i == 1) {
forms.acc_document_detail.document_print(true,true,'');
} else {
forms.acc_document_detail.document_print(true,false,'');
}
}
controller.saveData();
plugins.dialogs.showInfoDialog('Batch Print Invoices','Done!','OK');
Thank you all! The following appears to solve my problem:
if(plugins.dialogs.showQuestionDialog('Print',
'Print found set (also prints page 2 when page 2 "attachment" field '+
'contains at least one word)?','Yes','No') == 'No')
{
return '';
}
controller.recordIndex = 1;
for ( var i = 1; i <= foundset.getSize() ; i++ )
{
foundset.setSelectedIndex(i);
forms.formA.controller.print(true,false);
if(utils.stringWordCount(attachment) > 0)
{
forms.formB.controller.print(true,false);
}
}
controller.recordIndex = 1;
plugins.dialogs.showInfoDialog('Print Status','Print job completed!','OK');
so when you first show the printerdialog, choose an other printer as the default, than the rest of the pages(forms) are printed to that printer also???
so when you first show the printerdialog, choose an other printer as the default, than the rest of the pages(forms) are printed to that printer also???
What are you confused about? Did you try it? What would you expect? What were your results? In which sense and why were they confusing? Any changes you suggest?
Apologies for the amount of questions but I always want to know what’s going on when people are a little confused.
I had the assumption (and still have) that when you show a printer dialog and print a job, and right after that you do another printjob, that the last print-job ends is printed to the default-printer and NOT the printer thas has been choosen the first time!
the first line is printed to the printer you select.
the second line is printed always to the default printer.
(I double checked it now!)
Showing a printerdialog in this case, has no sense to me, because the rest that follows is always printed to the default printer.
So yes, I would like to have a function, where Servoy could ‘remember’ what the last choosen printer was.