prt.h
Last updated: 17-Sep-2025
Go to the documentation of this file.
1Â /********************************************************** 2Â Copyright: Verifone GmbH 2013 3Â 4Â Entity: HTML Printer 5Â Filename: prt.h 6Â Date: May 2013 7Â 8Â **********************************************************/ 9Â #ifndef PRINTER_IF_H_20130513 10Â #define PRINTER_IF_H_20130513 11Â 17Â #include <stdarg.h> 18Â #include "types.h" 19Â #include <vector> 20Â 21Â #if defined _WIN32 && defined VFI_GUIPRT_SHARED_EXPORT 22Â # define DllSpec __declspec(dllexport) 23Â #elif defined __GNUC__ && defined VFI_GUIPRT_SHARED_EXPORT 24Â # define DllSpec __attribute__((visibility ("default"))) 25Â #else 26Â # define DllSpec 27Â #endif 28Â 29Â #ifndef DOXYGEN 30Â namespace vfihtml {} 31Â namespace vfiprt { 32Â #endif 33Â 34Â #if 0 35Â } // just to satisfy automatic indentation of the editor 36Â #endif 37Â 38Â using namespace vfihtml; // import common interfaces 39Â 41Â enum PrtError 42Â { 43Â PRT_OK = 0, 44Â // error codes from RawPrinter 45Â PRT_BUSY = -1, 46Â PRT_PAPERJAM = -2, 47Â PRT_HEADOPEN = -3, 48Â PRT_PAPEREND = -4, 49Â PRT_OVERHEAT = -5, 50Â PRT_OVERVOLTAGE = -6, 51Â PRT_UNDERVOLTAGE = -7, 52Â PRT_FAIL = -8, 53Â PRT_SCRIPT_ERROR = -9, 54Â PRT_NO_PRINTER = -10, 55Â PRT_BATTERY = -11, 56Â PRT_UNSUPPORTED = -20, 58Â // additional error codes 59Â PRT_INVALID_PARAM = -21, 60Â PRT_NO_RESOURCE = -22, 61Â PRT_FILE_NOT_FOUND = -23, 62Â PRT_PROTOCOL = -24, 64Â // transient error codes 65Â PRT_FINAL_RESULT =- 40, 66Â PRT_TIMEOUT = -41 67Â }; 68Â 69Â inline bool prtFinalResult(int x) { return x>PRT_FINAL_RESULT; } 70Â 71Â 72Â enum PrtMode { 73Â PRT_PREFER_GRAPHICS, PRT_PREFER_TEXT 74Â }; 75Â 77Â enum PrtPropertyInt { 78Â PRT_PROP_STATE=0, 79Â PRT_PROP_HEAD_TEMP, 80Â PRT_PROP_HEAD_VOLTAGE, 81Â PRT_PROP_PIXEL_WIDTH, 82Â PRT_PROP_CONTRAST, 83Â PRT_PROP_DEFAULT_FONT_SIZE, 84Â PRT_PROP_PRINT_MODE, 85Â PRT_PROP_JS_QUOTA_SIZE 87Â }; 88Â 90Â enum PrtPropertyString { 91Â PRT_PROP_RESOURCE_PATH, 92Â PRT_PROP_FILE_PREFIX, 94Â PRT_PROP_DEFAULT_FONT, 95Â PRT_PROP_CSS, 96Â PRT_PROP_INIFILE, 98Â PRT_PROP_JS_ROOT, 101Â PRT_PROP_DEVICE, 103Â PRT_PROP_JS_QUOTA_ROOT, 104Â PRT_PROP_CP_APP_DIR 106Â }; 107Â 114Â DllSpec int prtSetPropertyInt(enum PrtPropertyInt property, int value); 115Â 121Â DllSpec int prtGetPropertyInt(enum PrtPropertyInt property, int *value); 122Â 129Â DllSpec int prtSetPropertyString(enum PrtPropertyString property, const char* value); 130Â 132Â inline int prtSetPropertyString(enum PrtPropertyString property, const std::string &value) 133Â { return prtSetPropertyString(property,value.c_str()); } 134Â 141Â DllSpec int prtGetPropertyString(enum PrtPropertyString property, char* value, int len); 142Â 148Â DllSpec int prtGetPropertyString(enum PrtPropertyString property, std::string &value); 149Â 158Â DllSpec std::string prtFormat(const char *format, ...); 159Â 162Â DllSpec std::string prtFormatV(const char *format, va_list va); 163Â 164Â 172Â DllSpec enum PrtError prtURL(const stringmap &value, const char *url, bool landscape=false); 173Â 175Â inline enum PrtError prtURL(const stringmap &value, const std::string &url, bool landscape=false) 176Â { return prtURL(value,url.c_str(),landscape); } 177Â 178Â 180Â inline enum PrtError prtURL(const char *url, bool landscape=false) 181Â { stringmap value; return prtURL(value,url,landscape); } 182Â 183Â 185Â inline enum PrtError prtURL(const std::string &url, bool landscape=false) 186Â { return prtURL(url.c_str(),landscape); } 187Â 194Â DllSpec enum PrtError prtHTML(const stringmap &value,const std::string &text, bool landscape=false); 195Â 197Â inline enum PrtError prtHTML(const std::string &text, bool landscape=false) 198Â { stringmap value; return prtHTML(value,text,landscape); } 199Â 200Â 205Â typedef void (*prtAsyncCallback)(void *data); 206Â 207Â 218Â DllSpec enum PrtError prtURLAsync(const stringmap &value, const char *url, bool landscape=false, prtAsyncCallback cb=0, void *cbdata=0); 219Â 221Â inline enum PrtError prtURLAsync(const stringmap &value, const std::string &url, bool landscape=false, prtAsyncCallback cb=0, void *cbdata=0) 222Â { return prtURLAsync(value,url.c_str(),landscape, cb,cbdata); } 223Â 224Â 226Â inline enum PrtError prtURLAsync(const char *url, bool landscape=false, prtAsyncCallback cb=0, void *cbdata=0) 227Â { stringmap value; return prtURLAsync(value,url,landscape,cb,cbdata); } 228Â 230Â inline enum PrtError prtURLAsync(const std::string &url, bool landscape=false, prtAsyncCallback cb=0, void *cbdata=0) 231Â { return prtURLAsync(url.c_str(),landscape,cb,cbdata); } 232Â 242Â DllSpec enum PrtError prtHTMLAsync(const stringmap &value, const std::string &text, bool landscape=false, prtAsyncCallback cb=0, void *cbdata=0); 243Â 245Â inline enum PrtError prtHTMLAsync(const std::string &text, bool landscape=false, prtAsyncCallback cb=0, void *cbdata=0) 246Â { stringmap value; return prtHTMLAsync(value,text,landscape,cb,cbdata); } 247Â 253Â DllSpec enum PrtError prtWait(int timeout_msec=-1); 254Â 264Â DllSpec enum PrtError prtURL2PNG(const char *destfile, int width, const stringmap &value, const char *url, bool landscape=false); 265Â 267Â inline enum PrtError prtURL2PNG(const std::string &destfile, int width, const stringmap &value, const char *url, bool landscape=false) 268Â { return prtURL2PNG(destfile.c_str(),width,value,url,landscape); } 269Â 271Â inline enum PrtError prtURL2PNG(const char *destfile, int width, const stringmap &value, const std::string &url, bool landscape=false) 272Â { return prtURL2PNG(destfile,width,value,url.c_str(),landscape); } 273Â 275Â inline enum PrtError prtURL2PNG(const std::string &destfile, int width, const stringmap &value, const std::string &url, bool landscape=false) 276Â { return prtURL2PNG(destfile.c_str(),width,value,url.c_str(),landscape); } 277Â 278Â 279Â 281Â inline enum PrtError prtURL2PNG(const char *destfile, int width, const char *url, bool landscape=false) 282Â { 283Â stringmap value; 284Â return prtURL2PNG(destfile,width,value,url,landscape); 285Â } 286Â 288Â inline enum PrtError prtURL2PNG(const std::string &destfile, int width, const char *url, bool landscape=false) 289Â { return prtURL2PNG(destfile.c_str(),width,url,landscape); } 290Â 292Â inline enum PrtError prtURL2PNG(const char *destfile, int width, const std::string &url, bool landscape=false) 293Â { return prtURL2PNG(destfile,width,url.c_str(),landscape); } 294Â 296Â inline enum PrtError prtURL2PNG(const std::string &destfile, int width, const std::string &url, bool landscape=false) 297Â { return prtURL2PNG(destfile.c_str(),width,url.c_str(),landscape); } 298Â 299Â 308Â DllSpec enum PrtError prtHTML2PNG(const char *destfile, int width, const stringmap &value, const std::string &text, bool landscape=false); 309Â 311Â inline enum PrtError prtHTML2PNG(const char *destfile, int width, const std::string &text, bool landscape=false) 312Â { 313Â stringmap value; 314Â return prtHTML2PNG(destfile,width,value,text,landscape); 315Â } 316Â 318Â inline enum PrtError prtHTML2PNG(const std::string &destfile, int width, const std::string &text, bool landscape=false) 319Â { return prtHTML2PNG(destfile.c_str(),width,text,landscape); } 320Â 330Â DllSpec enum PrtError prtURL2ColorPNG(const char *destfile, int width, const stringmap &value, const char *url, bool landscape=false); 331Â 333Â inline enum PrtError prtURL2ColorPNG(const std::string &destfile, int width, const stringmap &value, const char *url, bool landscape=false) 334Â { return prtURL2ColorPNG(destfile.c_str(),width,value,url,landscape); } 335Â 337Â inline enum PrtError prtURL2ColorPNG(const char *destfile, int width, const stringmap &value, const std::string &url, bool landscape=false) 338Â { return prtURL2ColorPNG(destfile,width,value,url.c_str(),landscape); } 339Â 341Â inline enum PrtError prtURL2ColorPNG(const std::string &destfile, int width, const stringmap &value, const std::string &url, bool landscape=false) 342Â { return prtURL2ColorPNG(destfile.c_str(),width,value,url.c_str(),landscape); } 343Â 344Â 345Â 347Â inline enum PrtError prtURL2ColorPNG(const char *destfile, int width, const char *url, bool landscape=false) 348Â { 349Â stringmap value; 350Â return prtURL2ColorPNG(destfile,width,value,url,landscape); 351Â } 352Â 354Â inline enum PrtError prtURL2ColorPNG(const std::string &destfile, int width, const char *url, bool landscape=false) 355Â { return prtURL2ColorPNG(destfile.c_str(),width,url,landscape); } 356Â 358Â inline enum PrtError prtURL2ColorPNG(const char *destfile, int width, const std::string &url, bool landscape=false) 359Â { return prtURL2ColorPNG(destfile,width,url.c_str(),landscape); } 360Â 362Â inline enum PrtError prtURL2ColorPNG(const std::string &destfile, int width, const std::string &url, bool landscape=false) 363Â { return prtURL2ColorPNG(destfile.c_str(),width,url.c_str(),landscape); } 364Â 365Â 374Â DllSpec enum PrtError prtHTML2ColorPNG(const char *destfile, int width, const stringmap &value, const std::string &text, bool landscape=false); 375Â 377Â inline enum PrtError prtHTML2ColorPNG(const char *destfile, int width, const std::string &text, bool landscape=false) 378Â { 379Â stringmap value; 380Â return prtHTML2ColorPNG(destfile,width,value,text,landscape); 381Â } 382Â 384Â inline enum PrtError prtHTML2ColorPNG(const std::string &destfile, int width, const std::string &text, bool landscape=false) 385Â { return prtHTML2ColorPNG(destfile.c_str(),width,text,landscape); } 386Â 387Â 391Â struct prtControlSeq { 392Â std::string fontNormal; 393Â std::string fontDoubleHeight; 394Â std::string fontDoubleWidth; 395Â std::string fontDoubleWidthHeight; 397Â std::string italicOff; 398Â std::string italicOn; 399Â std::string boldOff; 400Â std::string boldOn; 401Â std::string underlineOff; 402Â std::string underlineOn; 403Â }; 404Â 414Â DllSpec enum PrtError prtURL2Text(std::string &result, int width, const stringmap &value, const char *url, const prtControlSeq &ctrl); 415Â 417Â inline enum PrtError prtURL2Text(std::string &result, int width, const stringmap &value, const std::string &url, const prtControlSeq &ctrl) 418Â { return prtURL2Text(result,width,value,url.c_str(),ctrl); } 419Â 421Â inline enum PrtError prtURL2Text(std::string &result, int width, const char *url, const prtControlSeq &ctrl) 422Â { stringmap value; return prtURL2Text(result,width,value,url,ctrl); } 423Â 425Â inline enum PrtError prtURL2Text(std::string &result, int width, const std::string &url, const prtControlSeq &ctrl) 426Â { return prtURL2Text(result,width,url.c_str(),ctrl); } 427Â 436Â DllSpec enum PrtError prtHTML2Text(std::string &result, int width, const stringmap &value, const std::string &text, const prtControlSeq &ctrl); 437Â 439Â inline enum PrtError prtHTML2Text(std::string &result, int width, const std::string &text, const prtControlSeq &ctrl) 440Â { stringmap value; return prtHTML2Text(result,width,value,text,ctrl); } 441Â 446Â DllSpec int prtGetFD(); 447Â 453Â DllSpec int prtSetCatalog(const std::string &filename); 454Â 462Â DllSpec void prtCatalogSetDelayedRelease(unsigned num); 463Â 469Â DllSpec unsigned prtCatalogGetDelayedRelease(); 470Â 477Â DllSpec std::string prtGetText(const std::string &name, const std::string &deflt=""); 478Â 487Â DllSpec int prtGetHtml(const std::map<std::string,std::string> &value, const std::string &text, std::string &html, bool full); 488Â DllSpec int prtGetHtml(const std::map<std::string,std::string> &value, const std::string &text, std::string &html); 489Â 499Â DllSpec int prtGetHtmlURL(const std::map<std::string,std::string> &value, const std::string &url, std::string &html, bool full); 500Â DllSpec int prtGetHtmlURL(const std::map<std::string,std::string> &value, const std::string &url, std::string &html); 501Â 502Â 509Â DllSpec int prtSetRemotePrinter(const std::string &address); 510Â 511Â 515Â DllSpec const char *prtLibVersion(); 516Â 520Â DllSpec const char *prt_GetVersion(); 521Â 522Â 524Â struct PrtErrorEntry { 526Â enum ErrorType { NOT_FOUND, 527Â UNSUPPORTED, 528Â CORRUPT 529Â } type; 530Â std::string name; 532Â PrtErrorEntry(ErrorType t, const std::string &n) :type(t),name(n) {} 533Â }; 534Â 538Â DllSpec const std::vector<PrtErrorEntry> &prtErrorList(); 539Â 541Â DllSpec std::string prtScriptError(); 542Â 543Â 548Â DllSpec void prtSetLocalProperties(bool local); 549Â 551Â DllSpec bool prtGetLocalProperties(); 552Â 553Â 557Â DllSpec void prtSetLogMask(unsigned mask); 558Â 562Â DllSpec unsigned prtGetLogMask(void); 563Â 570Â DllSpec void prtAddFontDir(const char *dir); 571Â 572Â #ifndef DOXYGEN 573Â } //namespace vfiprint 574Â #endif 575Â 576Â #undef DllSpec 577Â 580Â #endif // #ifndef PRINTER_IF_H_20130513
Rate this article: