1

I am Using Delphi VCL and the problem is that I am creating labels and printing them, the user selects how many to print and I need to add a progress bar to the printing process so that it says something like: printing 3 of 7 or similar, but I don't know how to.

any ideas how to get this done?

EDIT:

I am using FastReports for printing the label and I basically set:

report.PrintOptions.Copies:= x;
report.Print;

the report's printer is set to the same printer that Tprinter is set, I set them with Printer.PrinterIndex:= Printer.Printers.IndexOf('My Printer');

Hiram
  • 159
  • 1
  • 9
  • How are you printing the labels? Directly with TPrinter, or through a reporting component? You've not provided enough information. – Ken White Jun 18 '19 at 16:51
  • sorry, I am using FastReports to print the label, but Tprinter and the report's printer are set to the same printer. – Hiram Jun 18 '19 at 16:55
  • thing is FastReports doesn’t support printing copies, and when I print, lets say, 4 the progress bar only moves 1 and then stops. If there is a way of tracking the selected printer progress I would appreciate the guidance. – Hiram Jun 18 '19 at 16:57
  • FastReport is the relevant information. Can you [edit] your post to include that you're using FR and add details about how specifically your report is set up to print the labels, as well as the information you just added in that last comment? – Ken White Jun 18 '19 at 16:57
  • okay, I edited the question, if I there is more information I can provide please let me know @KenWhite – Hiram Jun 18 '19 at 17:04
  • The immediate question is why you don't just print one copy multiple times in a loop, and update the progress bar in the loop. `for i := 1 to x do begin report.Print; ProgressBar1.Progress := Trunc(i / (x * 1.0)) * 100.0; end;` – Ken White Jun 18 '19 at 17:13
  • I tried that but if I print 3 labels, the printer hasn’t even finished the first one and the progress bar is already full – Hiram Jun 18 '19 at 17:29
  • 1
    If they're printing that fast, why do you need to show progress at all? You can't measure the actual output progress of the printer itself, only the code that is sending it to the printer. – Ken White Jun 18 '19 at 17:30
  • I was asked to do so, it wasn’t my idea. So, is there any way to know when the printer finished printing? – Hiram Jun 18 '19 at 17:36
  • 2
    Usually, no. A few printers may support two-way communication, but you typically have to jump through a bunch of hoops to do so. Most print jobs go directly to the Windows spooler or are dumped directly to the printer's internal memory. Sometimes when you're asking to do things, the answer is *Sorry, I can't - here's why*. – Ken White Jun 18 '19 at 17:39
  • don't worry, thank you so much for answering and helping me, I think I'll just put a loader screen while it prints. – Hiram Jun 18 '19 at 17:43
  • @KenWhite, you know what, you missunderstood what I said previously and I didn’t notice. the printer is not the fast one, the progress bar is. I mean, the progressBar fills completely and the printer hasn’t even finished printing one label – Hiram Jun 18 '19 at 17:47
  • 1
    Yes, that's what I said. The progress bar tracks what your code is doing. It has no way of knowing what the printer is doing once your code sends the label to the printer. I didn't misunderstand anything. :-) I wrote *You can't measure the actual output progress of the printer itself, only the code that is sending it to the printer.* – Ken White Jun 18 '19 at 17:50
  • oh sorry, I was the one who misunderstood then. in that case I'll go for the loader. – Hiram Jun 18 '19 at 17:51
  • 1
    Still the same problem, you won't know when to hide it. You could try to get information from the Windows spooler, but even that can be done before the actual printer is done. Each of them buffers the information of your application. Your application could send something to the spooler in 2 seconds, while the printer would take an hour to print it. – GolezTrol Jun 19 '19 at 05:42
  • 1
    There are some questions, [like this](https://stackoverflow.com/questions/11769351/is-there-a-way-to-check-if-a-printing-process-was-successful) for C#, on how to get the status of print jobs. That would at least be a bit closer to the truth.. – GolezTrol Jun 19 '19 at 05:45
  • 1
    I personally haven't done this before, but maybe the [Asynchronous printing notification functions](https://learn.microsoft.com/en-us/windows/desktop/printdocs/asynchronous-printing-notification-functions) can be used to let your application receive updates on print jobs? – GolezTrol Jun 19 '19 at 05:47
  • thanks For the information, I'll check it out and and see whether I try something or just drop it. cheers! – Hiram Jun 19 '19 at 14:37

0 Answers0