php 使用 fpdf 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1339810/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:05:34  来源:igfitidea点击:

using fpdf library

phpfpdf

提问by user156073

i have found some pdf file geneartion program in php. When i reun it i get the following error

我在 php 中找到了一些 pdf 文件生成程序。当我重新打开它时,我收到以下错误

Warning: require(/include/fpdf153/fpdf.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\aks\mikepdf.php on line 57

Fatal error: require() [function.require]: Failed opening required '/include/fpdf153/fpdf.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\aks\mikepdf.php on line 57

警告:require(/include/fpdf153/fpdf.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\aks\mikepdf.php on line 57

致命错误:require() [function.require]: Failed opening required '/include/fpdf153/fpdf.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\第 57 行的 aks\mikepdf.php

I think the fpdf.php is missing. I have searched on their site but i could not find the english version.

我认为 fpdf.php 丢失了。我在他们的网站上搜索过,但找不到英文版本。

can anyone provide me full link of english version?

谁能给我英文版的完整链接?

回答by Silvan Mühlemann

Currently PHP is looking for the file in C:\include\fpdf153\fpdf.phpas it is an absolute path.

目前 PHP 正在寻找该文件,C:\include\fpdf153\fpdf.php因为它是一个绝对路径。

Try to put the file in C:\xampp\htdocs\aks\include\fpdf153\and use the follwing statement:

尝试将文件放入C:\xampp\htdocs\aks\include\fpdf153\并使用以下语句:

require(include/fpdf153/fpdf.php);

要求( include/fpdf153/fpdf.php);

Then it uses a relative link based on your current working this (I guess it's C:\xampp\htdocs\aks\). And it should work.

然后它使用基于您当前工作的相对链接(我猜是C:\xampp\htdocs\aks\)。它应该工作。

You can find more info in the PHP manual

您可以在 PHP 手册中找到更多信息

回答by adatapost

I presume that the name of root folder is a test.

我假设根文件夹的名称是test

/test

copy font folder and fpdf.php into /test

/测试

将字体文件夹和 fpdf.php 复制到 /test

Example, Create sample.php into /test folder.

示例,将 sample.php 创建到 /test 文件夹中。

<?php
require('fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

回答by Thinker

I think the fpdf.php is missin .I have searched on their site but i could not find the english version. can anyone provide me full link of english version?

我认为 fpdf.php 是missin。我在他们的网站上搜索过,但找不到英文版本。谁能给我英文版的完整链接?

Are you looking for that?

你在找那个?

http://www.fpdf.org/en/dl.php?v=16&f=zip

http://www.fpdf.org/en/dl.php?v=16&f=zip

回答by Manu

There is an API for FPDF so before using this you have to save all file in any folder then provide the path to this.

有一个用于 FPDF 的 API,因此在使用它之前,您必须将所有文件保存在任何文件夹中,然后提供它的路径。

Then you will be able to use this.

然后你就可以使用它了。

回答by Nilesh Nartam

i think you should put all content of fpdf library inside the root folder of your project like follow

我认为你应该把 fpdf 库的所有内容放在你的项目的根文件夹中,如下所示

root(project folder)

根(项目文件夹)

  • font(fpdf library fonts folder)
  • makefont(fpdf library make font folder)`
  • fpdf.php(fpdf file)
  • index.php(your project file)
  • 字体(fpdf 库字体文件夹)
  • makefont(fpdf 库制作字体文件夹)`
  • fpdf.php(fpdf 文件)
  • index.php(你的项目文件)

also include in your code by include_once('fpdf.php')in your index.php

还包括在您的代码中,include_once('fpdf.php')在您的 index.php 中

回答by Moni

All the files of the fpdf library should be inside your project.

fpdf 库的所有文件都应该在您的项目中。

I'd suggest you copy everything into a directory of you project. After that, it may look similar to this structure:

我建议您将所有内容复制到您的项目目录中。之后,它可能看起来类似于这个结构:

  • root of project
    • directory a
    • directory b
    • directory fpdf
      • directory doc (many files inside)
      • directory font (many files inside)
      • directory makefont (many files inside)
      • fpdf.css
      • fpdf.php
      • install.txt
      • licence.txt
    • directory c
    • index.php
    • ...
  • 项目根
    • 目录a
    • 目录 b
    • 目录 fpdf
      • 目录doc(里面有很多文件)
      • 目录字体(里面有很多文件)
      • 目录makefont(里面有很多文件)
      • pdf文件
      • pdf文件
      • 安装文件
      • 许可证.txt
    • 目录c
    • 索引.php
    • ...

Then you can include it like so:

然后你可以像这样包含它:

require('fpdf/fpdf.php');

See also: http://www.fpdf.org/

另见:http: //www.fpdf.org/

回答by Tann

when you are getting error in this line require('fpdf/fpdf.php'); that means you need to keep the folder in your current directory. what you can do is , you can go to the following url download any version zip file extract that make folder name 'fpdf' and save in current project location. it will work perfectly. Here is the url "http://www.fpdf.org/en/download.php"

当您在此行中遇到错误时 require('fpdf/fpdf.php'); 这意味着您需要将该文件夹保留在当前目录中。您可以做的是,您可以转到以下网址下载任何版本的 zip 文件提取,使文件夹名称为“fpdf”并保存在当前项目位置。它会完美地工作。这是网址“ http://www.fpdf.org/en/download.php

回答by mck89

I think that the file path that you have used with the require function is wrong

我认为您与 require 函数一起使用的文件路径是错误的