Skip to main content

On the Shipments Screen, I overrode the Print Shipment Confirmation button so that I can direct the print job to a specific printer on the Device Hub.  

It works.  But I want to specify a number of copies.  There is a printer parameter NumberOfCopies but when the print job is sent to the Hub, it seems to be ignoring the parameter.

//THIS WORKS but only prints one copy even if NumberOfCopies is greater than 1
//PrintSettings printSettings = new PrintSettings()
//{
// PrinterID = printer.PrinterID,
// NumberOfCopies = iCSPrintHubActions.NumberCopies,
// PrintWithDeviceHub = true,
// DefinePrinterManually = true
//};

//PXGraph.CreateInstance<SMPrintJobMaint>().CreatePrintJob(printSettings, reportID, parametersDictionary, "Shipment Confirmation", CancellationToken.None);

//to use this you must uncheck Use Parallel Processing in the Device Hub
for (int i = 0; i < iCSPrintHubActions.NumberCopies; i++)
{
PrintSettings printSettings = new PrintSettings()
{
PrinterID = printer.PrinterID,
NumberOfCopies = 1,
PrintWithDeviceHub = true,
DefinePrinterManually = true
};

PXGraph.CreateInstance<SMPrintJobMaint>().CreatePrintJob(printSettings, reportID, parametersDictionary, "Shipment Confirmation", CancellationToken.None);
}

If I use the code that is commented out, it works great but if I specify a value greater than 1 for the NumberOfCopies, it has no effect.

I came up with a workaround.  I use a for loop and run the print job the number of times that is specified in the iCSPrintHubActions.NumberCopies.

I’ve been testing using 2 copies.

However, I have to uncheck the Use Parallel Processing in the Device Hub or I get errors and unexpected results.  Sometimes one prints, or they all fail.

If I knew why the NumberOfCopies parameter is being ignored, I would like to use my first option (commented out).  The work around is not the best way to do this.

Any suggestions?

UDPATE:

In the Print Jobs, it IS showing that I want 2 copies.  So my issue is that when I send 2 copies, it only prints 1.

Now I’m playing with the device hub settings to see if I can get it to work.  

I’m wondering if maybe my laserjet printer is not allowing or cannot accept a command for the number of copies...or, does the print hub send two print jobs to the printer?

 

 

 


Apparently, the printer I am using for testing does not accept a command for a number of copies to print.  The customer installed my project and it prints multiple copies as expected.

Since the only way to direct a report directly to a device hub printer is from a process screen, I created a fairly nice workaround.  You create an action (override or custom) on the screen you want to use a device hub printer.  Then I created a maintenance screen where you can define the printer you want to go to for each custom action.  It is a workaround, but it allows the user to change the destination printer for each custom action.

 

The menu title you assign is what is used for the menu item and it will add (JOEPRINTER) to the end of the title so you know exactly which printer your report is going to.  You can use a lookup on the printer name to select any printer setup in the Device Hub.  All the other fields are manually entered so it is up to the user to enter the data correctly.  When the action fires, it looks for the ScreenID/ReportID combination and selects the printer, label for the menu item and number of copies to print from the custom table that is ties to this screen.  The VS code is hard coded, but that’s why it is a workaround.

Unfortunately, I am going to mark my post as the best answer.  I am not trying to pad my stats… 😏

 


Reply