2016-06-18 10 views
1

PDFを生成したい。 私はFPDFを使用してpdfファイルを生成しています。 私は内容のテキストとイメージを使ってpdfを生成します。 イメージを背景イメージにしたい。 シナリオは、テキストがイメージ上にあることです。私は多くのソリューションを試しましたが、どんな解決策も私には役立っています。私は以下のコードを使ってPDFを生成しました。FPDFを使用してイメージにテキストを書き込む方法

$pdf = new FPDF(); 
$title = 'Without User Details'; 
$img_title = 'Your Voucher Image is-: '; 
$php2pdf = ''; 
$php2pdf .= 'Your Voucher Code is-: '; 
$php2pdf .= $voucher_prefix; 
$php2pdf .= get_post_meta($post->ID, 'voucher_start_digit', true); 

if (has_post_thumbnail($post->ID)): 
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); 
$image_url = $image[0]; 
endif; 

$pdf->AddPage(); 
$pdf->SetFont('Arial','B',16); 
$pdf->SetTitle($title); 
$pdf->MultiCell($w, $h, $title); 
$pdf->Ln(3); 
$pdf->Cell(90,90,$php2pdf); 
$pdf->Ln(20); 
$pdf->MultiCell(40, 10, $img_title); 
$pdf->Image($image_url,30,60,90,0); ob_start(); 
$pdf->Output(); 
ob_end_flush(); 
+0

ので、あなたが背景画像として画像を作りたいですか? –

+0

http://forums.devshed.com/php-development-5/fpdf-background-image-510220.html –

+0

私はすでにこのソリューションを試しましたが、私のために働いていません。画像を背景にしていない –

答えて

0

私は答えを得た!これは、FPDFの透明性を使用しています。 そのためには、拡張されたAlphapdfクラスを使用する必要があります。

参考: http://www.fpdf.org/en/script/script74.php

関連する問題