PHPでPDF出力(tcpdf) 画像取込

TCPDF定義ファイルに画像を取込みPDF出力

TCPDF定義ファイルジェネレーターにExcleの画像取込み機能を追加した。

因みに、動作するにはGDライブラリが必須になる。

 

帳票設計したExcelファイル

f:id:sesjk:20200903145259p:plain

   

出力PDFはこちらから 納品書

 TCPDF定義ファイル

<?php

/***********************************************************************

*

* lxsTCPDFで作成したソースです。ソースの内容には責任を負いかねます

* 改変は自由です。

* クラス名は変更しないでください

***********************************************************************/

?>

<?php

Class tcpDefine extends tcpdfEditer {

 

public function setHeader() {

//ヘッダー・フッター印刷しない

$this->setPrintHeader(false);

 

$this->setPrintFooter(0);

$this->setHeaderMargin(0);

$this->setFooterMargin(0);

//余白

$this->SetMargins(7.8,8.7,-1,true);

 

}

 

public function newPage() {

//ページ追加

$this->AddPage('L','A4');

 

}

 

public function setPage($pnum, $resetmargins = false) {

//自動改ページ オフ

$this->SetAutoPageBreak(False, 0);

 

$a = $this->GetX();

$b = $this->GetY();

$wd=41;

$vPos=8.7;

$hPos=132.4;

$this->SetFont('kozminproregular', '',20);

$this->SetTextColor(79,129,189);

$source ='納 品 書';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');

$wd=14;

$vPos=8.7;

$hPos=202.5;

$this->SetFont('kozminproregular', '',11);

$this->SetTextColor(0,0,0);

$source ='納品No';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=11;

$vPos=8.7;

$hPos=216.8;

$source =$this->_pdf_vars['No'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=14;

$vPos=14.4;

$hPos=202.5;

$source ='納品日';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=29;

$vPos=14.4;

$hPos=216.8;

$source =$this->_pdf_vars['nouhinbi'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=88;

$vPos=19.3;

$hPos=19.3;

$this->SetFont('kozminproregular', '',14);

$source =$this->_pdf_vars['name'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,9, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=14;

$vPos=19.3;

$hPos=107.3;

$source =$this->_pdf_vars['keisyo'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,9, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=11;

$vPos=23.2;

$hPos=173.6;

$this->SetFont('kozminproregular', '',12);

$this->SetTextColor(0,112,192);

$source ='株式会社システム・エッセンス';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=22;

$vPos=31;

$hPos=19.3;

$this->SetFont('kozminproregular', '',11);

$this->SetTextColor(0,0,0);

$source =$this->_pdf_vars['zip'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=73;

$vPos=31;

$hPos=173.6;

$this->SetFont('kozminproregular', '',11);

$this->SetTextColor(0,112,192);

$source ='184-0003 東京都小金井市○○町1-1-1';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=102;

$vPos=36.2;

$hPos=19.3;

$this->SetTextColor(0,0,0);

$source =$this->_pdf_vars['addr'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=11;

$vPos=36.2;

$hPos=173.6;

$this->SetTextColor(0,112,192);

$source ='TEL042-380-xxxx FAX 042-380-xxxx';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$wd=11;

$vPos=40.9;

$hPos=19.3;

$this->SetTextColor(0,0,0);

$source =$this->_pdf_vars['bill'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,5, $source, 0, 0,'L',0,'',0,0,'T','M');

$this->Rect(19.3, 55.2,66,6,'F','',array(83,141,213));

$wd=66;

$vPos=55.2;

$hPos=19.3;

$this->SetTextColor(255,255,255);

$source ='品番/品名';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$this->Rect(85.3, 55.2,22,6,'F','',array(83,141,213));

$wd=22;

$vPos=55.2;

$hPos=85.3;

$source ='数量';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$this->Rect(107.3, 55.2,14,6,'F','',array(83,141,213));

$wd=14;

$vPos=55.2;

$hPos=107.3;

$source ='単位';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$this->Rect(121.4, 55.2,30,6,'F','',array(83,141,213));

$wd=30;

$vPos=55.2;

$hPos=121.4;

$source ='単  価';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$this->Rect(151.6, 55.2,33,6,'F','',array(83,141,213));

$wd=33;

$vPos=55.2;

$hPos=151.6;

$source ='金  額';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$this->Rect(184.6, 55.2,62,6,'F','',array(83,141,213));

$wd=62;

$vPos=55.2;

$hPos=184.6;

$source ='摘   要';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$wd=66;

 

// 行の高さ

$hi = 8.2;

// 行の開始位置

$vPos = 61.6;

$row = 12;

$iy = 0;

$maxRow = 18;

foreach ($this->_pdf_vars['loop'] as $key) {

$iy++;

$hPos=19.3;

$wd = 66;

//背景色

if (($iy % 2) == 0 ) {

$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(220,230,241));

}

 

$this->SetTextColor(0,0,0);

if (isset( $key['hinmei'] ) ) {

$source = $key['hinmei'];

} else {

$source = '';

}

$this->SetXY($hPos, $vPos);

$info = $this->adjustToWidth($source, $wd,'kozminproregular',11);

$this->SetFont('kozminproregular', '',$info);

$this->Cell( $wd, $hi, $source, 0, 0,'L',0,'',0,0,'T','M');

$hPos=85.3;

$wd = 22;

//背景色

if (($iy % 2) == 0 ) {

$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(220,230,241));

}

 

$this->SetTextColor(0,0,0);

if (isset( $key['suryo'] ) ) {

$source = $key['suryo'];

} else {

$source = '';

}

$this->SetXY($hPos, $vPos);

$this->Cell( $wd, $hi, $source, 0, 0,'R',0,'',0,0,'T','M');

$hPos=107.3;

$wd = 14;

//背景色

if (($iy % 2) == 0 ) {

$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(220,230,241));

}

 

$this->SetTextColor(0,0,0);

if (isset( $key['tani'] ) ) {

$source = $key['tani'];

} else {

$source = '';

}

$this->SetXY($hPos, $vPos);

$this->Cell( $wd, $hi, $source, 0, 0,'C',0,'',0,0,'T','M');

$hPos=121.4;

$wd = 30;

//背景色

if (($iy % 2) == 0 ) {

$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(220,230,241));

}

 

$this->SetTextColor(0,0,0);

if (isset( $key['tanka'] ) ) {

$source = $key['tanka'];

} else {

$source = '';

}

$this->SetXY($hPos, $vPos);

$this->Cell( $wd, $hi, $source, 0, 0,'R',0,'',0,0,'T','M');

$hPos=151.6;

$wd = 33;

//背景色

if (($iy % 2) == 0 ) {

$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(220,230,241));

}

 

$this->SetTextColor(0,0,0);

if (isset( $key['kingaku'] ) ) {

$source = $key['kingaku'];

} else {

$source = '';

}

$this->SetXY($hPos, $vPos);

$this->Cell( $wd, $hi, $source, 0, 0,'R',0,'',0,0,'T','M');

$hPos=184.6;

$wd = 62;

//背景色

if (($iy % 2) == 0 ) {

$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(220,230,241));

}

 

$this->SetTextColor(0,0,0);

if (isset( $key['bikou'] ) ) {

$source = $key['bikou'];

} else {

$source = '';

}

$pos=$vPos;

$this->SetFont('kozminproregular', '',11);

$chrcnt=0;

for ($k= 0; $k != -1; ) {

$info = $this->adjustToHeight($source, $k,$wd, $wd - 1,8.2,'kozminproregular',11,$chrcnt);

$k = $info['length'];

$text = $info['text'];

$this->SetXY($hPos, $pos);

$this->Cell($wd, $info['height'], $text, 0, 0,'L',0,'',0,0,'T','M');

$pos += $info['height'];

$chrcnt = $info['count'];

}

$vPos += $hi;

$row++;

}

 

$hPos=19.3;

$wd = 227;

$lastRow = 18;

for($row = $row; $row <= $lastRow;$row++) {

$iy++;

if (($iy % 2) == 0 ) {

$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(220,230,241));

}

$vPos += $hi;

}

$this->Rect(121.4, 119,30,6,'F','',array(220,230,241));

$wd=30;

$vPos=119;

$hPos=121.4;

$this->SetTextColor(0,0,0);

$source ='小計(税抜)';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$wd=33;

$vPos=119;

$hPos=151.6;

$source =$this->_pdf_vars['syoukei'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'R',0,'',0,0,'T','M');

$this->Rect(121.4, 125.4,30,6,'F','',array(220,230,241));

$wd=30;

$vPos=125.4;

$hPos=121.4;

$source ='消費税';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'C',0,'',0,0,'T','M');

