Compare commits
3 Commits
02704cdd36
...
eb358d49f0
| Author | SHA1 | Date |
|---|---|---|
|
|
eb358d49f0 | 9 months ago |
|
|
150004c557 | 9 months ago |
|
|
acf710de60 | 9 months ago |
16 changed files with 200 additions and 25 deletions
@ -0,0 +1,57 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\service\core\contract_sign; |
|||
|
|||
|
|||
use PhpOffice\PhpWord\TemplateProcessor; |
|||
use core\base\BaseCoreService; |
|||
|
|||
/** |
|||
* 素材管理服务层 |
|||
* Class CoreAttachmentService |
|||
* @package app\service\core\sys |
|||
*/ |
|||
class ContractSign extends BaseCoreService |
|||
{ |
|||
public function setSign($templatePath,$outputPath,$signImagePath,$placeholder) |
|||
{ |
|||
// $templatePath = root_path() . 'public/upload/attachment/document/document/202507/03/1751535235ccad2afa1b71ee025dc8087942058957_local.docx'; |
|||
// $outputPath = root_path() . 'public/uploads/result_signed.docx'; |
|||
// $signImagePath = root_path() . 'public/uploads/student_sign.png'; |
|||
|
|||
$tempImagePath = root_path() . '/public/upload/'.date("YmdHis").time() .'.jpg'; |
|||
|
|||
$imageContent = file_get_contents($signImagePath); |
|||
if ($imageContent === false) { |
|||
exit('图片下载失败'); |
|||
} |
|||
file_put_contents($tempImagePath, $imageContent); |
|||
|
|||
if (!file_exists($templatePath)) { |
|||
exit('模板文件不存在'); |
|||
} |
|||
|
|||
$templateProcessor = new TemplateProcessor($templatePath); |
|||
|
|||
$templateProcessor->setImageValue($placeholder, [ |
|||
'path' => $tempImagePath, |
|||
'width' => 120, |
|||
'height' => 50, |
|||
'ratio' => false, |
|||
]); |
|||
|
|||
$templateProcessor->saveAs($outputPath); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue