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.

Regards,
Saurav Dhyani

Comments

Post a Comment

Popular posts from this blog

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 - 

MSDYN365BC - Data Upgrade To Microsoft Dynamics 365 Business Central on premises.

Hi Readers, We have already talked about the number of steps for upgrading to Business Central on Premises from different NAV versions. After that article, I received multiple requests for an article which list down steps for Data Migration. In this article, we will discuss steps of data migration to MSDYN365BC (on-Prem) from NAV 2017. For this article, I am considering a Cronus Demo Database without any customization. For an actual upgrade project, we will have to complete object merge using compare and Merge process. After the Merge Process, the next step is data migration. Let's discuss those steps. Direct Upgrade to Microsoft Dynamics 365 Business Central (on-Prem) is from following versions - 1. NAV 2015. 2. NAV 2016. 3. NAV 2017. 4. NAV 2018.