LabWindows/CVI User Group Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Printing PDF files from LabWindows.

One of the major issues with NIReport is that it does not save the information to a file.  A way around this issue is to print the report using NIReport_Print and point to the Adobe PDF printer that is installed with Adobe Acrobat.

Printing to the Adobe PDF opens a "File Save" dialog box where you can enter the filename.  This works unless your are trying to do automated tests and don't want the operator to have to create a new name each time.

Below is a code segment for automating the "File Save" by creating a key in the registry.  The report is created using the normal NIReport functions.

/* create test application name, must have path information */

   sprintf(caTestApplicationWithPathInfo, "%s\\myapplicationname.exe", TEST_DIRECTORY);  

/* create filename with path information from serial number, date and time */

   sprintf(caFilenameWithPathInfo, "%s\\%s_%s_%s.pdf",  TEST_DIRECTORY, caSerialNumber, caDate, caTime);   

 

/* create a key in the Current User using the application and filename. */

/* this key is created each time and is destroy by Adobe PDF printer when it prints */

   RegWriteString(REGKEY_HKCU, "Software\\Adobe\\Acrobat Distiller\\PrinterJobControl", caTestApplicationWithPathInfo, caFilenameWithPathInfo); 

/* now print the report */

   NIReport_Print(iReportHandle, "adobe pdf", 1);

This creates a file in the test directory without the operator entering any data.

Two gotchas:

1. The directory TEST_DIRECTORY must already exist and the user must have read/write access.

2. The pdf file can not exist, an error occurs if you try to overwrite an existing file.

Paul

0 Kudos
Message 1 of 3
(4,983 Views)

We have been using the BullZip PDF printer for this purpose for a while and we are quite happy with it.

It is free. Only drawback is you need to install GhostScript as well.

You do not have to play with Windows registry, it is possible to automate it over ActiveX.

You can configure many properties, like overwriting files, display file save popup, etc.

We are using the free version of Foxit as the PDF reader.

We find Adobe bulky and slow. It also installs updaters running in the background, which is unwanted for test stations.

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 3
(3,523 Views)

I agree there are many different ways to accomplish this.  I can't download free software, only IT is allowed and then it has to be a standard piece of software.  Gets ugly in a big company requesting non-standard software.

NIReport doesn't work very well with Adobe's ActiveX software, I spend 3 days trying.  This was the simpliest way of using Adobe.

Paul

0 Kudos
Message 3 of 3
(3,523 Views)