Skip to main content

Navision Classic - Save Report in PDF File as User Defined Path.

Hi all,

Today Let's try to save a classic report in PDF format.

We need to use any third party tool (PDF Printer) which will be used to print report in PDF.

There are plenty of them if you search on the web. I will be using Bullzip Printer for Demo.

For Downloading Bullzip Printer follow the Link.

Download and Install the PDF Printer.

Make sure that during installation you install all the components. Please don't uncheck any of the option as shown below.

After installation Make this printer as system default printer.

For saving report as PDF, you can either Create a new Report / Codeunit.

I will be using codeunit for the demo purpose.

Agenda -

Provide a button on customer card, on click event the report should be saved in PDF as per path defined.

Basic Setup -

1) Path will be user defined.
  Create a new text field in User Setup table and add same to Form (Say - Path to Save Report).

User based on his requirement can specify the path where the PDF file should be saved.

2) Create a Codeunit which will save report in PDF.

  a) Create a function say - CheckSetup().
  b) Create a function say - CustomerStatement(CustNo : Code[20])

First function will be used to check the user setup and path for the report saving.

Second function will run Report Sales Statistics and save it into specified location using BULLZIP.

Function CustomerStatement have a parameter customer no. for which report should get executed.

As its a file related operation required we require a variable for 'Microsoft Scripting Runtime'.FileSystemObject.

As Report need to be save as PDF we need the automation variable of Bullzip.

Function CustomerStatement will -
1) check the user setup.
2) Get Customer.

3) initialize automation of File Variable & BullZip.
4) Check the path existence provided in user setup.
5) Create a file name.

6) Set parameters of Bullzip.

7) Run Report & Save.
8) Clear Bullzip and File.

Other parts are self explanatory except step 6.

In step 6, I have set parameter related to bullzip, that are loading settings, Set Filename, Hide progress bar, suppress error message and allow overwrite.

These parameters can be found in the variable created for bullzip.

Variables Created in codeunit-

BullZipPDF Automation 'Bullzip'.PDFPrinterSettings

UserSetup Record User Setup

Customer Record Customer

File1 Automation 'Microsoft Scripting Runtime'.FileSystemObject

Filename1 Text 250

RunOnceFile Text 250

SalesStat Report Sales Statistics

Now i have added a button in customer menu button where i called codeunit function.

Here is the output when i clicked on button for customer 1000.

I have kept the modified objects in my skydrive folder [Version 2009 R2].

File Name - Save Report in PDF (Classic Client)

Please keep backup of standard objects before importing.

We will see usages of this in future post.

Saurav Dhyani


Post a Comment

Popular posts from this blog

Welcome - Microsoft Dynamics 365!

Hi All, In this article we will discuss the new introduced member of Dynamics Family. Yes you heard it correctly, one more new member with Name "Microsoft Dynamics 365" . #ProjectMadeira   #Dynamics365

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

NAV 2013 Credential Type - How to Use?

Hi all, Please do these activities when you have time, its a long activity and i would suggest do all activities in one go. So be clam and lets start. For NAV 2013 R2 Refer Here. For NAV 2016 Steps have been Reduced Please Refer Here. I have installed NAV 2013 and its work great with my windows credentials. I was checking the service console (Microsoft Dynamics NAV Administration) in NAV 2013 and found out that Credentials Type have multiple Options.