如何使用 fpdi 添加页眉(徽标)和页脚(带有页码的徽标) 或者如果您建议任何其他类似 tcpdf 的文件,请给我任何 tcpdf.php 文件的 CDN 链接(如果可能)
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
use setasign\Fpdi\Fpdi;
use setasign\Fpdi\PdfReader;
require_once('fpdf/fpdf.php');
require_once('fpdi/src/autoload.php');
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('logo.png',10,6,30);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(30,10,'Title',1,0,'C');
// Line break
$this->Ln(20);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$pdf = new Fpdi();
//first page
$pageCount = $pdf->setSourceFile('generated.pdf');
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId);
$pdf->addPage();
$pdf->Ln(60);
$pdf->SetFont('Arial','B',34);
$pdf->Cell(189,10,'Tender Details',0,1,'C');
$pdf->Ln(20);
$heading="";
$ttitle="";
$tno="";
$tdate="";
$itemname="123gytfytfytfytftyfyty";
$pdf->SetFont('Arial','B',20);
$pdf->Cell(30);
$pdf->Cell(170,5,'Heading- '.$heading.'',0,1);
$pdf->Ln(10);
$pdf->Cell(30);
$pdf->Cell(170,5,'Tender Title- '.$ttitle.'',0,1);
$pdf->Ln(10);
$pdf->Cell(30);
$pdf->Cell(170,5,'Tender Number- '.$tno.'',0,1);
$pdf->Ln(10);
$pdf->Cell(30);
$pdf->Cell(170,5,'Tender Date- '.$tdate.'',0,1);
$pdf->Ln(10);
$pdf->Cell(30);
$pdf->Cell(170,5,'Item Name- '.$itemname.'',0,1);
$cd="We are from Ascentech Lightening Solution, a MSME firm, manufacturer of LED Lights along with Medical Lights and Emergency Lights. We have participated in your tender 2021-01-06. Please find below list of documents for the same.";
$pdf->addPage();
$pdf->Ln(30);
$pdf->SetFont('times','B',12);
$pdf->Write(5,$cd);
$pdf->Ln(10);
$pdf->SetFont('times','BU',12);
$pdf->Cell(170,5,'Item Name- ',0,1);
$pdf->Ln(5);
$pdf->SetFont('times','B',12);
$pdf->Cell(170,5,$itemname,0,1);
$pdf->Ln(15);
$pdf->SetFont('times','BU',24);
$pdf->Cell(189,10,'Technical Specification Acceptance',0,1,'C');
$pdf->Ln(7);
$pdf->Cell(189,10,'Item name test',0,1,'C');
$pdf->Ln(5);
$pdf->SetFillColor(224,235,255);
$pdf->SetFont('Arial','B',12);
$pdf->SetX(25);
$pdf->Cell(15,10,'Sr. no',1,0,'C',1);
$pdf->Cell(90,10,'Technical Specification',1,0,'C',1);
$pdf->Cell(30,10,'Values',1,0,'C',1);
$pdf->Cell(30,10,'Offered',1,0,'C',1);
//$pdf->Cell(18,10,'Browse',1,0,'C',1);
//$pdf->Cell(45,10,'Browse Documents',1,0,'C',1);
$pdf->SetFont('Arial','',12);
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->addPage();
$pdf->SetFont('times','BU',24);
$pdf->Ln(30);
$pdf->Cell(189,10,'Item name test1',0,1,'C');
$pdf->Ln(5);
$pdf->SetFillColor(224,235,255);
$pdf->SetFont('Arial','B',12);
$pdf->SetX(25);
$pdf->Cell(15,10,'Sr. no',1,0,'C',1);
$pdf->Cell(90,10,'Technical Specification',1,0,'C',1);
$pdf->Cell(30,10,'Values',1,0,'C',1);
$pdf->Cell(30,10,'Offered',1,0,'C',1);
//$pdf->Cell(18,10,'Browse',1,0,'C',1);
//$pdf->Cell(45,10,'Browse Documents',1,0,'C',1);
$pdf->SetFont('Arial','',12);
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Ln(10);
$pdf->SetX(25);
$pdf->Cell(15,10,'1',1,0,'C');
$pdf->Cell(90,10,'test',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
$pdf->Cell(30,10,'yes',1,0,'C');
// get the page count
$pageCount = $pdf->setSourceFile('generated.pdf');
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size[0] > $size[1]) {
$pdf->AddPage('L', array($size[0], $size[1]));
} else {
$pdf->AddPage('P', array($size[0], $size[1]));
}
// use the imported page
$pdf->useTemplate($templateId);
$pdf->SetFont('Helvetica');
$pdf->SetXY(5, 5);
$pdf->Write(8, 'By me');
}
$pdf->addPage();
// get the page count
$pageCount = $pdf->setSourceFile('generated.pdf');
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size[0] > $size[1]) {
$pdf->AddPage('L', array($size[0], $size[1]));
} else {
$pdf->AddPage('P', array($size[0], $size[1]));
}
// use the imported page
$pdf->useTemplate($templateId);
$pdf->SetFont('Helvetica');
$pdf->SetXY(5, 5);
$pdf->Write(8, 'By me');
}
$pdf->Output();
?>
如何使用 fpdi 添加页眉(徽标)和页脚(带有页码的徽标) 或者如果您建议使用其他任何类似 tcpdf 的文件。
您可以在此处查看此文件的部署版本 (http://twenfluence.tech/pdf/pdf.php)