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.
1. Using ActiveX References
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.
2. Using PDF Printer Software
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.
3. Using LabVIEW Add-Ons
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.