input->post('file_url'); $fill_data = $this->input->post('fill_data'); if(!$file_url || !$fill_data){ die(json_encode(['code'=>0,'msg'=>'参数错误'])); } $fill_data = json_decode($fill_data,true); $url = base64_decode(urldecode($file_url)); $file_path = FCPATH.'tmp.pdf'; $arrContextOptions = [ "ssl" => [ "verify_peer"=>false, "verify_peer_name"=>false, ], ]; $file = file_get_contents($file_url,false,stream_context_create($arrContextOptions)); file_put_contents($file_path, $file); if(file_exists($file_path)){ $pdf = new Pdf($file_path); $result = $pdf->fillForm($fill_data)->needAppearances()->saveAs('fill.pdf'); if ($result === false) { die(json_encode(['code'=>0,'msg'=>$pdf->getError()])); }else{ $data = [ 'file_path' => http_host_com('api').'/fill.pdf', ]; @unlink($file_path); die(json_encode(['code'=>1,'msg'=>'保存成功','data'=>$data])); } }else{ die(json_encode(['code'=>0,'msg'=>'保存文件失败'])); } } }