77 lines
2.9 KiB
PHP
77 lines
2.9 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
use Gregwar\Image\Image;
|
|
|
|
use TencentCloud\Common\Credential;
|
|
use TencentCloud\Common\Profile\ClientProfile;
|
|
use TencentCloud\Common\Profile\HttpProfile;
|
|
use TencentCloud\Common\Exception\TencentCloudSDKException;
|
|
use TencentCloud\Ocr\V20181119\OcrClient;
|
|
use TencentCloud\Ocr\V20181119\Models\IDCardOCRRequest;
|
|
class Test extends CI_Controller {
|
|
|
|
public function index(){
|
|
$name= 'car_fh';
|
|
$url = "https://liche-api-dev.xiaoyu.com/wxapp/licheb/protocol/".$name;
|
|
$path = FCPATH.'temp/pdf/';
|
|
$filename = $name.'.pdf';
|
|
if (!file_exists($path)){
|
|
$oldumask = umask(0);
|
|
mkdir($path, 0777, true); umask($oldumask);
|
|
}
|
|
$arrContextOptions=array(
|
|
"ssl"=>array(
|
|
"verify_peer"=>false,
|
|
"verify_peer_name"=>false,
|
|
),
|
|
);
|
|
$html = file_get_contents($url,false,stream_context_create($arrContextOptions));
|
|
require_once COMMPATH.'/third_party/TCPDF/tcpdf.php';
|
|
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,true, 'UTF-8', false);
|
|
$pdf->SetCreator(PDF_CREATOR);
|
|
$pdf->SetAuthor("jmcx");
|
|
|
|
$pdf->setPrintHeader(false);
|
|
|
|
$pdf->setPrintFooter(false);
|
|
|
|
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
|
|
|
$pdf->SetMargins(PDF_MARGIN_LEFT, 5,PDF_MARGIN_RIGHT);
|
|
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
|
|
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
|
|
|
|
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
|
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
|
$pdf->SetFont('stsongstdlight', '', 10); //设置中文显示
|
|
$pdf->AddPage();
|
|
$pdf->writeHTML($html, true, false, true, false, '');
|
|
$pdf->Output($path.$filename,'F');
|
|
}
|
|
|
|
public function pdf2img(){
|
|
$pdf = 'http://liche-api-dev.xiaoyu.com/temp/pdf/car_fh.pdf';
|
|
$pdf2img_url = 'http://liche-api-dev.xiaoyu.com/jar/pdf2img';
|
|
$this->load->library('mycurl');
|
|
$url = $pdf2img_url.'?furl='.$pdf;
|
|
$res = $this->mycurl->httpGet($url);
|
|
var_dump($res);
|
|
}
|
|
|
|
public function save_img(){
|
|
$img = 'https://liche-api-dev.xiaoyu.com/pdf2img/2021-07-07/1889917037729102438059_0.png';
|
|
//if(!$_FILES['file']){
|
|
// echo '参数错误';exit;
|
|
//}
|
|
$this->load->library('receiver/sign_entity');
|
|
//$res = $this->sign_entity->merge($img,$_FILES['file'],1050,1550,300); //协议
|
|
$res = $this->sign_entity->test($img,$_FILES['file']=222,1050,1550,300); //协议
|
|
//$res = $this->sign_entity->test($img,$base64_img,1050,200,300); //整车
|
|
//$res = $this->sign_entity->test($img,$base64_img,1050,400,300); //确认单
|
|
//$res = $this->sign_entity->test($img,$base64_img,300,1400,'','',false); //车辆交接信息
|
|
echo $res;
|
|
}
|
|
|
|
}
|