+ -
当前位置:首页 → 问答吧 → FPDF使用教程中文版

FPDF使用教程中文版

时间:2008-12-22

来源:互联网

FPDF Tutorials | FPDF 教程The different examples rapidly show how to use FPDF. You will find all main features explained.
不同的示例快速向你展示如何使用FPDF。你将找到所有已经说明的那些主要的功能。
  • Tutorial 1: Minimal example 教程1:最小的例子
  • Tutorial 2: Header, footer, page break and image 教程2:页眉、页脚、分页和图像
  • Tutorial 3: Line breaks and colors 教程3:换行和颜色
  • Tutorial 4: Multi-columns 教程4:分栏
  • Tutorial 5: Tables 教程5:表格
  • Tutorial 6: Links and flowing text 教程6:链接和流动的文本?
  • Tutorial 7: Adding new fonts and encoding support 教程7:增加新字体和编码支持

想来想去,不如直接加个注释完事。这个帖子算是废了。

作者: Fising   发布时间: 2008-12-22

教程1:最小的例子

Let's start with the classic example:
让我们以这个传统的范例作为开始:


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

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


After including the library file, we create an FPDF object. The FPDF() constructor is used here with the default values: pages are in A4 portrait and the unit of measure is millimeter. It could have been specified explicitly with:
包含进库文件之后,我们创建了一个FPDF对象。这里使用了默认值调用FPDF()这个构造器:纸张类型为A4,计量单位为毫米。它可以被明确的指定:
$pdf=new FPDF('P','mm','A4');

It is possible to use landscape (L), other page formats (such as Letter and Legal) and units of measure (pt, cm, in).
使用landscape (L)其他页面格式(例如信件和律师函)和计量单位(pt,cm和in)。

作者: Fising   发布时间: 2008-12-22

无法访问

作者: 落叶人生   发布时间: 2008-12-22

不错,打印出来了:

下载 (18.08 KB)
2008-12-22 19:00

作者: sinopf   发布时间: 2008-12-22

There is no page for the moment, so we have to add one with AddPage(). The origin is at the upper-left corner and the current position is by default placed at 1 cm from the borders; the margins can be changed with SetMargins().
现在还没有页面,所以我们必须使用AddPage()添加一个。开始处位于左上角,当前位置被默认的置于距离页面边缘1厘米处。可以使用SetMargins()对这个边距进行改变。

Before we can print text, it is mandatory to select a font with SetFont(), otherwise the document would be invalid. We choose Arial bold 16:
在我们打印文本之前,必须使使用SetFont()要为其选择一个字体,不然这个文档将无效。我们选择Arial,粗体,16磅:


$pdf->SetFont('Arial','B',16);


We could have specified italics with I, underlined with U or a regular font with an empty string (or any combination). Note that the font size is given in points, not millimeters (or another user unit); it is the only exception. The other standard fonts are Times, Courier, Symbol and ZapfDingbats.
我们可能对于一个空字符串(或者它的其他联合体)指定了斜体,下划线或者常规字体。记住:字体是以磅值为单位给出的,没有毫米(或者其他单位)。这是仅有的意外情况。其他标准字体是Times,Courier,Symbol和ZapfDingbats.

作者: Fising   发布时间: 2008-12-22

我正好在问这个问题,不错,继续

作者: kingbanner   发布时间: 2008-12-22

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

作者: Fising   发布时间: 2008-12-22

我建议咱们主动删帖,把位子腾出来让Fising接着写,这样也便于今后咱们再查询。同意不?



作者: sinopf   发布时间: 2008-12-22

原帖由 sinopf 于 2008-12-22 19:19 发表
我建议咱们主动删帖,把位子腾出来让Fising接着写,这样也便于今后咱们再查询。同意不?



http://blog.sinopf.com/pic.php

作者: Fising   发布时间: 2008-12-22

LZ怎么不更新了,正等着继续向下看呢?

作者: longxinhe   发布时间: 2009-02-12

怎么用那个会出现。。文件不是以%pdf-开头的错误提示。。。

作者: 可笑可笑   发布时间: 2009-06-18

呵呵,,给翻译,,啊啊

作者: idea360   发布时间: 2009-06-30

热门下载

更多