2

助けを期待しています。以下のphpを使用して4つのことをしようとしています。最初の長いチャンクは、sig.pdf テンプレートに署名画像を追加します。2 番目のチャンクは、私の template3.pdf テンプレートのフォーム フィールドを埋めます。3 番目のチャンクは、両方のファイルをマージする必要があります。そして、4 番目のチャンクは、マージされた pdf を電子メールで送信します。

1 と 4 は単独で動作し、2 と 4 は単独で動作します。

1、2、および 4 を一緒に使用すると、2 つの別個の PDF が作成されますが、電子メールは送信されません。

3 決して機能しません。次のエラーが表示されます。

Fatal error: Uncaught exception 'Exception' with message 'object [1] non trouve' in /home/content/.../html/pdf2/fpdf_merge.php:74 Stack trace: #0 /home/content/.../html/pdf2/fpdf_merge.php(214): FPDF_Merge->error('object [1] non ...') #1 /home/content/.../html/pdf2/fpdf_merge.php(615): FPDF_Merge->getObject(Resource id #23, Array, '1') #2 /home/content/.../html/pdf2/fill.php(79): FPDF_Merge->add('qaf.pdf') #3 {main} thrown in /home/content/.../html/pdf2/fpdf_merge.php on line 74 

これは、qaf.pdf が 7 ページの長さであることが原因である可能性があると推測していますが、それに関するドキュメントは見つかりませんでした。

だから私の質問は:

1) 私の 2 つのドキュメントで fpdf_merge.php を動作させるにはどうすればよいですか?

2) 1 番目と 2 番目のプロセスの両方を使用すると、電子メール プロセスが機能しないのはなぜですか?

どういうわけか私は物事がうまくいかないと思います。しかし、phpでそれをトラブルシューティングする方法がわかりません。

手がかりをありがとう!!

注: この投稿を読みやすくするために、コメント (他の人のすばらしい仕事) を削除しました。それらは私の作業スクリプトに保持されます。

ここに相互投稿: http://www.fpdf.org/phorum/read.php?f=1&i=60395&t=60395

1:

$s = new signature; 
$s->use_template_pdf('signed','sig'); 
$s->delete_signature(); 
class signature { 
var $pdf; 
var $hash; 
var $image; 
function __construct(){ 
require('fpdf/fpdf.php'); 
require('fpdi/fpdi.php'); 
$this->make_hash(); 
$this->make_signature(); 
} 
function make_hash(){ 
$this->hash = uniqid(); 
} 
function make_signature(){ 
if(isset($_POST['img'])){ 
$arr = explode(',',$_POST['img']); 
$this->image = "image{$this->hash}.png"; 
if(is_writable(dirname(__FILE__))){ 
file_put_contents($this->image, base64_decode($arr[1])); 
}else{ 
die('<p>The working directory is not writable, abort.</p>'); 
} 
} 
} 
function delete_signature(){ 
if(file_exists($this->image)) @unlink($this->image); 
} 
function use_template_pdf($filename, $template){ 
$this->pdf = new FPDI(); 

$pagecount = $this->pdf->setSourceFile($template.'.pdf'); 
$tplidx = $this->pdf->importPage(1); 
$this->pdf->addPage(); 
$this->pdf->SetXY(90, 260); 
$this->pdf->Write(5,"Signature: "); 
$this->pdf->useTemplate($tplidx, 10, 10); 
$this->pdf->Image($this->image,125,260,-200); 
if(is_writable(dirname(__FILE__))){ 
$this->pdf->Output($filename.'.pdf', 'F'); 
}else{ 
$this->pdf->Output($filename.'.pdf', 'I'); 
} 
$this->pdf = NULL; 
} 
} 

2:

require('fpdm/fpdm.php'); 
$fields = array( 
'cascade' => $_POST['_fid_6'], 
'structuretype' => $_POST['_fid_7'], 
'marketmanager' => $_POST['_fid_8'], 
); 
$pdf = new FPDM('template3.pdf'); 
$pdf->Load($fields, false); 
$pdf->Merge(); 
$pdf->Output('qaf.pdf', 'F'); 

3:

require('fpdf_merge.php'); 
$merge = new FPDF_Merge(); 
$merge->add('qaf.pdf'); 
$merge->add('signed.pdf'); 
$merge->output('qaf-final.pdf', 'F'); 

4:

$to = $_POST['_fid_6']; 
$from = "qaf@me.com"; 
$subject = "Your QAF"; 
$separator = md5(time()); 
$eol = PHP_EOL; 
$filename = "qaf-final.pdf"; 
$pdfdoc = $pdf->Output("", "S"); 
$attachment = chunk_split(base64_encode($pdfdoc)); 
$headers = "From: ".$from.$eol; 
$headers .= "MIME-Version: 1.0".$eol; 
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\""; 
$body = "--".$separator.$eol; 
$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol; 
$body .= "Here is your QAF.".$eol; 
$body .= "--".$separator.$eol; 
$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; 
$body .= "Content-Transfer-Encoding: base64".$eol; 
$body .= "Content-Disposition: attachment".$eol.$eol; 
$body .= $attachment.$eol; 
$body .= "--".$separator."--"; 
mail($to, $subject, $body, $headers);
4

0 に答える 0