Print RDLC report from Classic Client

When you read the title, you might want to ask yourself .. why the hell would I want to do that??

Well, the are a number of reasons to do that.. :

  • You want to print to PDF using NAS because you don't know .NET, and you never heared of "Windows Task Schedular";
  • You're upgrading to the RTC and follow the advice of Microsoft to go live role-by-role. So you have a mixed environment. In some occasions, reports are shared between departements, so sometimes a report is printed from RTC, but sometimes, it needs to be printed from classic..
  • You're working mixed mode, have a report for RTC, but want to print that same report from classic client
  • ...

Believe me, there are scenario's, and here I try to deliver you a solution on how to do it..

To print an RDLC report, you have to make sure your code is run on the service tier. There are only two pieces of software that can run on the service tier: RTC and web services. We're NOT working with RTC, so I guess we'll have to use web services, right? And we CAN use web services in the current development environment, so all should be fine.

In fact, Freddy showed us "How to Connect to NAV Web Services from NAV". So I decided to just go from there.

It's not so easy and straight forward to use web services in NAV (.NET Interoperability in R2 sure will help us there...finally :-)), but I must admit .. it only took about 30 minutes to create this little demo.. and that was it. Thanks to Freddy .. again ;°).

Why? Well, the only thing I had to do is create a "save as pdf" routine and publish that as a web service. That routine looks like:

GenerateReport() : Text[250]
ltxtFileName := 'C:\TEMP\';
ltxtFileName += FORMAT(CREATEGUID());
ltxtFileName := DELCHR(ltxtFileName,'=','.');
ltxtFileName += '.pdf';

Not very exciting, is it? Well, it's the idea that counts .. I hope ... . This codeunit, I published as a Web Service:

And then, I started to rebuild Freddy's codeunit to be able to call this web service... . There was not much to rebuild.

  • I deleted to redundant code which would not be used in my services. (I kept (off course) the InvoiceNavWS function .. THAT I need ! :-) )
  • I created an URL and NameSpace to my own web services ..
  • I created a PDFCreateService-function like Freddy's function:

    PDFCreateService(VAR nodeList : Automation "'Microsoft XML, v6.0'.IXMLDOMNodeList") result : Boolean
    result := InvokeNavWS(PDFCreateServiceURL, 'GenerateReport', PDFCreateServiceNS, 'return_value', '', nodeList);

  • Finally, some test-code in the OnRun trigger (supposed to be used as NAS) and I was good to go.

    IF PDFCreateService(nodeList) THEN

    Or in pseudo: if I succeed running the PDF-routine, then show me my PDF-Document.

So .. hope it's useful. I didn't put any effort in "decent coding". I also want to say that the code is "as is" .. not supported, not fully tested ... you know .. all the Microsoft-official-I-am-not-responsible-mumbo-jumbo ;°) .. just wanted to share the idea ... and the objects, which you can download here.


Comment List
  • Hi,

    The Webservice is running on the service tier .. which means it's going to save on the NAV Server as well.  This is normal behaviour which you have to manage (save it to a network folder and hyperlink that, for example).. .

  • Hi

    I believe I have the same issue as Luna.

    On the client (not the NAV app server) where I run the CDU, I get an error message "C/SIDE Hyperlinking failed", it then gives me the path to the PDF, except the PDF has now been created but on the NAV server. Not the client!

    How do I fix this?

    Another question: how can I set the report to run as a variable so I can use it multiple times for different reports?



  • Seems you're having installation issues – delegation/SPN not correctly installed.  

    Or isn't it a security issue?

    as the webservice is Always going to produce the PDF .. it shouldn't be any different running on either the local machine or not :-/

  • Hi Waldo,

    If I run this on same machine as the webservice it works great but if I run it from a client machine service tier seems to struggle with the creating the PDF.  Any ideas?