There are several ways to programmatically print a front panel control. Listed below are a few good methods:
Use the Report Generation VIs to generate and print a report
- From the Report Generation palette, place the New Report.vi on the block diagram.
- Next, place the Append Control Image to Report.vi on the block diagram.
- From the block diagram, right click on your control and select Create»Reference. Attach this reference to the "Ctrl Reference" input of the Append Control Image to Report.vi.
- Place the Print Report.vi on the block diagram.
- Place the Dispose Report.vi on the block diagram.
- Connect the VIs as indicated in the PrintGraph.llb attached below (Note: Open the respective PrintGraph.llb depending on whether or not you have the Report Generation Toolkit installed).
Write image to a file and print
- From the block diagram, right-click on the control and select Create»Invoke Node. Select the "Get Image" method.
- Place the Write JPEG File.vi on the block diagram and wire the "image data" output of the Invoke Node to the "image data" input of the Write JPEG File.vi (Note that other file formats, such as Bitmap and PNG, would also work here).
- Place the System Exec.vi from the Communications palette on the block diagram, and wire in a command to print the file. (Sending the string "mspaint.exe /p [jpeg file path]" will open the file in mspaint and print it). See the Printing Front Panel Objects in LabVIEW (6.1) example program (linked below) for an illustration of how this works.
Pass a control to a subVI and print the subVI. This method will print the control along with a front panel image
- Create a subVI with a graph on its front panel.
- Change the graph from an indicator to a control.
- Open the subVI and select Operate»Print at Completion.
- Assign the subVI a connector and pass the data from the graph on the main VI to the graph on the subVI. Every time your main VI calls the subVI, the subVI automatically prints the graph.
Note: These directions assume that you are using a graph, but other controls may also be used.