
Since the advent of RDLC report in October 2018 with NAV 2009 RTM (Build 27808), printing Labels with Report Viewer (RV) component has not been an easy task to accomplish.
SQL Server Reporting Services (SSRS) team, whom historically created RV as an add-on for SQL Server 2000 (yes, exactly, 20 years ago), didn’t had in mind to use reporting services to print e.g. documents nor label.
That is the main reason why you might find some difficulties creating these 2 kinds of report compared to others and, overall, in relation of good old CSIDE Classic Report development.
Considering Label printing this has always been an open wound and a nerve that might be painful to touch.
In December 2020 Cumulative Update (CU) for 16.x and 17.x branches (SaaS update included) and in January 2021 for all other supported branches (9.0, 10.0, 11.0, 14.x) there have been enhancement in the way RV component deployed through Dynamics 365 Business Central interacts with Custom Paper Sizes.
Below a short reference to 17.x Knowledge Base (KB) article and relevant entry
|
372707 |
Reports with paper setup that does not match default printer page size can print with incorrect scaling or orientation. |
Custom Paper Sizes are the bread and butter when designing report for label printing.
The things to know when dealing with RDLC Label report printing, then, are the following:
Before moving forward with the creation of a RDLC label Report, you have to know that RDLC output within this context will always be an image that will be sent to the label printer. Label printer driver acknowledge that this is an image and, as such, it will take its own time to render the image picture within the label.
In other words, labels will never be printed at the same speed as interacting with the printer driver.
Interacting directly with the printer would have the following benefits:
The drawback is that Interacting with printer driver would require the creation of a custom add-in (.NET or .NET with Azure Functions or JavaScript, etc.) that should be consumed client and/or server side.
Just to give an example, Zebra has a specific language called Zebra Programming Language (ZPL). Creating a TCP client port writer and a stream wrapper it might be possible to send printing commands all the way through the printer. No need to create any kind of RDLC report or smash your head when you have to accommodate for a new field printed in the label or, even worse, when customer decide to change paper label in favour of another format.
It happens that one day your customer would call you stating that everything is fine with the ERP except label printing. Everything was moved from an old Windows OS to a shiny brand new WS 2019 and the old label printer did not support the new GDI.
Be sure that you have the appropriate label printer driver in place that is targeted for that specific OS. Moreover, be sure to update the printer driver when needed.
If you decide to skip point 1. and go for label printing through RDLC Report, this is the milestone rule to follow.
One simple example. Let’s say that you are in need to print the following labels: 7.62 cm. x 5.08 cm. RDLC report must have the exact size and, obviously, also the report body must not exceed these dimensions. Below a simple example how this should be setup
And the equivalent settings in the Printer Driver must match and maintain the same paper size parameters.
Everything is working fine? Ok. Hold on, I have to deploy the latest CU.
Custom paper size calculation might rarely introduce breaking changes to your existing label report printings, overall considering the orientation (portrait or landscape).
Always test, test and test once again.
With a super vast plethora of different label printer and the equivalent wide ocean of exotic printer drivers, some paper format properties such as e.g. rotation (rotate 90, rotate 180, rotate X, etc.) has never been implemented within the printing algorithm hence if these are set in the printer driver they might lead to unpredictable printing results.
Always test, test and test once again.
Printing could be achieved in several different ways within Dynamics NAV / Dynamics 365 Business Central. Below I am just trying to summarize some of them:
Windows Client
Web Client
Background session
Once you have tested all the combination that suits you best (the ones used by your customer), you might then decide to create one or more ad hoc report used within each different action (if the experience is different, of course). Use OnAfterSubstituteReport event to check the CURRENTCLIENTTYPE and decide which report you are in need to run to guarantee the same experience as much as you could.
When enabling server side printing from the request page (click on Schedule option in the request page) or via task scheduler / web services then you better add these bullet points to your check list:
If you are exhausted and struggling in find out which are the different paper sizes that printer driver offers, you could download LINQPad6 and inspect printer driver collection.
string laser = "HP33B624 (HP Tango) (Copy 1)";
PrinterSettings printerSettings = new PrinterSettings { PrinterName = laser};
JsonSerializerOptions jsonOption = new JsonSerializerOptions();
jsonOption.MaxDepth = 128;
jsonOption.ReferenceHandler = ReferenceHandler.Preserve;
string jsonString = JsonSerializer.Serialize(printerSettings,jsonOption);
Console.Write(jsonString);
NOTE: you must change laser definition with the exact name of your printer (you can find it in the printer properties like the one shown below)
System.Drawing.Printing
System.Text.Json
System.Text.Json.Serialization
As shown below
This is the collection of printer settings. These typically includes:
Looking at paper sizes, you might inspect if there are 2 very similar ones (e.g. the same one but it changes the orientation, flipped by rotation) and decide how to proceed further.