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

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

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 -