Using .Net to extend Dynamics NAV’s report printing capabilities

One request we get regularly here at Technology Management is printing of terms and conditions with certain reports, but unfortunately Microsoft Dynamics NAV does not support anything like that out of the box.

You could print an extra report with the terms and conditions but what if the customer uses duplex printing and wants the terms on the back of each page? This would be very hard to do using standard Microsoft Dynamics NAV.

We looked at this issue and decided to use PDF printing in combination with .NET technology to modify the PDF file as required.

This now allows us to do such things as:-

· Add terms and conditions on the back of every page

· Insert one or more pages anywhere in the document

· Watermark all or specific pages

This opens the possibility of removing images from the dataset and adding them as a watermark after the document has been printed. Pre-printed paper is no longer required which can make the printing process a lot less complicated.

In our solution we can set up rules for each report to define how a report needs to be processed based on criteria such as Country/Region, Language, Customer, Supplier etc.

Our solution is based on a slightly modified version of PDF Clown which provides the functionality we use to modify the PDF files. The only issue with this library is that it uses NULL’s in some of its functions which C/AL cannot handle and using it directly from C/AL was very complicated and made the solution somewhat unstable. We solved this by writing a .NET wrapper library that sits in-between Microsoft Dynamics NAV and PDF Clown so it can translate function calls between the two and avoid compatibility issues. It also provides a simplified interface to the functionality that we require whilst hiding functionality that we don’t need.

The functionality is invoked from a report so that it can be printed/previewed as normal but produces a PDF file instead and uses an installed PDF viewer to print/view the end result. This avoids having to change the standard printing functionality in Microsoft Dynamics NAV and making changes throughout the system in every place where a report may be printed from.

Leave a Reply