1

HTML テーブルの形式で請求書を生成する PHP Web サイトがあります。これらの HTML テーブルをドット マトリックス プリンターに出力する必要があります。ブラウザーの印刷オプションを使用して Web ページを直接印刷しようとしましたが、ASCII テキスト ファイルのように 1 回のパスで完全な文字ではなくドットごとに文字を印刷するため、プリンターは画像として処理するようです。文字。

プリンターにテキストファイルとして扱わせる方法はありますか? または、位置のスタイリング (間隔、マージンなど) を失うことなく、html ページをテキスト ファイルに変換する方法はありますか? それとも、私が使用できる別のアプローチがありますか? 注意すべきことの 1 つは、クライアントが使用するため、テキストベースのブラウザーを使用してこれを行うことはできないということです。

請求書は、左上に小さなロゴ、タイトル、および説明を広告として持つ html テーブルと、tbody として境界線を持つ単純なテーブル セルです。

エプソンのLX300+IIプリンターを使用しています。

4

5 に答える 5

2
<?php
 // Download printer driver for dot matrix printer ex. 1979 Dot Matrix      Regular or Consola

?>
<html>
<head>
<title>PHP to Dot Matrix Printer</title>

<style>
@font-face { font-family: kitfont; src: url('1979 Dot Matrix Regular.TTF'); } 

.customFont { /*  <div class="customFont" /> */
font-style: kitfont;
font-size:10;
}
#mainDiv {
height: 324px; /* height of receipt 4.5 inches*/
width: 618px;  /* weight of receipt 8.6 inches*/
position:relative; /* positioned relative to its normal position */
}
#cqm { /*  <img id="cqm" /> */
top: 10px; /* top is distance from top (x axis)*/
left: 105px; /* left is distance from left (y axis)*/
position:absolute; /* position absolute based on "top" and "left"    parameters x and y  */
}

#or_mto { 
position: absolute;
left: 0px;
top: 0px;
z-index: -1; /*image */
}

    #arpno {
top: 80px;
left: 10px;
position:absolute;
}
#payee {
top: 80px;
left: 200px;
position:absolute;
}
#credit {
top: 80px;
right: 30px; /*   distance from right */
position:absolute;
}
#paydate {
top: 57px;
right: 120px;
position:absolute;
}
 </style>

</head>
<body>
<?php
//sample data

$arpno   = 1234567;
$payee   = "Juan dela Cruz";
$credit  = 10000;
$paydate = "Dec. 6, 2015" ;


?>
<div id="mainDiv"> <!--  invisible space -->
<div id="cqm" class="customFont">ABC TRADING</div>
<div id="arpno" class="customFont"><?php echo $arpno; ?></div>
<div id="payee" class="customFont"><?php echo $payee; ?></div>
<div id="credit" class="customFont"><?php echo $credit; ?></div>
<div id="paydate" class="customFont"><?php echo $paydate; ?></div>
<img id="or_mto" src="or_mto.jpg" /> <!---- sample for logo  ---->
</div>

</body>
</html>
于 2015-12-06T04:53:24.443 に答える