fpdf를 사용하여 pdf에 텍스트를 추가합니다. 텍스트를 추가 할 수 있지만 pdf 페이지의 크기는 항상 A4입니다. 업로드 된 pdf 방향이 가로 방향 인 경우 세로로 표시됩니다. pdf에 writting하기위한 업로드 된 pdf의 widht와 height 및 orientation을 사용하고 싶습니다.fpdf 설정 높이와 방향을 자동으로
$fullPathToFile = $target_path;
class custom_PDF extends FPDI {
var $_tplIdx;
var $file;
function Header() {
if (is_null($this->_tplIdx)) {
// THIS IS WHERE YOU GET THE NUMBER OF PAGES
$this->numPages = $this->setSourceFile($this->file);
$this->_tplIdx = $this->importPage(1);
}
$this->useTemplate($this->_tplIdx, 0, 0, 200);
}
function Footer() {
}
function setFile($param) {
$this->file = $param;
}
}
$pdf234 = new custom_PDF();
$pdf234->setFile($fullPathToFile);
$pdf234->AddPage();
$pdf234->SetAutoPageBreak(TRUE, 0);
$pdf234->SetY(280);
$pdf234->SetFont("helvetica", "B", 8);
$pdf234->SetTextColor(0, 0, 0);
$utf8text = $current_user->user_login . "(" . str_ireplace('_', ' ', $current_user->roles[0]) . ")," . get_bloginfo('name') . "," . get_bloginfo('url') . "" . date("d M Y,h:i:s a");
$pdf234->Write(5, $utf8text, get_bloginfo('url'));
if ($pdf234->numPages > 1) {
for ($i = 2; $i <= $pdf234->numPages; $i++) {
//$pdf->endPage();
$pdf234->_tplIdx = $pdf234->importPage($i);
$pdf234->AddPage();
$pdf234->SetAutoPageBreak(TRUE, 0);
$pdf234->SetY(280);
$pdf234->Write(5, $utf8text, get_bloginfo('url'));
}
}
$pdf234->Output($line['name'], 'D');
die();
다음 코드도 시도 : 이제 가로 모드하지만 내용의 전체 page.content을 점유하지 않는에서
$specs = $pdf234->getTemplateSize($pdf234->_tplIdx);
$pdf234->AddPage('L',$specs);
내 PDF가 왼쪽 상단에 정렬됩니다.
'$ 사양 = $ pdf234-> getTemplateSize ($의 pdf234 -> _ tplIdx); $ pdf234-> AddPage ('L', $ specs); ' 내 PDF는 가로 모드로 표시되지만 콘텐츠는 전체 페이지를 차지하지 않습니다. 콘텐츠가 왼쪽 상단에 정렬됩니다. – Kavita