Links

Remote Printing SDK for Thinfinity - Delphi

Delphi

Objective

The Remote Printing SDK allows you to programmatically send commands and documents to the end-user’s printer. Currently, raw printers are supported.
The following table shows the methods of the Remote Printer SDK.

Components

Remote Printer SDK Library
Thinfinity.RemotePrinter.dll
This module presents an COM API to be consumed by a Windows application running under Thinfinity VirtualUI or Thinfinity Remote Desktop.
Thinfinity Local Agent and Local Printer Plugin
Executable and library needed to work as a nexus between the web browser and local or network resources, otherwise inaccessible due to browser’s security restrictions.
Thinfinity Virtual Channels
A proprietary Virtual Channel System used to communicate the Remote Printer SDK with the Local Printer plugin.

Basic Scheme

The Remote Printer SDK tasks:
  1. 1.
    Retrieve the printer list.
  2. 2.
    Prepare the connection for printing.
  3. 3.
    Send data to the printer
  4. 4.
    Inform the end of the printing process.
  5. 5.
    In case of any error must be Cancel the printing or if the user wants.
  6. 6.
    In case of any error, can get it more details using LastError method

API

The following table shows the methods of the Remote Printer SDK.
Methods
GetPrinters
GetPrinters(const Delimiter: WideString; out Printers: WideString): WordBool;
Retrieve all printer names detected on the end-user's side. Returns a string delimited by the Delimiter parameter. Returns: True if is successful and False in case of error.

Parameters

Delimiter
Printers (out)
WideString - Character or string used as delimiter of the printer names on Printers param.
WideString - Out parameter filled with the printer names delimited by Delimiter param
LastError
LastError(out ErrorCode: Integer; out ErrorMessage: WideString);
Retrieves the last ErrorCode and ErrorMessage. Can be used when a call to any method returns False. Returns: nothing

Parameters

ErrorCode (out)
ErrorMessage (out)
Integer - Out last error code. If ErrorCode is 0, there is not error
WideString - Out last error message.
BeginDoc
BeginDoc(PrintType: Integer; const PrinterName: WideString; const DocName: WideString; Encoding: Integer; out DocID: WideString): WordBool;
It makes the connection with the printer and initializes the print job. Creates an unique Document Id to identify a print job in subsequent calls. Returns: True if the communication and actions on the selected printer was sent successful.

Parameters

PrintType
PrinterName
DocName
Encoding
DocID (out)
Integer - Determines the type of priting. Now support PRINT_TYPE_RAW = 1
WideString - The name that identifies the printer.
WideString - Name of the printer job to be created on the print spooler.
Integer - Identifies the format of the document to print.
PRINT_ENCODE_ANSI = 0
PRINT_ENCODE_UTF8 = 1
WideString - This out parameter is filled with a unique document id to be used in subsequent calls.
Print
Print(const DocID: WideString; const Data: WideString): WordBool;
Sends data to the printer using the document identifier obtained using BeginDoc..
This method can be called as many times as needed to send commands or data until the entire print job is completed. Returns: True if nothing went wrong.

Parameters

DocID
Data
WideString - The document identifier obtained by BeginDoc
WideString - Data to be sent to the Printer.
EndDoc
EndDoc(const DocID: WideString): WordBool
Ends the print job. This completes the print process and sends the print job to the spooler. Returns: True if the work was sent to the printer spooler.

Parameters

DocID
WideString - The document identifier obtained by BeginDoc
Abort
Abort(const DocID: WideString): WordBool
Cancels the printer job.
This method must be called in case of the methods Print or EndDoc return False.

Parameters

DocID
WideString - The document identifier obtained by BeginDoc
PrintFile
PrintFile(PrintType: Integer; const FileName: WideString; const PrinterName: WideString): WordBool;
Sends the file to the print spooler of the remote printer. In case of PrinterName is Empty the default remote printer is used.

Parameters

PrintType
FileName
PrinterName
Integer - Determines the type of printing.
Now support:
PRINT_TYPE_XPS = 3
PRINT_TYPE_PDF = 4
PRINT_TYPE_DIRECT = 5
WideString - Full FileName of the file to Print.
WideString - The name that identifies the printer.