【问题标题】:create pdf with title + image in php在php中创建带有标题+图像的pdf
【发布时间】:2012-10-10 17:36:56
【问题描述】:

我有以下数组,其中包含标题及其各自的图像。

Array
(
    [0] => Array
        (
            [title] => Title1 : Introduction
            [image] => http://path/to/file.png
        )

    [1] => Array
        (
            [title] => Title2 : Description
            [image] => http://path/to/file.jpg
       )
     .
     .
     .
     //and so on

)

我想创建它的 PDF 格式: page1 上的 Array[0] 内容: 顶部(对齐:中​​心)和下方的标题 图片(对齐:居中,高度:400,宽度:400)

与第 2 页上的数组 [1] 内容类似...

我正在这样做,但没有取得任何成功。检查下面的代码:

<?php    
include_once ('class.ezpdf.php');

$feeddata = unserialize(urldecode($_GET['feed']));

$pdf = & new Cezpdf('LETTER');

$image = imagecreatefrompng("background.png");
$pdf->addImage($image, 0, 0, 611);

$pdf->selectFont("fonts/Helvetica.afm");
$pdf->setColor(0 / 255, 0 / 255, 0 / 255);

$pdf->setLineStyle(0.5);
$pdf->line(80, 615, 540, 615);
$pdf->setStrokeColor(0, 0, 0);

$pdf->setColor(0 / 255, 0 / 255, 0 / 255);
$pdf->addText(30, 16, 8, "<b>Created " . date("m/d/Y"));

foreach($feeddata as $data){
    $pdf->addText(80, 620, 10, $data['title']);
    $pdf->addImage($data['image'], 0, 0, 611);
}   

$pdf->ezStream();
?>

谁能告诉我该怎么做……谢谢

【问题讨论】:

    标签: php pdf


    【解决方案1】:

    最后,我自己解决了:

    我刚用过这个:

    foreach ($feeddata as $data) {
        $pdf->ezText($data['title'], 15);
        $pdf->ezImage($data['image'], 50, 300, none, center);
    }
    

    现在它在我的 pdf 文件中显示标题和图像.....非常简单:-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-08
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多