LogoLogo
v3.7.x
v3.7.x
  • Introduction
  • Concept
  • Prerequisites
  • Trust1Connector JS SDK
  • Changelog
  • Core
    • Setting up the SDK
    • Initialize Trust1Connector
    • Readers
    • Core Service
    • Downloading latest Trust1Connector
    • Consent
    • Authenticated client
    • Module/container setup
    • Status codes / error handeling
    • Quick-Migration Guide (v2 -> v3)
  • Token
    • Token typing models
    • Generic token
    • Belgian eID
    • Aventra MyEID PKI
    • Idemia Cosmo One v8.2
    • Oberthur Cosmo One v7.3
    • Diplad (BeLawyer)
    • Chambersign*
    • Camerfirma*
    • Certigna*
    • Certinomis*
    • Jcop3*
    • Airbus
    • Eherkenning
    • Safenet*
    • Luxembourg ID
    • LuxTrust
    • Other PKCS11 Compatible Tokens*
  • Payment
    • Payment typing models
    • EMV*
    • Crelan
  • FIle
    • File exchange
  • HSM
    • Remote loading
  • Other
    • Print
    • Wacom*
  • Miscellaneous
    • Prerequisites New Token/Smart Card
    • Prerequisites Support
    • Troubleshooting
      • Changing Device date/time
      • Enable Debug Logging
      • Connector Connection Issues
      • Mac OSX Sonoma
    • Installation FAQ
    • Removal of Trust1Connector
Powered by GitBook
On this page
  • Introduction
  • Interface
  • Model Objects
  • Get Printer module object
  • List
  • Print

Was this helpful?

Export as PDF
  1. Other

Print

Introduction

The Trust1Connector print module provides the integrator the ability to communicate with local printers. It provides an interface to retrieve the available printers and then execute a specific print job on one of those printers.

Interface

Below you can find the interface of the Trust1Connector print module.

export interface AbstractRawPrint {
    list( callback?: (error: T1CLibException, data: PrinterListResponse) => void): Promise<PrinterListResponse>;
    print(name: string, job: string, data: string, callback?: (error: T1CLibException, data: PrintResponse) => void): Promise<PrintResponse>;
}

Model Objects

Below you can find the available models for Trust1Connector print module which are used in the interface.

export class PrinterList {
    constructor(public printers: Array<string>) {}
}

export class PrinterListResponse extends T1CResponse {
    constructor(public data: PrinterList, public success: boolean) {
        super(success, data);
    }
}

export class Print {
    constructor(public printed: boolean) {}
}

export class PrintResponse extends T1CResponse {
    constructor(public data: Print, public success: boolean) {
        super(success, data);
    }
}

Get Printer module object

Before we can use the print module we need to Initialise the Trust1Connector. The code sample below is a simplified version, for the complete initialise flow you can see Integration in Web Applications

T1CSdk.T1CClient.initialize(config).then(res => {
    client = res;
}, err => {
    console.error(error)
});

After you've initialised the Trust1Connector you can use the client/response of the initialise function to instantiate the rawprint module. Later on we can keep using this module to execute various print functions provided by the Trust1Connector interface.

var print = client.rawprint();
function callback(err,data) {
    if(err){console.log("Error:",JSON.stringify(err, null, '  '));}
    else {console.log(JSON.stringify(data, null, '  '));}
}
print.list(callback);

List

The list function provides an iterator of all the available printers locally. These will return as identifiers that can be used when executing a print action as described in the Print function

client.rawprint().list(callback);

An example callback:

function callback(err,data) {
    if(err){
        console.log("Error:",JSON.stringify(err, null, '  '));
    }
    else {
        console.log(JSON.stringify(data, null, '  '));
    }
}

Response:

{
 "printers": ["123"],
}

Print

The Print function available on the interface provides print capabilities via the Trust1Connector. Here you need to specify the print job name, a name for the printer which can be fetched via the List function and the Data.

The data block needs to be base64 encoded.

const name = "test"
const job = "test-job-01"
const data = "SSdtIGRlZmluaXRseSBub3QgYSBNQUxBS0E="
client.rawprint().print(name, job, data, callback);

An example callback:

function callback(err,data) {
    if(err){
        console.log("Error:",JSON.stringify(err, null, '  '));
    }
    else {
        console.log(JSON.stringify(data, null, '  '));
    }
}

The print function will respond with a True or False depending on wether the command succeeded or failed.

{
 "printed": true/false,
}
PreviousRemote loadingNextWacom*

Last updated 2 years ago

Was this helpful?

In the example below we execute the list function available in the rawprint module. Here we use the callback mechanism but a is also available as defined in the interface

Promise