【问题标题】:how to generate pdf file from php code or print text over image如何从 php 代码生成 pdf 文件或在图像上打印文本
【发布时间】:2015-03-03 23:04:45
【问题描述】:

我正在从事暑期培训系统项目,我想通过普通的html表单收集学生信息,这些信息将存储在数据库中

我有 PDF 格式的正式表格图片 包含: 姓名:ID:公司:等...

我想从 html 表单中收集上述数据

如何移动收集的数据然后将其写入图像(官方形式)? 打印后可以保存为pdf吗?

我试图四处搜索,但我没有找到我的答案

【问题讨论】:

  • 查看 fPdf。它附带您通过 XAMPP 获得的 PHP 安装。它可能带有 PHP 的“标准”安装 - 我没有看过。此外,您可以查看 GDImage 以仅处理图像。 fpdf.orgphp.net/manual/en/ref.image.php

标签: php html css pdf


【解决方案1】:

使用以下代码在图像上打印。

<?php
  //Set the Content Type
  header('Content-type: image/jpeg');

  // Create Image From Existing File
  $jpg_image = imagecreatefromjpeg('sunset.jpg');

  // Allocate A Color For The Text
  $white = imagecolorallocate($jpg_image, 255, 255, 255);

  // Set Path to Font File
  $font_path = 'font.TTF';

  // Set Text to Be Printed On Image
  $text = "This is a sunset!";

  // Print Text On Image
  imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text);

  // Send Image to Browser
  imagejpeg($jpg_image);

  // Clear Memory
  imagedestroy($jpg_image);
?>

您可以使用fpdf 库从图像生成pdf

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-11
    • 2013-03-19
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多