Hi,
Is there a way to make calls to the printer asynchronous? We are finding that the PDF printmanager is slow to complete the print job method, e.g. it send's the job to the printer, waits for it to spool and then print before returning control back to the application that made the call.
thanks,
Paul
Asynchronous calls
Re: Asynchronous calls
Support · Aug 18, 2009Hello Paul,
Currently it is not possible to do asynchronous printing directly using the API. This is a feature we do have on our wish list and will be added in the near future in the coming version.
Currently you will have to use Threads to do the asynchronous printing.
Thanks,
ceTe Software Support Team.
Re: Asynchronous calls
Forum member · Apr 25, 2023Regarding "use Threads to do the asynchronous printing."
Can it be done using async Task like
static async Task Main(string[] args)
{
var aTaskA= PrintAsync("DocumentA.pdf");
var aTaskB= PrintAsync("DocumentB.pdf");
var printTasks = new List<Task> { aTaskA, aTaskB};
while (printTasks .Count > 0)
{
Task finishedTask = await Task.WhenAny(breakfastTasks);
if (finishedTask == aTaskA)
{
Console.WriteLine("aTaskA are ready");
}
else if (finishedTask == aTaskB)
{
Console.WriteLine("aTaskBis ready");
}
await finishedTask;
breakfastTasks.Remove(finishedTask);
}
}
static async Task PrintAsync(string doc)
{
byte[] pdfBytes = System.IO.File.ReadAllBytes(doc);
InputPdf pdf = new InputPdf(pdfBytes);
PrintJob printJob = new PrintJob(Printer.Default, pdf);
printJob.Print();
}
Re: Asynchronous calls
Support · Apr 28, 2023Hi,
Yes, that will work fine to make the call asynchronous.
Thanks,
ceTe Software Support Team