Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-从PHP如何触发JavaScript将标签打印到打印机?_Javascript_Php_Windows_Zend Framework_Printing - Fatal编程技术网

PHP-从PHP如何触发JavaScript将标签打印到打印机?

PHP-从PHP如何触发JavaScript将标签打印到打印机?,javascript,php,windows,zend-framework,printing,Javascript,Php,Windows,Zend Framework,Printing,使用PHP(Zend框架)。但问题是我有这个,它只有基于Javascript的训练,没有找到任何PHP。所以我就这样做了 第1步: google-chrome "http://unittest:80/test/fast" A) PHP控制器 class TestController extends Zend_Controller_Action { public function fastAction() { $this->_helper->layout()->di

使用PHP(Zend框架)。但问题是我有这个,它只有基于Javascript的训练,没有找到任何PHP。所以我就这样做了

第1步:

google-chrome "http://unittest:80/test/fast"
A) PHP控制器

class TestController extends Zend_Controller_Action {
  public function fastAction() {
    $this->_helper->layout()->disableLayout();
    //$this->_helper->viewRenderer->setNoRender();
  }
}
B) test/fast.phtml:要触发的html和javascript视图

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>OnLoad Trigger PRint</title> 
<script src = "http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js" type="text/javascript" charset="UTF-8"> </script>

<script type="text/javascript" charset="UTF-8">
(function() {

  function onload() {
    /*
      "Nmbr.: {$data->badgeid}"
      $data->name
      $data->firstname
      $data->company
      $data->person
      $data->number     
     */
    //var textTextArea = 'BadgeID\nName\nFirstname\nCmpany\nPerson\nNumber';

    function printnow(textTextArea) {
      try {

        var labelXml = '<DieCutLabel Version="8.0" Units="twips"><PaperOrientation>Landscape</PaperOrientation><Id>Address</Id><PaperName>30252 Address</PaperName><DrawCommands/><ObjectInfo><TextObject><Name>Text</Name><ForeColor Alpha="255" Red="0" Green="0" Blue="0" /><BackColor Alpha="0" Red="255" Green="255" Blue="255" /><LinkedObjectName></LinkedObjectName><Rotation>Rotation0</Rotation><IsMirrored>False</IsMirrored><IsVariable>True</IsVariable><HorizontalAlignment>Left</HorizontalAlignment><VerticalAlignment>Middle</VerticalAlignment><TextFitMode>ShrinkToFit</TextFitMode><UseFullFontHeight>True</UseFullFontHeight><Verticalized>False</Verticalized><StyledText/></TextObject><Bounds X="332" Y="150" Width="4455" Height="1260" /></ObjectInfo></DieCutLabel>';

        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 < 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;

} ());

</script>
</head>
<body>
</body> 
</html>
步骤3:确定-结果,打印输出

但问题是,我如何(直接)从PHP完成这一切

(由于它是触摸屏和打印,我无法弹出此步骤1、2、3以获得最终用户体验)


有什么想法吗?

好的-可以使用iframe,并且可以使用样式来隐藏它以产生显著效果

class TestController extends Zend_Controller_Action {
  public function silentAction() {
    $this->_helper->layout()->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
    echo "<body><iframe src='http://printing:7007/test/fast' ></iframe></body>";    
    exit;

    echo "<body><iframe src='http://printing:7007/test/fast?input=output' ></iframe></body>";  
  }

  public function fastAction() {
    $this->_helper->layout()->disableLayout();
    //$this->_helper->viewRenderer->setNoRender();
    $this->view->output = $_GET['input'];
  }
类TestController扩展Zend\u Controller\u操作{
公共功能Silentation(){
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
回声“;
出口
回声“;
}
公共职能快速行动(){
$this->_helper->layout()->disableLayout();
//$this->_helper->viewRenderer->setNoRender();
$this->view->output=$\u GET['input'];
}