I have been using PDFCreator to create PDF documents from my NAV client. I am also using it with NAS (Nav Application Server) on my Windows 2003 32bit server. I needed to get this up an running on a 64bit Windows 2008 server and I ran into problems.
I could easily create the PDF documents from my client. I saw the pdf file appear in my file system and attached it to my record. But, when NAS was running the same job no files where created and the job failed. I unsuccessfully tried a few tricks but nothing changed. I decided to find another path and looked at bioPDF writer.
The result is a new single instance codeunit to handle the print of any report to a pdf file. Lets say that the user would like to be able to print and open a sales invoice in pdf format. Copy the function PrintRecords to PrintRecordsToPDF for table no. 112, Sales Invoice Header. Add two lines and you are done.
[code htmlscript=”false”]WITH SalesInvHeader DO BEGIN
bioPDFMgt.BeforeReportPrint(ReportSelection."Report ID"); // Dynamics.is
HYPERLINK(bioPDFMgt.AfterReportPrintGetFileName(ReportSelection."Report ID")); // Dynamics.is
UNTIL ReportSelection.NEXT = 0;
Where bioPDFMgt is a local variable for the BioPDF Management Codeunit.
The BioPDF Management Codeunit needs to be added to global variable in Codeunit 1, ApplicationManagement. Add to the FindPrinter function.
[code htmlscript=”false”]FindPrinter(ReportID : Integer) : Text
// Dynamics.is start
IF bioPDFMgt.PrinterBufferExists(ReportID) THEN
// Dynamics.is end
IF NOT PrinterSelection.GET(USERID,ReportID) THEN
IF NOT PrinterSelection.GET(”,ReportID) THEN
IF NOT PrinterSelection.GET(USERID,0) THEN
IF PrinterSelection.GET(”,0) THEN;
// Dynamics.is start
// Dynamics.is end
The BioPDF Management Codeunit includes these functions:
|BeforeReportPrint||Setup PDF printer and printer selection|
|AfterReportPrintGetBLOB||Copy the PDF file to a tempBLOB record|
|AfterReportPrintGetFileName||Return the PDF file name|
|CleanUp||Clear PDF automation objects|
|ConfirmFileExists||Return an error if file does not exist|
|FileExists||Return a boolean value for given file name|
|FileRename||Rename a file (copy and delete combined)|
|FileErase||Delete a file|
|FileCopy||Copy a file|
|ClearPrinterBuffer||Clear the printer selection buffer|
|CreatePrinterBuffer||Adds a report and a printer name to the printer selection buffer|
|PrinterBufferExists||Check if a printer selection buffer exists for given report|
|GetPrinterName||Get the printer name from the printer selection buffer|
|SaveLastPrinter||Save the name of the last printer used|
|GetLastPrinter||Get the name of the last printer used|
BioPDF Management Codeunit (2009 R2)
17 Replies to “bioPDF writer”
hi Gunnar. Thaks for greate aricle. But i have one question: is bioPDF freeware for commercial use (PDFCreator is)?
BioPDF is a professional and paid version of BullZip pdf writer. This code should also work with BullZip pdf writer. Please refer to Biopdf.com for more information
Hi Gunnar. Could we use this codeunit under Navision 5 SP1? I have a problem when i am trying to execute printing fuctionality (invoke PrintRecordsToPDF) in my NAV 5.0 SP1. Client crashed without any information about reason.
Also, client crashed when i am trying to push Design button on codeunit 50105.
Did you try to import the text version of the codeunit?
Main problem is that there is no CU 419 in Navision 5 SP1.
Try this attached text file and let me know if this works for 5 SP1.
Hi, i have the following compilation error with new CU: https://dl.dropbox.com/u/5753358/compile_error_50105.png .
OK. I checked this CodeUnit under Navision 2009 R2 everything works fine.
If this is of value to you, please check my Copyright page.
I am at home for today and I made a compiled version for 5 SP1 and added it to the original post.
Gunnar, did you get bioPDF up and running with the NAV JobQueue? In NAV 2009 R2, I have tried and have a test codeunit that I can run that generates a PDF using the bioPDF COM interface, but when I run that same codeunit in the job queue, there are no errors, but no file is generated. Do you have a code sample that ran successfully in the job queue?
Here is an example that I use to create PDF attachments for all posted sales invoices and -credit memos.
This trick is working great in the classic client. In my opinion it is not working in the RTC.
A singleinstance is working in the RTC but not when it is used through codeunit 1.
Maybe I’m doing something wrong. I’m not getting it to work.
You should just use SAVEASPDF in the RTC client and in newer versions of NAV.
This is not the solution for me because I use PDF background.
I have just found what is the problem.
Because we have not created RDLC-layouts for our custom reports the classic client is started from the RTC. This is another client so the SingleInstance does not work.
Thanks for your quick respons.
Of cource Elwin. Good call.