$wd=33;

$vPos=125.4;

$hPos=151.6;

$source =$this->_pdf_vars['zei'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,6, $source, 0, 0,'R',0,'',0,0,'T','M');

$this->Rect(121.4, 131.8,30,7,'F','',array(220,230,241));

$wd=30;

$vPos=131.8;

$hPos=121.4;

$source ='合計金額';

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,7, $source, 0, 0,'C',0,'',0,0,'T','M');

$wd=33;

$vPos=131.8;

$hPos=151.6;

$source =$this->_pdf_vars['total'];

$pos = $vPos;

$this->SetXY($hPos, $pos);

$this->Cell($wd,7, $source, 0, 0,'R',0,'',0,0,'T','M');

 

//罫線設定

$this->Line(19.3, 55.2, 85.3, 55.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 55.2, 85.3, 61.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(149,179,215)));

$this->Line(85.3, 55.2, 107.3, 55.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 55.2, 107.3, 61.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(149,179,215)));

$this->Line(107.3, 55.2, 121.4, 55.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 55.2, 121.4, 61.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(149,179,215)));

$this->Line(121.4, 55.2, 151.6, 55.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 55.2, 151.6, 61.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(149,179,215)));

$this->Line(151.6, 55.2, 184.6, 55.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 55.2, 184.6, 61.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(149,179,215)));

$this->Line(184.6, 55.2, 246.2, 55.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 55.2, 246.2, 61.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 61.6, 85.3, 61.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 61.6, 85.3, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 61.6, 107.3, 61.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 61.6, 107.3, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 61.6, 121.4, 61.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 61.6, 121.4, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 61.6, 151.6, 61.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 61.6, 151.6, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 61.6, 184.6, 61.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 61.6, 184.6, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 61.6, 246.2, 61.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 61.6, 246.2, 69.8, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 69.8, 85.3, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 69.8, 85.3, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 69.8, 107.3, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 69.8, 107.3, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 69.8, 121.4, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 69.8, 121.4, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 69.8, 151.6, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 69.8, 151.6, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 69.8, 184.6, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 69.8, 184.6, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 69.8, 246.2, 69.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 69.8, 246.2, 78, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 78, 85.3, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 78, 85.3, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 78, 107.3, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 78, 107.3, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 78, 121.4, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 78, 121.4, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 78, 151.6, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 78, 151.6, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 78, 184.6, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 78, 184.6, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 78, 246.2, 78, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 78, 246.2, 86.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 86.2, 85.3, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 86.2, 85.3, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 86.2, 107.3, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 86.2, 107.3, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 86.2, 121.4, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 86.2, 121.4, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 86.2, 151.6, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 86.2, 151.6, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 86.2, 184.6, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 86.2, 184.6, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 86.2, 246.2, 86.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 86.2, 246.2, 94.4, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 94.4, 85.3, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 94.4, 85.3, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 94.4, 107.3, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 94.4, 107.3, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 94.4, 121.4, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 94.4, 121.4, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 94.4, 151.6, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 94.4, 151.6, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 94.4, 184.6, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 94.4, 184.6, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 94.4, 246.2, 94.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 94.4, 246.2, 102.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 102.6, 85.3, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 102.6, 85.3, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 102.6, 107.3, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 102.6, 107.3, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 102.6, 121.4, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 102.6, 121.4, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 102.6, 151.6, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 102.6, 151.6, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 102.6, 184.6, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 102.6, 184.6, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 102.6, 246.2, 102.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 102.6, 246.2, 110.8, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 110.8, 85.3, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 110.8, 85.3, 119, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(85.3, 110.8, 107.3, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 110.8, 107.3, 119, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(107.3, 110.8, 121.4, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 110.8, 121.4, 119, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 110.8, 151.6, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 110.8, 151.6, 119, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 110.8, 184.6, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 110.8, 184.6, 119, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 110.8, 246.2, 110.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(246.2, 110.8, 246.2, 119, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 55.2, 19.3, 119, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(19.3, 119, 121.4, 119, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 119, 151.6, 119, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 119, 151.6, 125.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 119, 184.6, 119, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 119, 184.6, 125.4, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(184.6, 119, 246.2, 119, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 125.4, 151.6, 125.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(83,141,213)));

$this->Line(151.6, 125.4, 151.6, 131.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 125.4, 184.6, 125.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(83,141,213)));

$this->Line(184.6, 125.4, 184.6, 131.8, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 131.8, 151.6, 131.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(83,141,213)));

$this->Line(151.6, 131.8, 151.6, 138.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(151.6, 131.8, 184.6, 131.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(83,141,213)));

$this->Line(184.6, 131.8, 184.6, 138.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 119, 121.4, 138.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

$this->Line(121.4, 138.5, 184.6, 138.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(83,141,213)));

//画像情報

$this->Image('pdf_images/Picture1.png',220,20.2,23.4,24.7);

}

}

 

?>

 

index.phpファイル

<?php

error_reporting(E_ALL & ~ E_DEPRECATED & ~ E_USER_DEPRECATED & ~ E_NOTICE);

ini_set('display_errors', 1);

    require_once(dirname(__FILE__)."/../lib/TCPDF-master/tcpdf.php");

 

    require_once(dirname(__FILE__)."/tcpdfEditer.php");

 

    require_once(dirname(__FILE__)."/nouhinsyo.php");

 

    $pdf = new tcpDefine();

 

    $pdf->assign('zip', "184-0003");

    $pdf->assign('addr', "小金井市□□町1−1−1");

    $pdf->assign('bill', "駅前ビル301");

    $pdf->assign('name', "ジェーケイソフト");

    $pdf->assign('keisyo', "御中");

    $pdf->assign('nouhinbi', "2020年8月20日");

    $pdf->assign('No', "1-0115");

 

    $lpdata= array();

    $lpdata = array('hinmei'=>'パソコン','suryo'=>'2','tani'=>'台','tanka'=>'70,000','kingaku'=>'140,000','bikou'=>'');

    $pdf->append('loop', $lpdata);

    $lpdata = array('hinmei'=>'モニター','suryo'=>'2','tani'=>'台','tanka'=>'25,000','kingaku'=>'50,000','bikou'=>'');

    $pdf->append('loop', $lpdata);

    $lpdata = array('hinmei'=>'プリンター','suryo'=>'1','tani'=>'台','tanka'=>'55,000','kingaku'=>'55,000','bikou'=>'別納');

    $pdf->append('loop', $lpdata);

    $pdf->assign('syoukei','245,000');

    $pdf->assign('total', "269,500");

    $pdf->assign('zei', "24,500");

 

 

//    $pdf->init("hakenn");

 

$pdf->setHeader();

$pdf->newPage();

 

    $pdf->out('nouhin.pdf', 'I');

 

 

?>

 

PHPでPDF出力(tcpdf) 10 (ついに完成)

10.ExcelからTCPDF定義ファイル作成

Excelで帳票設計して、TCPDFでPDF帳票出力するためのジェネレーターが完成した。

完成したジェネレーターの実行画面である。

  ジェネレーター

帳票設計のExcelPHPで実行したTCPDF定義ファイルと出力されたPDFである。

   Excelレイアウト

 

   出力PDF帳票

 出力されたTCPDF定義を少々長くなる(899行)が載せておく。

<?php

