Printer C++

Namespaces

 dpyPrinter
 Deepsy Printer namespace that includes the different enums, structs or method signatures that should be used.
 

Classes

class  PrinterManager
 Allows to interact with Printer Service. More...
 
class  JobObserver
 Job Observer class. More...
 
class  Job
 Represents a Job in the printer queue. More...
 
class  PrinterObserver
 Printer Observer class. More...
 
class  IPrinter
 Abstract class which implements all the minimum necessary logic which all printer must have. More...
 

Detailed Description

Printer API related documentation

A quick overview of basic Printer API capabilities and examples is given.
If you find Printer API useful and would like to know more details, please check out further sections of the Printer API documentation or contact the Deepsy platform team.

Examples

  • Creating a PrinterManager object

    #include <dpy/printerApi.h>
    PrinterManager printerManager;


  • Add print job

    #include <dpy/printerApi.h>
    void print_image_handler(boost::system::error_code error_code, int jobid)
    {
    if (error_code != 0) {
    std::cout << "\rError : " << error_code.message() << std::endl;
    } else {
    std::cout << "\rAsynchronous operation forwarded successfully" << std::endl;
    std::cout << "Print job ID : " << jobid << std::endl;
    }
    }
    int main(int argc, char *argv[])
    {
    PrinterManager printerManager;
    printer.asyncAddPrintJob(print_image_handler, "1", "ticket.jpg");
    return 0;
    }


  • Set paper width
    The set paper width configuration message is provided by filling a paper width parameter. An example on how to set paper width is provided:

    #include <dpy/printerApi.h>
    void result_handler(boost::system::error_code error_code)
    {
    printf("result = %d, %s\n", error_code.value(), error_code.message().c_str());
    }
    int main(int argc, char *argv[])
    {
    PrinterManager printerManager;
    printerManager.asyncSetConfig(result_handler, "1", PrintConfig(PAPER_WIDTH, 50));
    return 0;
    }


  • Set ticket offset
    The set printer offset configuration message is provided by filling a ticket offset parameter. An example on how to set ticket offset is provided:

    #include <dpy/printerApi.h>
    void result_handler(boost::system::error_code error_code)
    {
    printf("result = %d, %s\n", error_code.value(), error_code.message().c_str());
    }
    int main(int argc, char *argv[])
    {
    PrinterManager printerManager;
    printerManager.asyncSetConfig(result_handler, "1", PrintConfig(TICKET_OFFSET, 50));
    return 0;
    }


  • Print a self-test ticket
    An example on how to print a self-test ticket is provided:

    #include <dpy/printerApi.h>
    void result_handler(boost::system::error_code error_code)
    {
    printf("result = %d, %s\n", error_code.value(), error_code.message().c_str());
    }
    int main(int argc, char *argv[])
    {
    PrinterManager printerManager;
    printerManager.asyncPrintTestTicket(result_handler,"1");
    return 0;
    }