Overview
This document provides an instructional guide on how to print PDFs within the server domain using the TPrintPDF.exe utility. It explains how to automate PDF printing in server scripts by creating a new process, triggered via a method in the ServerMain class, as shown in the attached exampleexample show how to access TagProperties from CodeBehind.
On this page:
Table of Contents | ||||
---|---|---|---|---|
|
Get DataRows method
The key for this is implementation is the method, which gets the the children from any folder as DataRow[], with each property in a column
What is the DataAccess API?
TPrintPDF is a module that handles the output of PDF documents during runtime. It integrates with applications to automate the process of sending PDFs to a printer without manual steps, streamlining the workflow within the runtime environment.
Module Requirements and Usage Instructions
The module requires the inclusion of System.Diagnostics in the namespace declarations, as it will be invoked using the Process method.
To use the utility, three parameters must be set: the file path for the PDF location, the printer to be used, and the page orientation. The page orientation options are 0 for the default setting, 1 for Portrait, and 2 for Landscape. If no value is provided for the page orientation, it defaults to 0.
Note: Regarding the printer name, you can locate it by searching for "Printers & Scanners" in Windows.
Once the setup is complete, pass the necessary information to a new Process as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
DataTable table ProcessStartInfo startInfo = new ProcessStartInfo { FileName = fileExec, Arguments = arguments, }; |
Here, FileName is the path to the module, with the default location in the FrameworX folder, accessible via:
Path.Combine(@Info.Product.GetProductPath(), "TPrintPDF.exe");
The Arguments parameter includes the PDF file path, printer name, and orientation, formatted as:
"c:/ExamplePath/Example.pdf" "Printer 1" 1
It then attempts to initiate a new process using the specified startInfo, waiting for the process to complete before continuing execution. The Using statement ensures that all resources associated with the process are properly disposed of after it finishes running.
Sample Method Implementation
The method implemented below demonstrates a standard application of the TPrintPDF utility. It can be invoked from any location, allowing the caller to customize the file path, printer name, and orientation as needed for each specific instance.
DataTable("Table1");
table.Columns.Add("Name", typeof(string));
table.Columns.Add("TypeName", typeof(string));
// This call will get all tags from the root folder
// In order to get tags from other folders, or domains, modify the paremeters of GetChildren Methods
DataRow[] rows = TK.GetTagChildrenAsDataRow();
// just fore verification
int j = rows.Length;
foreach (DataRow row in rows)
{
// In this example, we are getting only the Name and Type, all columns from UnsTas tables can be accessed using this method
string name = TK.ToText(row["Name"]);
int type = TK.ToInt(row["Type"]);
string typeName = await TK.GetElementTypeAsync(name);
table.Rows.Add(name, typeName);
}//foreach
|
Solution Example
Download example: GetTagProperties.dblsn
In this section...
Page Tree | ||||
---|---|---|---|---|
|