Recent

Author Topic: Printing to two or more printers at the same time  (Read 671 times)

PJW

  • New Member
  • *
  • Posts: 12
Printing to two or more printers at the same time
« on: November 06, 2020, 03:23:49 am »
Is there a way to do this?   I have an application where multiple (often different) reports need to be generated at the same time going to different printers using the same data.

Sure one could loop thru the data multiple times but it would be much more convenient to be able to have multiple active printers.

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 609
Re: Printing to two or more printers at the same time
« Reply #1 on: November 06, 2020, 06:56:11 am »
Does printing operation block current thread? If yes (at least while sending document to queue) - then may be use separate thread for each printing operation?
DynamicData 3.0 is released!
Since now development is frozen - only optimization passes will be made at some point.
Lack of multiple inheritance turns it into abomination.

PJW

  • New Member
  • *
  • Posts: 12
Re: Printing to two or more printers at the same time
« Reply #2 on: November 06, 2020, 10:34:11 pm »
The problem seems to be at least in Windows that one can only have one active printer selected OS-Wide.  At least under DOS we had LPT1, LPT2, etc.
 
Since the LCL works the same way in Linux as Windows I do not see a way to have two different printers selected, even if they are in multiple threads.  Besides, using multiple threads in the case still requires multiple passes thru the data, it just has two separate processes doing it.
« Last Edit: November 06, 2020, 11:55:02 pm by PJW »

winni

  • Hero Member
  • *****
  • Posts: 2113
Re: Printing to two or more printers at the same time
« Reply #3 on: November 06, 2020, 10:51:10 pm »
Hi!

Strange desire.

I would solve your problem this way:

Print your data to a file.
And then add the file to the different print queues.
As often as you like.
And to all the queues you own.

Winni

jamie

  • Hero Member
  • *****
  • Posts: 4030
Re: Printing to two or more printers at the same time
« Reply #4 on: November 07, 2020, 02:08:42 am »
Is there a way to do this?   I have an application where multiple (often different) reports need to be generated at the same time going to different printers using the same data.

Sure one could loop thru the data multiple times but it would be much more convenient to be able to have multiple active printers.

in windows you have a print spooler which means you can send multiple jobs to any printer.

problem is however using Lazarus "Printers4larus" may only allow you one printer cycle so you need to select the printer, print your just and close it.
it all goes to the print spooler so you don't need to wait for it to return.

 you can use the API calls to do it too which then would allow you to open multiple printers but still, you have a printer spooler
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 2588
  • Compiler Developer
Re: Printing to two or more printers at the same time
« Reply #5 on: November 07, 2020, 12:07:48 pm »
The problem seems to be at least in Windows that one can only have one active printer selected OS-Wide.  At least under DOS we had LPT1, LPT2, etc.

That is the default printer, not the only active printer. You can just as well print multiple documents to multiple printers at once. In how far the API provided by Lazarus allows for this right now is a different topic however (and one I don't know as I haven't worked with printers in a long time).

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 880
Re: Printing to two or more printers at the same time
« Reply #6 on: November 07, 2020, 01:23:18 pm »
hello,
in my small project printmemo ((print the content of a tmemo with printers or lazreport)  i have added a multiselect listbox to choose multiple printers for printing. 
code to fill the listbox :
Code: Pascal  [Select][+][-]
  1. Procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.     Listbox1.Items := Printer.Printers;
  4.   if Listbox1.Items.Count > 0 then
  5.     Listbox1.ItemIndex := 0;
  6. end;    

I have this code to print with lazreport the tmemo content to the  selected printers :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var  i: integer;
  3. begin
  4.    frReport1.LoadFromFile('print.lrf');
  5.    frReport1.PrepareReport;
  6.    for i:=0 to ListBox1.Items.Count-1 do
  7.     if ListBox1.Selected[i]  then
  8.       begin
  9.         frReport1.ChangePrinter(Printer.PrinterIndex, i);
  10.         frReport1.PrintPreparedReport('1-2',1);
  11.       end;
  12. end;
I choose two printers and click to print with lazreport (see attachment)
printing is OK for the two printers with no blocking dialog window.
see attachment for the generated pdf.

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

 

TinyPortal © 2005-2018