Rashed Amini

The ara3n weblog

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

25 Responses to “Save Nav Reports to PDF”

  1. Luc Van Dyck Says:

    When the code is executed by the NAS, it seems the RunOnceFile is not deleted.


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

    I see in the logs that the NAS is always waiting for 30 seconds. And on the NAS server, the RunOnceFile is not removed. These files exists in 2 locations:
    C:\Documents and Settings\NASUser\Application Data\Bullzip\PDF Printer\runonce@Bullzip PDF Printer.ini
    C:\Documents and Settings\NASUser\Bullzip\PDF Printer\runonce@Bullzip PDF Printer.ini

    Is this normal behaviour?

  2. Stephen Abela Says:

    Hi,

    First of all well done for this pdf creator it’s really good. Is it possible to add a pdf background? I know this is possble manually, can it be done automatically as well?

    Best Regards,

    Steve

  3. Roberto Says:

    Hey, do you know how determine the page size using bullzip?, I need a diferent size for two reports to print in the same printer. Thank’s.
    Regards, Roberto

  4. ara3n Says:

    I haven’t looked at page size, you can search bullzip forums.

  5. gerdhuebner Says:

    Concerning image background and other “musthaves” there are other nice freeware solutions:
    FreePDF: allows background images and you can automatically open a mail client with the attached file)
    qvPDF: additionally allows control sequences to submit the mail address, subject, etc., e.g.

  6. LibertyMountain Says:

    with BullZip can you programmatically make BullzipPDF the default printer, print your report, then change the default printer back to what the user had originally?

  7. ara3n Says:

    I don’t think you can, but you can use NAV report selection to setup the report to print to specific printer.

  8. Maarten Says:

    Bullzip needs a lot of time to initialize. More than a minute.
    It seems that the following code line is causing the problem.
    BullZipPDF.LoadSettings;

    Anyone else with the same experience?

  9. andre Says:

    hi Rashed, first of all..
    thks for the article. works nicely.

    and i want to ask, is it possible to add the digital signature in the code?
    where can i find the documentation?

    thks :D

  10. Ted Johnston Says:

    Just wanted to point out the BullZip is only free for up to 10 users. If you have more, you have to purchase the commercial product.

  11. yuppicide Says:

    Someone pointed me here from the forums. Great article. Bullzip is much better than CutePDF. So many more options!

  12. mar Says:

    still cannot figure out nav job queue. new at NAV. i installed NAS and created a job queue to run report aged receivable. nothing happends gives me error. basically what i want to do is end of the month i want to run aged receivable and aged payable and print to pdf automatically and save it somewhere on the server. can someone tell me the steps please.

  13. ara3n Says:

    I suggest to post the question on www.mibuso.com/forum you’ll get your answers. All Job queue is that it run your object at certain time. as far as saving report to a folder or somewhere, Job queue will not do that. You have to write the code to do it.

  14. Buffer Says:

    Thank you sir for this wonderful contribution.

    Are there known issues with Bullzip, navision and windows 7?

    I’ve tried this in Windows XP and everything worked fine. I have recently upgraded my machine to Windows 7, and now the code doesn’t create the PDF File to the folder that i’ve specified.

    Do I need to tweak something in the code to make this work? I’m running it on Nav 4.00 SP3.

  15. ara3n Says:

    I haven’t tried it on a windows 7 yet. I am still running windows xp.
    Take a look at this page for registry settings on where the runonce.ini file is created and see where the file is created.

    http://www.biopdf.com/guide/configuration_files.php

  16. systemali Says:

    Can some one please explain how do i accomplish this step :–

    —————————————
    Import the form.txt file into NAV and compile it and run it
    —————————————

    Where do i import this file to ? and how do i compile it and how do i run it.

    My apologies for the noob query :D

  17. ara3n Says:

    In Dynamics NAV. Click on Tools->object designer. A new window will open up with list of all object make sure you don’t have the object in your existing database if you do, change it form.txt file to a different number.

    Once the Object desinger is opened, Click on File->Import. Select the txt file. Once the file is imported, find the object in object designer and click on F11. this will compile the object. Then Run the object.

  18. systemali Says:

    Thank you for the prompt response, BUT what is the OBJECT that i should look out for so that it does not exist ?

    Thank you once again.

  19. marco polleschi Says:

    in actual version of Bullzip (7.x) , GetSettingsFileName does not exists…

  20. Rani Shoura Says:

    Hi Rashed,

    I have the code above running after modification on NSA, as Luc said the runonce is not getting deleted and in my case I’m not getting the PDF out, what is happening is I can see the PS file in a temp location, but never converted to PDF!!! Any Advice?

    Regards

  21. ara3n Says:

    Make sure the NAS user is local admin. Also what OS are you running this on?

  22. Rani Shoura Says:

    It’s a windows 2003 server SP2, and I had added the NAV sys to local admin, and it worked.

    Thanks a lot

  23. ara3n Says:

    You are welcome.

  24. Nanda Kumar Says:

    how can we add the setting of PDFCreator through *.ini files

  25. ara3n Says:

    This blog is about bullzip. I suggest to post the question on mibuso forum or pdfcreator forum.
    The settings are done through the pdfcreator dll file.

Leave a Reply

You must be logged in to post a comment.