- Last UpdatedOct 29, 2026
- 2 minute read
Print prints the contents of a specified text file.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
|
File |
Asynchronous |
No |
Supported |
Supported |
Not supported |
Supported |
Not supported |
Syntax
Print(strFilePath,optNumOrientation)
strFilePath
The file path and name of the text file to be printed.
Note: Follow the conventions of the target platform for the file path and name, and separators. For example, a file path in Windows starts with a drive letter and uses backward slashes as separators (C:\path\to\file), while a file path in Linux starts at the root directory and uses forward slashes as separators (/path/to/file).
optNumOrientation
A numeric value that indicates the paper orientation:
|
Value |
Description |
|---|---|
|
0 |
Portrait |
|
1 |
Landscape |
This parameter is optional; if no value is specified, the default value is 0.
Note: This parameter is not supported when the project is running on a Windows Embedded target system.
Return value
This function returns one of the following possible values:
|
Value |
Description |
|---|---|
|
0 |
Invalid parameter(s). |
|
1 |
Valid parameters. |
Note:
This function checks whether the specified parameters are valid before it tries to use those parameters to print the file. However, the return value does not indicate whether the file is successfully printed. To determine that, view the print queue in Windows.
Notes
This function can only be used to print the contents of text files. It cannot be used to print information in any other format, such as pictures, binary files, etc.
This function is based on legacy code, which means it cannot use printer settings that were previously configured by the PrintSetup function. Instead, it always uses the default printer on the computer or device that hosts the project runtime. You can use VBScript in your project to change the default printer in Windows; for example:
Dim WSHNetwork Set WSHNetwork = CreateObject("WScript.Network") WSHNetwork.SetDefaultPrinter "<printer name>" Set WSHNetwork = Nothing
Examples
Print the contents of ReadMe.txt in portrait mode:
Print("C:\ReadMe.txt")
Print the contents of the file specified by the MyTextFile tag, in landscape mode:
Print(MyTextFile,1)