This article describes different methods to save the Microsoft Excel and Word reports as PDF files by using the LabVIEW Report Generation Toolkit. It also proposes another alternative using a third-party add-on in LabVIEW.
This method uses ActiveX references and the ExportAsFixedFormat method to export a Word document or Excel worksheet as a PDF file. The example code is configured to open the PDF file immediately after created. If you do not want to open the PDF file, you can change the OpenAfterExport and OpenAfterPublish boolean constants to False. Note: this method does not work with HTML reports.
This method uses a third-party PDF printer software in combination with the Print Report VI from the LabVIEW Report Generation Toolkit to generate the PDF file. This method prompts the user to select the directory where the PDF file will be saved. Note: the example code requires the CutePDF Writer software, but can be modified to use similar tools.If you want to bypass the window where it asks for the user to set a path for the output PDF File we can get the references to the document being printed using the Word Get ActiveX References VI and then use an invoke node to set the output PDF file path. In this example, we set the Microsoft to PDF printer as the default one.
Another alternative is to use third-party add-ons in LabVIEW such as Custom PDF Generator for LabVIEW . Note: this product is supported by the third party and not by NI. For technical support, contact Simplicity AI.
https://www.ni.com/en-us/support/downloads/tools-network/download.labview-custom-pdf-generator.html The file, LabVIEW PDF Reports.zip, under the Attachments section contains the example code used in this article. To run the code, you need the LabVIEW Report Generation Toolkit and Microsoft Office installed on your computer.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.