title: PHP - from PHP how to trigger JavaScript to print the label to the printer?
body: <p>Using PHP (Zend Framework). But the problem is i have this and it only have Javascript based workout, have not found any PHP. So i was doing something like this.</p>
  
  <p><em><strong>Step 1:</em></strong> </p>
  
  <p>A) PHP Controller</p>
  
  <pre><code>class TestController extends Zend_Controller_Action {
    public function fastAction() {
      $this-&gt;_helper-&gt;layout()-&gt;disableLayout();
      //$this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender();
    }
  }
  </code></pre>
  
  <p>B) test/fast.phtml: Views for html and javascript to trigger</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
  &lt;title&gt;OnLoad Trigger PRint&lt;/title&gt; 
  &lt;script src = "http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js" type="text/javascript" charset="UTF-8"&gt; &lt;/script&gt;
  
  &lt;script type="text/javascript" charset="UTF-8"&gt;
  (function() {
  
    function onload() {
      /*
        "Nmbr.: {$data-&gt;badgeid}"
        $data-&gt;name
        $data-&gt;firstname
        $data-&gt;company
        $data-&gt;person
        $data-&gt;number     
       */
      //var textTextArea = 'BadgeID\nName\nFirstname\nCmpany\nPerson\nNumber';
  
      function printnow(textTextArea) {
        try {
  
          var labelXml = '&lt;DieCutLabel Version="8.0" Units="twips"&gt;&lt;PaperOrientation&gt;Landscape&lt;/PaperOrientation&gt;&lt;Id&gt;Address&lt;/Id&gt;&lt;PaperName&gt;30252 Address&lt;/PaperName&gt;&lt;DrawCommands/&gt;&lt;ObjectInfo&gt;&lt;TextObject&gt;&lt;Name&gt;Text&lt;/Name&gt;&lt;ForeColor Alpha="255" Red="0" Green="0" Blue="0" /&gt;&lt;BackColor Alpha="0" Red="255" Green="255" Blue="255" /&gt;&lt;LinkedObjectName&gt;&lt;/LinkedObjectName&gt;&lt;Rotation&gt;Rotation0&lt;/Rotation&gt;&lt;IsMirrored&gt;False&lt;/IsMirrored&gt;&lt;IsVariable&gt;True&lt;/IsVariable&gt;&lt;HorizontalAlignment&gt;Left&lt;/HorizontalAlignment&gt;&lt;VerticalAlignment&gt;Middle&lt;/VerticalAlignment&gt;&lt;TextFitMode&gt;ShrinkToFit&lt;/TextFitMode&gt;&lt;UseFullFontHeight&gt;True&lt;/UseFullFontHeight&gt;&lt;Verticalized&gt;False&lt;/Verticalized&gt;&lt;StyledText/&gt;&lt;/TextObject&gt;&lt;Bounds X="332" Y="150" Width="4455" Height="1260" /&gt;&lt;/ObjectInfo&gt;&lt;/DieCutLabel&gt;';
  
          var label = dymo.label.framework.openLabelXml(labelXml);
          label.setObjectText("Text", textTextArea);
  
          var printers = dymo.label.framework.getPrinters();
          if (printers.length == 0)
              throw "No DYMO printers are installed. Install DYMO printers.";
  
          var printerName = "";
          for (var i = 0; i &lt; printers.length; ++i) {
            var printer = printers[i];
            if (printer.printerType == "LabelWriterPrinter") {
              printerName = printer.name;
              break;
            }
          }
  
          if (printerName == "")
              throw "No LabelWriter printers found. Install LabelWriter printer";
  
          label.print(printerName);
  
        } catch(e) {
          alert(e.message || e);
        }
      }
  
      printnow('1234\nName\nFirstname\nCmpany\nPerson\nNumber');
  
    };
  
    // register onload event
    if (window.addEventListener)
        window.addEventListener("load", onload, false);
    else if (window.attachEvent)
        window.attachEvent("onload", onload);
    else
        window.onload = onload;
  
  } ());
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p><em><strong>Step 2:</em></strong> </p>
  
  <pre><code>google-chrome "http://unittest:80/test/fast"
  </code></pre>
  
  <p><em><strong>Step 3:</em></strong> OK - result, the print is out</p>
  
  <p>But problem is that, how can i do this whole thing (straight) from PHP? </p>
  
  <p>(and silently cause its a touch screen and print, i cant popup up this Step 1, 2, 3 to the end users experience)</p>
  
  <p>Any idea please?</p>