1

Fatal error: Uncaught com_exception: Failed to create COM object `TSCActiveX.TSCLIB': Class not registered in C:\xampp\htdocs\DiamLaundry\printpage.php:26 Stack trace: #0 C:\xampp\htdocs\DiamLaundry\printpage.php(26): com->com('TSCActiveX.TSCL...') #1 {main} thrown in C:\xampp\htdocs\DiamLaundry\printpage.php on line 26

this is my code

<?php
for ($i=$a;$i<=$pieces;$i++) {
    $number = sprintf("%'.05d", $i);

    $TSCObj = new COM ("TSCActiveX.TSCLIB");
    $TSCObj->ActiveXopenport("TSC ME240");
    $TSCObj->ActiveXsetup("101.6", "127", "5.0", "13", "0", "3.048", "0");
    $TSCObj->ActiveXclearbuffer();

    $TSCObj->ActiveXsendcommand("BAR 1,57, 810, 3");
    $TSCObj->ActiveXsendcommand("BAR 1,746, 810, 3");
    $TSCObj->ActiveXwindowsfont(756,727,30,180,2,0, "arial", "Document No.");
    $TSCObj->ActiveXprintlabel("1", "1");
    $TSCObj->ActiveXclearbuffer();
    $TSCObj->ActiveXcloseport();
}

?>

MH2K9
  • 11,951
  • 7
  • 32
  • 49
nik s
  • 11
  • 3

1 Answers1

1

If you are using the default version of XAMPP then you are probably using a 64-bit version of PHP. If the DLL for the printer COM API is 32-bit then PHP would have trouble loading it, there is some discussion of this issue here.

Fatal Error: "Class not registered" creating COM Object

The OP of that topic found that this page helped to solve their problem.

https://techtalk.gfi.com/32bit-object-64bit-environment/

If you are using a 32-bit version of PHP then make sure that the DLL is correctly registered with Windows. Assuming that the DLL is called TSCActiveX.dll you can re-register it with the following command:

RegSrv32.exe TSCActiveX.dll

ArchCodeMonkey
  • 2,264
  • 1
  • 10
  • 9