Class tcpDefine extends  tcpdfEditoer {

public function setHeader() {
//ヘッダー・フッター印刷しない
$this->setPrintHeader(false);

$this->setPrintFooter(0);
$this->setHeaderMargin(0);
$this->setFooterMargin(0);
//余白
$this->SetMargins(1.5,3.6,-1,true);

}

public function newPage() {
//ページ追加
$this->AddPage('L','A4');

}

public function setPage() {
//自動改ページ オフ
$this->SetAutoPageBreak(False, 0);

$a = $this->GetX();
$b = $this->GetY();
$wd=21;
$vPos=3.6;
$hPos=3.8;
$this->SetFont('kozgopromedium', '',11);
$this->SetTextColor(0,0,0);
$source ='受 注 日';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,7, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=59;
$vPos=3.6;
$hPos=24.5;
$source ='図 番';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,7, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=12;
$vPos=3.6;
$hPos=83;
$source ='個数';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,7, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=20;
$vPos=3.6;
$hPos=94.7;
$source ='単 価';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,7, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=18;
$vPos=3.6;
$hPos=114.9;
$source ='納 期';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,7, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=12;
$vPos=3.6;
$hPos=133.1;
$source ='回数';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,7, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=84;
$vPos=3.6;
$hPos=169.5;
$this->SetFont('kozgopromedium', '',22);
$source ='製 造 指 示 書';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,14, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=13;
$vPos=3.6;
$hPos=274.5;
$this->SetFont('kozgopromedium', '',12);
$source ='No.1';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,7, $source, 0, 0,'L',0,'',0,0,'T','M');
$wd=9;
$vPos=10.6;
$hPos=3.8;
$this->SetFont('kozgopromedium', '',11);
$source =$this->_pdf_vars['day'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,13, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=12;
$vPos=10.6;
$hPos=12.8;
$this->SetFont('kozgopromedium', '',22);
$this->SetTextColor(255,0,0);
$source ='Ⅹ';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,13, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=47;
$vPos=10.6;
$hPos=24.5;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['seizou'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,13, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=12;
$vPos=10.6;
$hPos=83;
$source =$this->_pdf_vars['kosuu'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,13, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=20;
$vPos=10.6;
$hPos=94.7;
$source =$this->_pdf_vars['tanka'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,13, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=18;
$vPos=10.6;
$hPos=114.9;
$source =$this->_pdf_vars['nouki'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,13, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=12;
$vPos=10.6;
$hPos=133.1;
$source =$this->_pdf_vars['kai'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,13, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=24;
$hPos=169.5;
$this->SetFont('kozgopromedium', '',12);
$source ='検査部';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,8, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=24;
$hPos=197.5;
$source ='製造部';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,8, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=24;
$hPos=225.5;
$source ='設計部';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,8, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=9;
$vPos=27.4;
$hPos=3.8;
$this->SetFont('kozgopromedium', '',14);
$source ='正';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=12;
$wd=12;

// 列の幅
// 行高さ
$hi = 4;
// 列の開始位置
$col = 3;
$maxCol = 10;
$hPos=12.8;
$vPos=27.4;
foreach ($this->_pdf_vars['hstday'] as $key) {
$source = $key['day'];
$this->SetTextColor(0,0,0);
$this->SetXY($hPos, $vPos);
$info = $this->adjustToWidth($source, $wd,'kozgopromedium,'11);
$this->SetFont('kozgopromedium', '',$info);
$this->Cell( $wd, $hi, $source, 0, 0,'C',0,'',0,0,'T','M');
$hPos += $wd;
$col++;
}
$wd=39;
$vPos=27.4;
$hPos=106.4;
$this->SetFont('kozgopromedium', '',11);
$source ='年間予定数';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,4, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=12;
$wd=12;

// 列の幅
// 行高さ
$hi = 7;
// 列の開始位置
$col = 3;
$maxCol = 10;
$hPos=12.8;
$vPos=31.9;
foreach ($this->_pdf_vars['hstsuu'] as $key) {
$source = $key['su'];
$this->SetTextColor(0,0,0);
$this->SetXY($hPos, $vPos);
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->Cell( $wd, $hi, $source, 0, 0,'C',0,'',0,0,'T','M');
$hPos += $wd;
$col++;
}
$wd=8;
$vPos=31.9;
$hPos=106.4;
$this->SetFont('kozgopromedium', '',14);
$source ='正';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=9;
$vPos=39.2;
$hPos=3.8;
$source ='反';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=8;
$vPos=43.7;
$hPos=106.4;
$source ='反';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=9;
$vPos=51;
$hPos=3.8;
$source ='正';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=8;
$vPos=55.5;
$hPos=106.4;
$this->SetFont('kozgopromedium', '',18);
$source ='MC';
$pos = $vPos;
$chrcnt=0;
for ($k= 0; $k != -1; ) {
$info = $this->adjustToHeight($source, $k,8,7,7.3,'kozgopromedium',18,$chrcnt);
$k = $info['length'];
$text = $info['text'];
$this->SetXY($hPos, $pos);
$this->Cell(8, $info['height'], $text, 0, 0,'C',0,'',0,0,'T','T');
$pos += $info['height'];
$chrcnt = $info['count'];
}
$wd=31;
$vPos=55.5;
$hPos=114.9;
$source ='1';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,19, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=9;
$vPos=62.8;
$hPos=3.8;
$this->SetFont('kozgopromedium', '',14);
$source ='反';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=78;
$hPos=3.8;
$this->SetFont('kozgopromedium', '',12);
$source ='材  料';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=121;
$vPos=78;
$hPos=24.5;
$source ='寸   法';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium,'12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=89;
$hPos=3.8;
$this->SetFont('kozgopromedium', '',18);
$source =$this->_pdf_vars['zairyo'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=109;
$vPos=89;
$hPos=36.2;
$source =$this->_pdf_vars['size'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'L',0,'',0,0,'T','M');
$wd=9;

// 行の高さ
$hi = 11;
// 行の開始位置
$vPos = 100;
$row = 16;
$maxRow = 19;
foreach ($this->_pdf_vars['lpdata'] as $key) {
$hPos=3.8;
$wd = 9;
$this->SetTextColor(0,0,0);
$source = $key['num'];
$this->SetXY($hPos, $vPos);
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->Cell( $wd, $hi, $source, 0, 0,'C',0,'',0,0,'T','M');
$hPos=12.8;
$wd = 102;
$this->SetTextColor(0,0,0);
$source = $key['zai'];
$this->SetXY($hPos, $vPos);
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->Cell( $wd, $hi, $source, 0, 0,'L',0,'',0,0,'T','M');
$vPos += $hi;
$row++;
}
$wd=31;
$vPos=100;
$hPos=114.9;
$this->SetFont('kozgopromedium', '',14);
$source ='注文';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=31;
$vPos=111;
$hPos=114.9;
$this->SetFont('kozgopromedium', '',24);
$source =$this->_pdf_vars['chumon'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',24);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','T');
$wd=28;
$vPos=111;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(0,102,255);
$source ='1F棚№';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'L',0,'',0,0,'T','M');
$wd=35;
$vPos=111;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',16);
$source =$this->_pdf_vars['tana1f'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=7;
$vPos=111;
$hPos=218.5;
$this->SetFont('kozgopromedium', '',18);
$source ='㋐ ㋒冶具方式';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'L',0,'',0,0,'T','M');
$wd=7;
$vPos=122;
$hPos=114.9;
$this->SetFont('kozgopromedium', '',10);
$this->SetTextColor(0,0,0);
$source ='加工予定日';
$pos = $vPos;
$chrcnt=0;
for ($k= 0; $k != -1; ) {
$info = $this->adjustToHeight($source, $k,7,6,11,'kozgopromedium',10,$chrcnt);
$k = $info['length'];
$text = $info['text'];
$this->SetXY($hPos, $pos);
$this->Cell(7, $info['height'], $text, 0, 0,'C',0,'',0,0,'T','M');
$pos += $info['height'];
$chrcnt = $info['count'];
}
$wd=28;
$vPos=122;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(0,102,255);
$source ='在庫(正)';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=122;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',12);
$source =$this->_pdf_vars['zaiko1f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=122;
$hPos=197.5;
$this->SetFont('kozgopromedium', '',14);
$source ='キ ズ';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=122;
$hPos=225.5;
$this->SetFont('kozgopromedium', '',12);
$source =$this->_pdf_vars['kizu1f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=122;
$hPos=246.5;
$this->SetFont('kozgopromedium', '',14);
$source ='材 料';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=18;
$vPos=122;
$hPos=274.5;
$this->SetFont('kozgopromedium', '',12);
$source =$this->_pdf_vars['zai1f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=9;

$wd=28;
$vPos=133;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',14);
$source ='在庫(反)';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=133;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',11);
$source =$this->_pdf_vars['zaiko01f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium,'11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=133;
$hPos=197.5;
$this->SetFont('kozgopromedium', '',14);
$source ='二次加工';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=133;
$hPos=225.5;
$this->SetFont('kozgopromedium', '',11);
$source =$this->_pdf_vars['niji1f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=133;
$hPos=246.5;
$this->SetFont('kozgopromedium', '',14);
$source ='その他';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=18;
$vPos=133;
$hPos=274.5;
$this->SetFont('kozgopromedium', '',12);
$source =$this->_pdf_vars['etc1f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,12, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=44;
$vPos=144.9;
$hPos=3.8;
$this->SetFont('kozgopromedium', '',16);
$this->SetTextColor(0,0,0);
$source ='1回 - 4本';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',16);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=47;
$vPos=144.9;
$hPos=47.9;
$source ='1本 - 8個';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',16);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=51;
$vPos=144.9;
$hPos=94.7;
$source ='4本 - 32個';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium,'16);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=144.9;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(0,102,255);
$source ='バリ・サビ';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=144.9;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',12);
$source =$this->_pdf_vars['bari1f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'R',0,'',0,0,'T','M');
$wd=28;
$vPos=144.9;
$hPos=197.5;
$this->SetFont('kozgopromedium', '',14);
$source ='溶 接';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=144.9;
$hPos=225.5;
$this->SetFont('kozgopromedium', '',12);
$source =$this->_pdf_vars['yousetu1f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=164.1;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(255,0,0);
$source ='2F棚№';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'L',0,'',0,0,'T','M');
$wd=35;
$vPos=164.1;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',16);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['tana2f'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=7;
$vPos=164.1;
$hPos=218.5;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(255,0,0);
$source ='㋐ ㋒';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'L',0,'',0,0,'T','M');
$wd=28;
$vPos=175.1;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',14);
$source ='在庫(正)';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=175.1;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['zaiko2f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=175.1;
$hPos=197.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(255,0,0);
$source ='キ ズ';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=175.1;
$hPos=225.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['kizui2f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=175.1;
$hPos=246.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(255,0,0);
$source ='材 料';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=18;
$vPos=175.1;
$hPos=274.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['zai2f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=186.1;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(255,0,0);
$source ='在庫(反)';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=186.1;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['zaiko02f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=186.1;
$hPos=197.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(255,0,0);
$source ='二次加工';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=186.1;
$hPos=225.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['niji2f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=186.1;
$hPos=246.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(255,0,0);
$source ='その他';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=18;
$vPos=186.1;
$hPos=274.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['etc2f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=197.1;
$hPos=148.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(255,0,0);
$source ='バリ・サビ';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=197.1;
$hPos=176.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['bari2f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=28;
$vPos=197.1;
$hPos=197.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(255,0,0);
$source ='溶 接';
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'C',0,'',0,0,'T','M');
$wd=21;
$vPos=197.1;
$hPos=225.5;
$this->SetFont('kozgopromedium', '',12);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['yousetui2f'];
$pos = $vPos;
$info = $this->adjustToWidth($source, $wd,'kozgopromedium',12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell($wd,11, $source, 0, 0,'R',0,'',0,0,'T','M');

//罫線設定
$this->Line(3.8, 3.6, 145.5, 3.6, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 10.6, 145.5, 10.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(12.8, 10.6, 12.8, 24, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(24.5, 3.6, 24.5, 24, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(83, 3.6, 83, 24, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(94.7, 3.6, 94.7, 24, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(114.9, 3.6, 114.9, 24, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(133.1, 3.6, 133.1, 24, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 24, 145.5, 24, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(169.5, 24, 253.5, 24, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 27.4, 145.5, 27.4, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(12.8, 31.9, 145.5, 31.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(169.5, 31.9, 253.5, 31.9, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 39.2, 106.4, 39.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(12.8, 43.7, 145.5, 43.7, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(169.5, 24, 169.5, 43.7, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(197.5, 24, 197.5, 43.7, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(225.5, 24, 225.5, 43.7, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(253.5, 24, 253.5, 43.7, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(169.5, 43.7, 253.5, 43.7, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 51, 106.4, 51, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(12.8, 55.5, 106.4, 55.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(106.4, 55.5, 145.5, 55.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 62.8, 106.4, 62.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(12.8, 67.3, 106.4, 67.3, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(12.8, 27.4, 12.8, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(24.5, 27.4, 24.5, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(36.2, 27.4, 36.2, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(47.9, 27.4, 47.9, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(59.6, 27.4, 59.6, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(71.3, 27.4, 71.3, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(83, 27.4, 83, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(94.7, 27.4, 94.7, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(106.4, 27.4, 106.4, 74.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(114.9, 31.9, 114.9, 74.6, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 74.6, 145.5, 74.6, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 78, 145.5, 78, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 89, 145.5, 89, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(24.5, 78, 24.5, 100, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 100, 145.5, 100, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 111, 114.9, 111, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(0,0,0)));
$this->Line(114.9, 110.3, 145.5, 110.3, array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(114.9, 111, 145.5, 111, array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(148.5, 111, 211.5, 111, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(3.8, 122, 114.9, 122, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(0,0,0)));
$this->Line(114.9, 122, 145.5, 122, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(176.5, 111, 176.5, 122, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(211.5, 111, 211.5, 122, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(148.5, 122, 292.8, 122, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(3.8, 133, 114.9, 133, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(0,0,0)));
$this->Line(148.5, 133, 292.8, 133, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(114.9, 100, 114.9, 144.9, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(122.1, 122, 122.1, 144.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 144.9, 145.5, 144.9, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(148.5, 144.9, 292.8, 144.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(47.9, 144.9, 47.9, 155.9, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(94.7, 144.9, 94.7, 155.9, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 155.9, 145.5, 155.9, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(148.5, 111, 148.5, 155.9, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(176.5, 122, 176.5, 155.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(197.5, 122, 197.5, 155.9, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(225.5, 122, 225.5, 155.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(246.5, 122, 246.5, 155.9, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(274.5, 122, 274.5, 155.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(292.8, 122, 292.8, 155.9, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(148.5, 155.9, 292.8, 155.9, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(148.5, 164.1, 211.5, 164.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(176.5, 164.1, 176.5, 175.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(211.5, 164.1, 211.5, 175.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(148.5, 175.1, 292.8, 175.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(148.5, 186.1, 292.8, 186.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(148.5, 197.1, 292.8, 197.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(3.8, 3.6, 3.8, 208.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(145.5, 3.6, 145.5, 208.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(3.8, 208.1, 145.5, 208.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(148.5, 164.1, 148.5, 208.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(176.5, 175.1, 176.5, 208.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(197.5, 175.1, 197.5, 208.1, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(225.5, 175.1, 225.5, 208.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(246.5, 175.1, 246.5, 208.1, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(274.5, 175.1, 274.5, 208.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(292.8, 175.1, 292.8, 208.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(148.5, 208.1, 292.8, 208.1, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
}
}

?>

 

画像の取り込みやプロポーショナルの対応などまだ課題は残るが、PHPでPDF帳票を出力するには、まあまあ満足できる出来栄えは自画自賛か。

 

【謝辞】

最後に、ジェネレーターの作成に当たり、次のサイトを参考にさせて頂きました。

各サイト作成の皆様ありがとうございました。

TCPDFマニュアル(勝手訳)

TCPDFの部屋

Examples · TCPDF

 

PHPでPDF出力(tcpdf) 9 (列の繰り返しと折り返して全体表示)

9.列の繰り返しと折り返して全体表示

ほぼ満足のいく結果が得られたが、「列の繰り返し」と「折り返しての全体表示」に課題が残った。

まず、取り掛かったのが「列の繰り返し」である。

Excelでの変数定義は、行と同様に「{$配列名変数名]}」とした。

TCPDF定義ファイルの出力は下記の通り、簡単に作成でき結果も良好である。

 // 列の幅
$wd = 16.4;
// 行高さ
$hi = 6.2;
// 列の開始位置
$col = 2;
$maxCol = 13;
$hPos=8.8;
$vPos=28.4;
foreach ($this->_pdf_vars['lp'] as $key) {
$source = $key['mon'];
$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(226,239,218));
$this->SetTextColor(0,0,0);
$pos=$vPos;
$this->SetFont('kozgopromedium', '',11);
for ($k= 0; $k != -1;  ) {
$info = $this->adjustToHeight($source, $k,16.4,15.4,6.2,kozgopromedium,11);
$k = $info['length'];
$text = $info['text'];
$this->SetXY($hPos, $pos);
$this->Cell(16.4, $info['height'],  $text, 0, 0,'R',0,'',0,0,'T','M');
$pos += $info['height'];
}
$hPos += $wd;
$col++; 
}

 pdf列の繰り返し

1行での列の繰り返しであり、行の繰り返しの中で列の繰り返しもある。

これだと対応できない。

行の繰り返しと列の繰り返しをどう融合させるか?

二次元配列で実装することにした。

Excelでの変数定義は、「{$配列名配列名1][変数名]}」で配列名1は列の配列で使用することにした。

Excelの定義と出力定義ファイルとindex.phpは次のようになる。

  excel二次元定義

tcpdf定義ファイル
// 行の高さ
$hi = 6.5;
// 行の開始位置
$vPos = 19.4;
$row = 2;
$maxRow = 5;
foreach ($this->_pdf_vars['lp1'] as $key) {
// 列の幅
$wd = 31.7;
// 行高さ
$hi = 6.5;
// 列の開始位置
$col = 2;
$maxCol = 7;
foreach($key as $key1) {
foreach($key1 as $key2) {
$hPos=9.8;
for ($ix= 0;$ix < count($key2['kin']); $ix++) {
$source = $key2['kin'][$ix];
$this->Rect($hPos, $vPos,$wd, $hi,'F','',array(226,239,218));
$this->SetTextColor(0,0,0);
$this->SetXY($hPos, $vPos);
$this->Cell( $wd, $hi, $source, 0, 0,'R',0,'',0,0,'T','M');
$hPos += $wd;
$col++; 
}
$vPos += $hi;
$row++;
}
}
index.php
$lp = array();
for ($iy= 1; $iy < 5;$iy++) {
$lpdata=array();
for($ix=1; $ix< 7; $ix++){
//列の代入   $lpdata['kin'][] = $iy.-$ix; }
//行の代入 $lp['mon'][] = $lpdata; } $pdf->append("lp1",$lp);

 果たして、tcpdfで出力結果は

  f:id:sesjk:20200514162514p:plain

背景色が先頭行と同じになってしまうが、これは先頭行の繰り返しであるので、仕様(仕方ない)と考え妥協する。

 

折り返して全体表示

 ジェネレーターでは対応できないので、PHPでPDFを出力時に処理する必要がある。 

これは、PHPでPDF出力 5(縮小・折り返しで全体表示)で作成した関数「adjustToHeight」を修正した。

 

/*******************************************************************

折り返して表示

 $source:文字列, $pos:開始文字位置, $maxwidth:表示エリア幅,

    $width:表示する幅, $height:行の高さ

   $font:使用するフォント名, $fontsize:使用するフォントサイズ

  $count:セルに収まる1行当たりの文字数

********************************************************************/

public function adjustToHeight($source, $pos, $maxwidth, $width, $height, $font, $fontsize,$count) {

$info = array();

$text = mb_substr($source,$pos, null,"UTF-8");

$size = $fontsize;

$info["text"] = $text;
$info["height"] = $hei;
$info["length"] = -1;

if ($pos == 0) {
$info["height"] = $height;

//セルに収まるフォントサイズを算出
$limt = $maxwidth * $height;
while(1) {
//文字高さを取得
$hei = $this->getStringHeight(0,mb_substr($text,0,1,"UTF-8"));
//文字列幅を取得
$wid = $this->getStringWidth($text,$font,"",$size);
// 必要セル数
$needWidth = ceil*1 {
//フォントサイズを下げる
$size -= 1;
if ($size < 7) break;
$this->SetFont($font, '',$size);
} else {
break;
}
}
} else {
$hei = $this->getStringHeight(0,mb_substr($text,0,1,"UTF-8"));
}

$arrlen = $this->GetStringWidth($text,"","","",true);

if ($count == 1 && $pos > 0) {
// 1行1文字
$info["text"] = mb_substr($text,0,1,"UTF-8");
$info["height"] = $hei;
$info["length"] = 1 + $pos;
$info["count"] = 1;
if (count($arrlen) == 1) {
$info["length"] = -1;
}
return $info;
}

$len = 0;
//文字列がセルに収まるかのチェック
if ($this->GetStringWidth($text) > $maxwidth) {
$blktxt = $text;
$text="";
for ($j =0; $j < count($arrlen); $j++) {
$len += $arrlen[$j];
if ($len > $width) {
$info["text"] = $text;
$info["height"] = $hei;
$info["length"] = $j + $pos;
$info["count"] = $j;
break;
}
$text .= mb_substr($blktxt,$j,1,"UTF-8");
}
if ($j == count($arrlen)) {
$info["length"] = -1;
}
}

return $info;
}

 

*1:$wid+0.5) / $maxwidth);

if ($limt <= ($hei * $wid

PHPでPDF出力(tcpdf) 8 (実行そして課題)

8.ジェネレーターの実行そして課題

 ほぼ形は整ったので、実行してみた。

ジェネレーターで出力した定義ソースと実行結果

<?php 
Class tcpDefine extends tcpdfEditer {

public function setHeader() {
//ヘッダー・フッター印刷しない
$this->setPrintHeader(false);

$this->setPrintFooter(0);
$this->setHeaderMargin(0);
$this->setFooterMargin(0);
//余白
$this->SetMargins(4,2,-1,true);

}

public function newPage() {
//ページ追加
$this->AddPage('L','A4');

}
public function setPage() {
//自動改ページ オフ
$this->SetAutoPageBreak(False, 0);

$a = $this->GetX();
$b = $this->GetY();
$vPos=2;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',11);
$this->SetTextColor(0,0,0);
$source ='受 注 日';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(19,8, $source, 0, 0,'C',0,'',0,0,'T','M');
////
$vPos=2;
$hPos=24;
$source ='図        番';
$pos = $vPos;
$info = $this->adjustToWidth($source, 54,kozgopromedium,11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(54,8, $source, 0, 0,'C',0,'',0,0,'T','M');
////
$vPos=2;
$hPos=77.5;
$source ='個数';
$pos = $vPos;
$info = $this->adjustToWidth($source, 11,kozgopromedium,11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(11,8, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=2;
$hPos=88.2;
$source ='単  価';
$pos = $vPos;
$info = $this->adjustToWidth($source, 18,kozgopromedium,11);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(18,8, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=2;
$hPos=106.1;
$source ='納  期';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(22,8, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=2;
$hPos=128;
$source ='回数';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(13,8, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=2;
$hPos=163;
$this->SetFont('kozgopromedium', '',24);
$source ='製 造 指 示 書';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(76,14, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=2;
$hPos=246;
$this->SetFont('kozgopromedium', '',11);
$source =$this->_pdf_vars['No'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(13,8, $source, 0, 0,'R',0,'',0,0,'T','M');
//
$vPos=9.5;
$hPos=5.1;
$source =$this->_pdf_vars['day'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(8,13, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=9.5;
$hPos=13.3;
$this->SetFont('kozgopromedium', '',22);
$this->SetTextColor(255,0,0);
$source ='Ⅹ';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(11,13, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=9.5;
$hPos=24;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(0,0,0);
$source =$this->_pdf_vars['zuban'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 43,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(43,13, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=9.5;
$hPos=77.5;
$source =$this->_pdf_vars['kosuu'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(11,13, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=9.5;
$hPos=88.2;
$source =$this->_pdf_vars['tanka'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 18,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(18,13, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=9.5;
$hPos=106.1;
$source =$this->_pdf_vars['nouki'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(22,13, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=9.5;
$hPos=128;
$source =$this->_pdf_vars['kaisuu'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(13,13, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=22.9;
$hPos=163;
$this->SetFont('kozgopromedium', '',12);
$source ='検査部';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(26,8, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=22.9;
$hPos=189;
$source ='製造部';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(26,8, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=22.9;
$hPos=215;
$source ='設計部';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(24,8, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=25.9;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',14);
$source ='正';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(8,12, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=25.9;
$hPos=13.3;
$this->SetFont('kozgopromedium', '',11);
$source =$this->_pdf_vars['oldday1'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(11,4, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=25.9;
$hPos=24;
$source =$this->_pdf_vars['oldday2'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(11,4, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=25.9;
$hPos=34.7;
$source =$this->_pdf_vars['oldday3'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(11,4, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=25.9;
$hPos=45.4;
$source =$this->_pdf_vars['oldday4'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(11,4, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=25.9;
$hPos=98.9;
$source ='年間予定数';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(42,4, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=30.4;
$hPos=13.3;
$this->SetFont('kozgopromedium', '',14);
$source =$this->_pdf_vars['oldsuu1'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 11,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(11,7, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=30.4;
$hPos=24;
$source =$this->_pdf_vars['oldsuu2'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 11,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(11,7, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=30.4;
$hPos=34.7;
$source =$this->_pdf_vars['oldsuu3'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 11,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(11,7, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=30.4;
$hPos=45.4;
$source =$this->_pdf_vars['oldsuu4'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 11,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(11,7, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=30.4;
$hPos=98.9;
$source ='正';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(7,12, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=37.7;
$hPos=5.1;
$source ='反';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(8,12, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=42.2;
$hPos=98.9;
$source ='反';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(7,12, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=49.5;
$hPos=5.1;
$source ='正';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(8,12, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=54;
$hPos=98.9;
$source ='MC';
$pos = $vPos;
$info = $this->adjustToWidth($source, 7,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(7,19, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=54;
$hPos=106.1;
$this->SetFont('kozgopromedium', '',18);
$source =$this->_pdf_vars['MC'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(35,19, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=61.3;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',14);
$source ='反';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(8,12, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=76.5;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',12);
$source ='材  料';
$pos = $vPos;
$info = $this->adjustToWidth($source, 19,kozgopromedium,12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(19,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=76.5;
$hPos=24;
$source ='寸   法';
$pos = $vPos;
$info = $this->adjustToWidth($source, 117,kozgopromedium,12);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(117,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=87.5;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',18);
$source =$this->_pdf_vars['zairyo'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 19,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(19,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=87.5;
$hPos=34.7;
$source =$this->_pdf_vars['sunpou'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(11,11, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=98.5;
$hPos=5.1;
$source =$this->_pdf_vars['num1'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 8,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(8,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=98.5;
$hPos=13.3;
$source =$this->_pdf_vars['sunpou1'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 86,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(86,11, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=98.5;
$hPos=106.1;
$this->SetFont('kozgopromedium', '',16);
$bgcolor='242,242,242';
$rgb = explode(',', $bgcolor);
$this->SetFillColor($rgb[0],$rgb[1],$rgb[2]);
$source ='注文';
$pos = $vPos;
$info = $this->adjustToWidth($source, 35,kozgopromedium,16);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(35,11, $source, 0, 0,'C',1,'',0,0,'T','M');
//
$vPos=109.5;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',18);
$source =$this->_pdf_vars['num2'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 8,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(8,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=109.5;
$hPos=13.3;
$source =$this->_pdf_vars['sunpou2'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 86,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(86,11, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=109.5;
$hPos=106.1;
$this->SetFont('kozgopromedium', '',26);
$source =$this->_pdf_vars['chumon'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 35,kozgopromedium,26);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(35,11, $source, 0, 0,'C',0,'',0,0,'T','T');
//
$vPos=109.5;
$hPos=143.5;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(0,102,255);
$source ='1F棚№';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=109.5;
$hPos=169.5;
$this->SetFont('kozgopromedium', '',16);
$source =$this->_pdf_vars['1Ftana'];
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(32,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=109.5;
$hPos=208.5;
$this->SetFont('kozgopromedium', '',18);
$source ='㋐ ㋒冶具方式';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(6,11, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=120.5;
$hPos=5.1;
$this->SetTextColor(0,0,0);
$source ='③';
$pos = $vPos;
$info = $this->adjustToWidth($source, 8,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(8,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=120.5;
$hPos=106.1;
$this->SetFont('kozgopromedium', '',12);
$source ='加工予定日';
$pos = $vPos;
for ($k= 0; $k != -1;  ) {
$info = $this->adjustToHeight($source, $k,7,6,11);
$k = $info['length'];
$text = $info['text'];
$this->SetXY($hPos, $pos);
$this->Cell(7, $info['height'],  $text, 0, 0,'L',0,'',0,0,'T','M');
$pos += $info['height'];
}
//
$vPos=120.5;
$hPos=143.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(0,102,255);
$source ='在庫(正)';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=120.5;
$hPos=169.5;
$source =$this->_pdf_vars['1Fzaiko'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 20,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(20,11, $source, 0, 0,'R',0,'',0,0,'T','M');
//
$vPos=120.5;
$hPos=189;
$source ='キ ズ';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=120.5;
$hPos=233;
$source ='材 料';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=120.5;
$hPos=259;
$source =$this->_pdf_vars['1Fzairyo'];
$pos = $vPos;
$info = $this->adjustToWidth($source, 18,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(18,11, $source, 0, 0,'R',0,'',0,0,'T','M');
//
$vPos=131.5;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(0,0,0);
$source ='④';
$pos = $vPos;
$info = $this->adjustToWidth($source, 8,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(8,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=131.5;
$hPos=143.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(0,102,255);
$source ='在庫(反)';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=131.5;
$hPos=189;
$source ='二次加工';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=131.5;
$hPos=233;
$source ='その他';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=142.5;
$hPos=5.1;
$this->SetFont('kozgopromedium', '',16);
$this->SetTextColor(0,0,0);
$source ='1回  - 4本';
$pos = $vPos;
$info = $this->adjustToWidth($source, 40,kozgopromedium,16);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(40,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=142.5;
$hPos=45.4;
$source ='1本  - 8個';
$pos = $vPos;
$info = $this->adjustToWidth($source, 43,kozgopromedium,16);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(43,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=142.5;
$hPos=88.2;
$source ='4本  - 32個';
$pos = $vPos;
$info = $this->adjustToWidth($source, 53,kozgopromedium,16);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(53,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=142.5;
$hPos=143.5;
$this->SetFont('kozgopromedium', '',14);
$this->SetTextColor(0,102,255);
$source ='バリ・サビ';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=142.5;
$hPos=189;
$source ='溶 接';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=158.3;
$hPos=143.5;
$this->SetFont('kozgopromedium', '',18);
$this->SetTextColor(255,0,0);
$source ='2F棚№';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,18);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=158.3;
$hPos=208.5;
$source ='㋐ ㋒';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(6,11, $source, 0, 0,'L',0,'',0,0,'T','M');
//
$vPos=169.3;
$hPos=143.5;
$this->SetFont('kozgopromedium', '',14);
$source ='在庫(正)';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=169.3;
$hPos=189;
$source ='キ ズ';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=169.3;
$hPos=233;
$source ='材 料';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=180.3;
$hPos=143.5;
$source ='在庫(反)';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=180.3;
$hPos=189;
$source ='二次加工';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=180.3;
$hPos=233;
$source ='その他';
$pos = $vPos;
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=191.3;
$hPos=143.5;
$source ='バリ・サビ';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//
$vPos=191.3;
$hPos=189;
$source ='溶 接';
$pos = $vPos;
$info = $this->adjustToWidth($source, 26,kozgopromedium,14);
$this->SetFont('kozgopromedium', '',$info);
$this->SetXY($hPos, $pos);
$this->Cell(26,11, $source, 0, 0,'C',0,'',0,0,'T','M');
//

//罫線設定
$this->Line(5.1, 2, 140.7, 2, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 9.5, 140.7, 9.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(13.3, 9.5, 13.3, 22.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(24, 2, 24, 22.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(77.5, 2, 77.5, 22.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(88.2, 2, 88.2, 22.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(106.1, 2, 106.1, 22.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(128, 2, 128, 22.9, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 22.9, 140.7, 22.9, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(163, 22.9, 239.5, 22.9, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 25.9, 140.7, 25.9, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(13.3, 30.4, 140.7, 30.4, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(163, 30.4, 239.5, 30.4, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 37.7, 98.9, 37.7, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(13.3, 42.2, 140.7, 42.2, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(163, 22.9, 163, 42.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(189, 22.9, 189, 42.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(215, 22.9, 215, 42.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(239.5, 22.9, 239.5, 42.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(163, 42.2, 239.5, 42.2, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 49.5, 98.9, 49.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(13.3, 54, 98.9, 54, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(98.9, 54, 140.7, 54, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 61.3, 98.9, 61.3, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(13.3, 65.8, 98.9, 65.8, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(13.3, 25.9, 13.3, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(24, 25.9, 24, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(34.7, 25.9, 34.7, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(45.4, 25.9, 45.4, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(56.1, 25.9, 56.1, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(66.8, 25.9, 66.8, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(77.5, 25.9, 77.5, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(88.2, 25.9, 88.2, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(98.9, 25.9, 98.9, 73.1, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(106.1, 30.4, 106.1, 73.1, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 73.1, 140.7, 73.1, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 76.5, 140.7, 76.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 87.5, 140.7, 87.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(24, 76.5, 24, 98.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 98.5, 140.7, 98.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 109.5, 106.1, 109.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(0,0,0)));
$this->Line(106.1, 108.8, 140.7, 108.8, array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(106.1, 109.5, 140.7, 109.5, array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(143.5, 109.5, 202, 109.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
//$this->Line(106.8, 98.5, 106.8, 120.5, array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(106.1, 98.5, 106.1, 120.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 120.5, 106.1, 120.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(0,0,0)));
$this->Line(106.1, 120.5, 140.7, 120.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(169.5, 109.5, 169.5, 120.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(202, 109.5, 202, 120.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(143.5, 120.5, 277, 120.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(5.1, 131.5, 106.1, 131.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 1, 'color' => array(0,0,0)));
$this->Line(143.5, 131.5, 277, 131.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(106.1, 120.5, 106.1, 142.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(113.1, 120.5, 113.1, 142.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 142.5, 140.7, 142.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(143.5, 142.5, 277, 142.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(45.4, 142.5, 45.4, 153.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(88.2, 142.5, 88.2, 153.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 153.5, 140.7, 153.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(143.5, 109.5, 143.5, 153.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(169.5, 120.5, 169.5, 153.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(189, 120.5, 189, 153.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(215, 120.5, 215, 153.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(233, 120.5, 233, 153.5, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(259, 120.5, 259, 153.5, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(277, 120.5, 277, 153.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(143.5, 153.5, 277, 153.5, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,102,255)));
$this->Line(143.5, 158.3, 202, 158.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(169.5, 158.3, 169.5, 169.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(202, 158.3, 202, 169.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(143.5, 169.3, 277, 169.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(143.5, 180.3, 277, 180.3, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(143.5, 191.3, 277, 191.3, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(5.1, 2, 5.1, 202.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(140.7, 2, 140.7, 202.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(5.1, 202.3, 140.7, 202.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(0,0,0)));
$this->Line(143.5, 158.3, 143.5, 202.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(169.5, 169.3, 169.5, 202.3, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(189, 169.3, 189, 202.3, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(215, 169.3, 215, 202.3, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(233, 169.3, 233, 202.3, array('width' => 0.4, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(259, 169.3, 259, 202.3, array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(277, 169.3, 277, 202.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
$this->Line(143.5, 202.3, 277, 202.3, array('width' => 0.6, 'cap' => 'butt', 'join' => 'miter','dash' => 0, 'color' => array(255,0,0)));
}
}

?>

 ジェネレートの処理時間は約1分ほど要した。

ブラウザでのPDF表示は、1~2秒程度で表示された。

PDF実行結果

赤枠が「折り返して全体表示」のセルであるが、はみ出してしまった。
高さによっては、フォントサイズを下げる処理が必要である。Excelで予めフォントサイズを下げておく手もあるが。

また、青枠のように列の繰り返しにはまだ対応できていない。今回はそれぞれの列に変数を定義した。

また、フォント対応が明朝とゴシックのどちらかであるが、今回はExcelのPDF化ではなく、TCPDF実行の定義ファイルの出力が目的であるので、こちらは目をつぶることにした。

因みに、表示するためのPHPのソースは

    <?php
	require_once(dirname(__FILE__)."/../lib/TCPDF-master/tcpdf.php");
	require_once(dirname(__FILE__)."/tcpdfEditer.php");
	require_once(dirname(__FILE__)."/sample1.php");

	$pdf = new tcpDefine();

	$pdf->assign('No','1');
	$pdf->assign('day','8/8');
	$pdf->assign('zuban','HFA-450-091');
	$pdf->assign('kosuu','10');
	$pdf->assign('tanka','12,000');
	$pdf->assign('nouki','9/1');
	$pdf->assign('kaisuu','5');
	$pdf->assign('oldday1','16-11');
	$pdf->assign('oldday2','17-2');
	$pdf->assign('oldday3','3');
	$pdf->assign('oldday4','6');
	$pdf->assign('oldsuu1','10');
	$pdf->assign('oldsuu2','10');
	$pdf->assign('oldsuu3','10');
	$pdf->assign('oldsuu4','10');
	$pdf->assign('MC','1');
	$pdf->assign('zairyo','S45C');
	$pdf->assign('sunpou','12x22x4000=10本');
	$pdf->assign('num1','①')
$pdf->assign('sunpou1','12x22x1130=30本=240ヶ'); $pdf->assign('num2','②')
$pdf->assign('sunpou2','残材 610=10本=40ヶ'); $pdf->assign('chumon','280ヶ'); $pdf->assign('1Ftana','ア-1'); $pdf->assign('1Fzaiko','18'); $pdf->assign('1Fzairyo','4'); //PDF出力 $pdf->setHeader(); $pdf->newPage(); $pdf->out('sample.pdf', 'I'); ?>

 

リテラルで代入しているが、DBからデータを取得して代入すればよい。

イメージ通りのものを、簡単にTCPDFで出力できるようになった。

PHPでPDF出力 7 (繰り返す行の処理)

7.繰り返す行の処理

 

下図のような明細内容を繰り返し出力する処理を追加した。

 Ecel明細出力

 繰返し範囲の設定を「{$loop}」「{$&&}」を考えてみたが、図でA列が空いているので対応できるが、A列から始まっている場合には変数名が設定できなくなる。

そこで、「{$配列名[変数名]}」「$配列名[&&]」とした。

ジェネレーターの出力は、以下の仕様にした。

foreach ($this->_pdf_vars['loop'] as $key) {

$this->Cell(56,7, $key['hinmei'], 0, 0,'L',1,'',0,0,'T','M');

}

 

PHP側の変数代入はSmartyのappend風にしてみた。

index.phpで、

$lpdata = array("hinmei"=>"パソコ","suuryo"=>"2","tanka"=>"65,000",

"tani"=>"台","kingaku"=>"143,000","bikou"=>"");

$pdf->append("loop",$lpdata);

$lpdata = array("hinmei"=>"パソコン","suuryo"=>"2","tanka"=>"65,000",

"tani"=>"台","kingaku"=>"143,000","bikou"=>"");

$pdf->append("loop",$lpdata);

 

代入編集クラスにメソッドを追加

public function append($array_var, $value = null) {
$this->_pdf_vars[$array_var][] = $value;
}

Excelの定義と出力結果は、

pdf繰り返し行

 残念ながら、背景色が全ての行で同じになってしまった。

また、売上金額と内税がおかしいのて、index.phpでの代入の間違いである。

繰り返しは、1行間隔で変わると割り切り1行目と2行目の背景色を予め取得して、奇数偶数行で背景色を設定する仕様にした。

今度は、思い通りに出力された。

 f:id:sesjk:20200503144248p:plain

改ページは、TCPDFに「AddPage(用紙方向(P:縦 L:横)、用紙サイズ)」が用意されている。

ジェネレーターで次のように出力している。

public function newPage() {
//ページ追加
$this->AddPage('L','A4');

}

適宜、newPageを呼び出せば改ページとなる。

大分形が整ってきた。

 

 

PHPでPDF出力 6(PDF出力のクラス化)

6.PDF出力のクラス化

「縮小して全体を表示する」と「折り返して全体を表示する」ための関数をPDF出力側に作成した。

もっと使い勝手を良くするためにクラス化に修正した。

実行していた「index.php」のソースである。

<?php
require_once(dirname(__FILE__)."/../lib/TCPDF-master/tcpdf.php");
$tcpdf = new TCPDF();
【 ここに、ジェネレーター出力定義を貼り付け 】
$tcpdf->Output('samurai.pdf', 'I');
public function adjustToWidth($source, $width, $font, $size) {
global $tcpdf;
}
public function adjustToHeight($source, $pos, $maxwidth, $width, $height) {
global $tcpdf;
}
?>

その前に、Excelの「発注日」「図番」等は入力項目の可変である。

Excelに変数情報を埋め込むことにした。

Excel変数埋め込み

 変数の識別に「{$}」を使うことにし、上記のように変数を設定した。

想定したのは、以下のような処理である。

$day='8/8';
:
$source =$day;
$info = $tcpdf->adjustToWidth($source, 35,kozgopromedium,12);
$tcpdf->SetFont('kozgopromedium', '',$info);
$tcpdf->SetXY($hPos, $pos);
$tcpdf->Cell(35,8, $source, 0, 0,'L',0,'',0,0,'T','M');

 

これで変数が多くなると可読性に問題でてくる。

いっそのこと、TCPDFの定義ファイルも関数にすれば、可読性の問題は解決できる。

代入編集処理をTCPDFの継承クラスにすることにした。また、定義ファイルは代入編集処理の継承クラスで作成した。

Class tcpdfEditer extends TCPDF {
var $pdf;
public function tcpdfEdit() {
$pdf = new TCPDF();
}
//変数に代入するメソッド 
public function assign($var, $value=null) {
}
//PDF出力メソッド 
public function out($pdfname, $dest) {
$this->Output($pdfname, $dest);
}
}
定義ファイルのクラス
Class tcpDefine extends tcpdfEditer {
}

変数を代入するメソッドは、Smartyのassign風にしてみた。

 $this->assign('day','8/8');

修正後のindex.php

<?php
require_once(dirname(__FILE__)."/../lib/TCPDF-master/tcpdf.php");
// tcpdf編集用
require_once(dirname(__FILE__)."/tcpdfEditer.php");
// tcpdf定義ファイル
require_once(dirname(__FILE__)."/smaple.php");
$pdf = new tcpDefine();
$pdf->assign('day','8/8');
$pdf->assign('zuban','JFA-550-081');
$pdf->assign('kosuu','10');
$pdf->assign('tanka','12,000');
$pdf->assign('nouki','9/5');
$pdf->assign('kaisuu','12');
$pdf->out('sample.pdf', 'I');
?>

 結果は上々。

      代入結果PDF

また疑問が。

請求明細書のように明細内容を繰り返しをどうするか? 改ページは?

まだまだクリアすべきことが山積み。

次回は、明細の繰り返しの処理追加

 

  

PHPでPDF出力 5(縮小・折り返しで全体表示)

5.「縮小・折り返して全体を表示する」の処理の追加

文字表示の体裁も罫線もは整ったのだが、Excelのセル書式には、「縮小して全体を表示する」と「折り返して全体を表示する」のオプションがある。

ジェネレーターでは、値が可変の場合に対応できないため、PHP側で出力時に定義することになる。

 

 TCPDFには、文字列を出力する時の幅と高さを取得する関数が用意されている。

getStringWidth(セル幅、文字列)

getStringHeight(文字列、フォント名、フォントスタイル、フォントサイズ、文字単位)

出力するセル幅はと高さはジェネレーターで取得し、Cell関数に引数として渡している。

 

縮小して全体を表示は、

セル幅に出力する文字列が収まるかを判定し、収まらない場合はフォントサイズを下げて再度セル幅をチェックすればいい。

関数化したソースは以下のようになる。

-----------------------------------------------------------------------------

//$source:文字列, $width:表示する幅, $font:フォント名, $size:フォントサイズ

public function adjustToWidth($source, $width, $font, $size) {

global $tcpdf;

$text = mb_substr($source,$pos, null,"UTF-8");

$fontsize = $size;
while(1) {

// $width - 0.5は、二重線対応(0.5ミリずらす)

if ($tcpdf->GetStringWidth($text,$font,"",$fontsize) <= ($width-0.5)) {

break;

} else {

$fontsize = $fontsize - 1;

//フォントサイズの最小は6ポイントに設定

if ($fontsize < 7) break; }


return $fontsize;

}

-----------------------------------------------------------------------------

  

折り返して全体を表示は、

セル幅に出力する文字列が収まるかの判定は、「縮小して全体を表示」と同じであるが、オーバーした文字列を改行して表示する必要がある。

残念ながら、TCPDFにはセル内改行の機能はないので、縦横の座標を変えて表示することとした。

-----------------------------------------------------------------------------

//$source:文字列, $pos:開始文字位置, $maxwidth:表示エリア幅, $width:表示する幅, $height:行の高さ

 public function adjustToHeight($source, $pos, $maxwidth, $width, $height) {

global $tcpdf;
$info = array();     //連想配列で返す
$text = mb_substr($source,$pos, null,"UTF-8");
//文字高さを取得

$hei = $tcpdf->getStringHeight(0,mb_substr($text,0,1,"UTF-8"));

$info["text"] = $text;  //表示する文字列

$info["height"] = $hei;   //高さ

$info["length"] = -1;  //折り返す文字数  -1:折り返しなし

if ($pos == 0 ) {

$info["height"] = $height;

}

//文字列の文字単位で幅を配列で取得
$arrlen  = $tcpdf->GetStringWidth($text,"","","",true);
$len = 0;

if ($tcpdf->GetStringWidth($text) > $maxwidth) {

$blktxt = $text;

$text="";

for ($j =0; $j < count($arrlen); $j++) {

$len += $arrlen[$j];

if ($len > $width) {

$info["text"] = $text;

$info["height"] = $hei;

$info["length"] = $j + $pos;

break;

}

$text .=  mb_substr($blktxt,$j,1,"UTF-8");

}

if ($j == count($arrlen)) {

$info["length"] = -1; }

}
return $info;

}

----------------------------------------------------------------------------- 

ジェネレーターを下記のソース出力に修正する。

$source ='120000';
$info = adjustToWidth($source, 18,kozgopromedium,18);
$tcpdf->SetFont('kozgopromedium', '',$info);
$tdpdf->SetXY($hPos, $pos);
$tcpdf->Cell(18,13, $source, 0, 0,'C',0,'',0,0,'T','M');

 

結果は、サイズが微妙に大きくなるが、ほぼ満足いくものであったが、

折り返して全体を表示するで、後に問題が発生する。

   adjustの結果

 ジェネレーターで出力された定義をコピペで、PHPソースに貼り付けているのを、

ファイル出力で渡すことにした。

また、Excelは項目は固定ではなく可変であることを考慮して、関数はクラスに変更する。

次回は、それらをメモる。