Rashed Amini

The ara3n weblog

Archive for August, 2008

Save Nav Reports to PDF

1st August 2008

A while back I wrote an example on how to save Navision reports automatically to pdf files using PDFCreator. PDFCreator isn’t really well supported on Vista and in 64 bit environment.
Some people have also reported problems using PDFCreator.

So this blog is about a second solution. I’m using for this exampel BullZip. Which is a freeware.

Here are some of BullZip feature.

Print to PDF from almost any Windows program.
Runs on Microsoft Windows 2000/XP/XP x64/2003/2003 x64/Vista/Vista x64/2008.
Supports 64-bit operating systems.
Direct output to the same file each time or prompt for destination.

Here is example Form. I’ve coded. BullZip.

Here is the function

PROCEDURE PrintToBullZip@1000000000();
BEGIN
IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);

ReportID := REPORT::"Customer - List";
FileDirectory := 'C:\';

Window.OPEN('processing Cusomer ######################1##');

Object.GET(Object.Type::Report,'',ReportID);

IF Customer.FINDSET THEN REPEAT
Window.UPDATE(1,Customer."No.");
FileName := Customer."No." + '.pdf';
BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue('Output',FileDirectory+FileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);
Customer2 := Customer;
Customer2.SETRECFILTER;
REPORT.RUNMODAL(ReportID,FALSE,FALSE,Customer2);

TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
SLEEP(1000);
TimeOut := TimeOut + 1;
END;

UNTIL Customer.NEXT = 0;

Window.CLOSE;
END;

Make sure you set Bullzip as default printer, or set it up in Printer Selection for the user or report.
Download Bullzip PDF Printer and install it. Import the form.txt file into NAV and compile it and run it. The example will loop through customers and create one pdf document per customer.
Here is the Bullzip link

Posted in Dynamics NAV | 25 Comments »