|
|
@@ -5,6 +5,7 @@ namespace app\common\service\watermark\pdf;
|
|
|
use Mpdf\Mpdf;
|
|
|
use Mpdf\Config\ConfigVariables;
|
|
|
use Mpdf\Config\FontVariables;
|
|
|
+use TCPDF;
|
|
|
|
|
|
/**
|
|
|
* Class Pdf
|
|
|
@@ -26,10 +27,10 @@ class Pdf
|
|
|
// $pageCount = $pdf->setSourceFile($filePath);
|
|
|
//
|
|
|
// for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
|
|
|
-// $templateId = $pdf->importPage($pageNo);
|
|
|
+//$templateId = $pdf->importPage($pageNo);
|
|
|
// $pdf->AddPage();
|
|
|
// $pdf->useTemplate($templateId, ['adjustPageSize' => true]);
|
|
|
-// $size = $pdf->getTemplateSize($templateId);
|
|
|
+//$size = $pdf->getTemplateSize($templateId);
|
|
|
// $center_x = $size['width'] / 2;
|
|
|
// $center_y = $size['height'] / 2;
|
|
|
// $pdf->SetXY($center_x, $center_y);
|
|
|
@@ -57,7 +58,7 @@ class Pdf
|
|
|
* @throws \setasign\Fpdi\PdfParser\PdfParserException
|
|
|
* @throws \setasign\Fpdi\PdfParser\Type\PdfTypeException
|
|
|
*/
|
|
|
- public function waterMark($filePath, $waterText, $type = 0, $waterText2 = '')
|
|
|
+ public function waterMark($filePath, $waterText, $type = 0, $waterText2 = '', $pageWidth = 210, $pageHeight = 297)
|
|
|
{
|
|
|
$defaultConfig = (new ConfigVariables())->getDefaults();
|
|
|
$fontDirs = $defaultConfig['fontDir'];
|
|
|
@@ -66,7 +67,8 @@ class Pdf
|
|
|
$mpdf = new Mpdf(['mode' => '+aCJK',
|
|
|
'fontDir' => array_merge($fontDirs, [__DIR__.'/fonts']),
|
|
|
'fontdata' => $fontData + ['msyh' => ['R' => 'msyh.ttf',],],
|
|
|
- 'default_font' => 'msyh'
|
|
|
+ 'default_font' => 'msyh',
|
|
|
+ 'format' => [$pageWidth, $pageHeight],
|
|
|
]);
|
|
|
$mpdf->autoScriptToLang = true;
|
|
|
$mpdf->autoLangToFont = true;
|