Example Code

TestStand Model Plug-in: Printing Reports and Generating PDF Reports

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Teststand

Code and Documents

Attachment

Description

Overview

 This example plug-in allows you to automatically print your test reports after they are generated, or create a PDF of each generated reports.  

 

Description

 After generating a test report, it is a common requirement to print a hard copy of the report or generate a single file version of the report, such as a PDF, for archival.  This example plug-in provides these functions and can be used to process reports generated by the default or modified versions of the report generation plug-in.  It can also be modified to process reports generated by custom plug-ins.

 

General Functionality

In order to obtain all generated reports, the plug-in uses the Parameters.ModelPluginConfiguration property in the Model Plugin - UUT Done callback sequence.  This property contains an array of all active plug-in instances, allowing the print plug-in to find all active report generators.  The plug-in iterates through specific runtime variables to obtain all report objects managed by the plugin (Refer to the code for specific details).  Before converting a report, the plug-in uses the MSXML library to render XML reports into HTML.

 

Generating PDFs

The plug-in utilizes the wkhtmltopdf.exe PDF converter to process report files.  A version of this tool is included with the plug-in, and later versions can be downloaded at https://wkhtmltopdf.org/.  If you download another version, you can replace the included .exe file with the downloaded one.

 

Known Issues

  • the wkhtmltopdf.exe converter cannot generate images from the TestStand graph control displayed in reports and displays tabular results instead.

Printing Reports

The plug-in uses a webBrowser .NET control to print the report files.  Based on the plug-in options, the print command will use the default printer or prompt the user to select a printer for each report.

 

Legacy Example (TestStand 2010 and previous)

For TestStand versions earlier than TestStand 2012 that do not support plug-ins, use the legacy example.  This example provides a sequence file containing two sequences that first converts an XML report to an HTML file, if necessary.  It then uses the Internet Explorer ActiveX server to print the HTML report.  This pair of sequences will print all four types of TestStand reports and is configurable to only print when desired.  These sequences have been designed with modularity in mind so that they should be able to be taken in their current form and placed in any process model that generates test reports

 

Hardware and Software Requirements

Print Report Plug-in - TS2012.zip

TestStand 2012 SP1 or compatible

(recommended for viewing source code) Microsoft Visual Studio 2010 or compatible

 

PrintingSupport - TS4_2.zip

TestStand 4.2.1 or Compatible

LabVIEW 2009 or Compatible

 

Steps to Implement or Execute Code

  1.  To install the plug-in, extract the contents of the zip archive to the following location:
    <TestStand Public>\Components\models\modelPlugins
  2. To enable the plug-in, Open the Sequence Editor and select Configure » Result Processing...
  3. Click the Insert New button, and select the Print Report Plugin.
  4. Click the settings button for the plug-in instance to configure the settings.
 

Additional Information

Starting with TestStand 2019, there is an option to generate a PDF report. For more information, refer to the TestStand Help Topic: PDF Report Generation.

Al B.
Staff Software Engineer - TestStand
CTA/CLD

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
BroxSoft
Member
Member
on

In TestStand 2014 I don't see "Print Report Plugin" when clicking Insert New. I have:

 

Generate Report

Log to Database

Store Results for Offline Processing