# How to print without print dialog

**URL:** <https://forum.servoy.com/t/how-to-print-without-print-dialog/5754>\
**Category:** Classic Servoy\
**Created:** [April 13, 2006, 1:56pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754 "2006-04-13T13:56:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [April 13, 2006, 1:56pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/1 "2006-04-13T13:56:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [April 13, 2006, 4:12pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/2 "2006-04-13T16:12:41Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [April 13, 2006, 5:27pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/3 "2006-04-13T17:27:42Z")

</div>

Yes, there is a flag that lets you print the current record or current found set of records, and that is good.

However, in this case I need to do the following without repeatedly showing print dialogs:

1. go to first record
2. print form A (first page of form)
3. print form B (second page of form) if attachment field contains text  
repeat steps 2 and 3 for remaining records

This seems like it should be so simple, but I’m stumped. Does anyone know if this can be done in Servoy?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [April 13, 2006, 6:58pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/4 "2006-04-13T18:58:25Z")

</div>

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?

Thanks  
Patrick

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [April 14, 2006, 2:29pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/5 "2006-04-14T14:29:45Z")

</div>

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.

```auto
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');

```

and

```auto
var automatic = arguments[0];
var show_printer_select = arguments[1];
var email_pdf_to = arguments[2];
controller.saveData();

.
.
.
.
.
	} else if(automatic) {
		forms.acc_transaction_list_print.controller.print(false,show_printer_select);
	} else {
		forms.acc_transaction_list_print.controller.showPrintPreview();
	}

.
.
.
.

```

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [April 14, 2006, 6:00pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/6 "2006-04-14T18:00:03Z")

</div>

The solution Christian uses is **exactly** the way I solved such an issue also!

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [April 14, 2006, 7:27pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/7 "2006-04-14T19:27:16Z")

</div>

Thank you all! The following appears to solve my problem:

```auto
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');

```

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [April 14, 2006, 8:27pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/8 "2006-04-14T20:27:24Z")

</div>

I am a little confused here.

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???

---

<div class="post-metadata">

**Author:** ![Jan\_Aleman](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jan\_Aleman](https://forum.servoy.com/u/Jan_Aleman)\
**Post date:** [April 14, 2006, 9:56pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/9 "2006-04-14T21:56:58Z")

</div>

> HJK:  
> I am a little confused here.
> 
> 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.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [April 14, 2006, 10:49pm UTC](https://forum.servoy.com/t/how-to-print-without-print-dialog/5754/10 "2006-04-14T22:49:30Z")

</div>

Is it forbidden to be confused? ![:?]( "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!

for example, when you do this:

forms.printOrder.controller.print(true,true)  
forms.printFax.controller.print(true,false)

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.
