zoukankan      html  css  js  c++  java
  • php生成PDF文件(FPDF)

    首先要下载FPDF,官方地址:http://www.fpdf.org/ 

    附件可以在我的资源里下载:https://files.cnblogs.com/files/qingsong/fpdf17.zip.gz

    目前最新的是v1.81 (2015-12-20),下载地址:https://files.cnblogs.com/files/qingsong/fpdf181.zip.gz

    下载的包里面有文档资料,不过是英文的。

    例子:将下面的文件保存在web根目录,与附件fpdf17处于同一级

    <?php

    ini_set('display_errors', '0');
    ini_set('max_execution_time', '60');

    require ('fpdf17/chinese.php');


    $pdf = new PDF_Chinese();
    $pdf->AddGBFont();
    $pdf->Open();
    $pdf->AddPage();

    $pdf->SetFont('GB', 'B', 10);
    $pdf->SetLeftMargin(15.0);
    $pdf->Cell(180, 8, iconv("UTF-8", "gbk", "2015年10月出勤统计表 导出时间: 2015-10-14  市场部3人"), 1, 0, 'C');
    $pdf->Ln();
    //以上是表头

    $pdf->SetFont('GB', '', 8);
    $pdf->SetLeftMargin(15.0);
    $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "UID"), 1, 0, 'C');
    $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "姓名"), 1, 0, 'C');
    $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "部门"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "出勤/天"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "出勤/小时"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "迟到/次"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "迟到/分钟"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "早退/次"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "早退/次"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "早退/分钟"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "缺卡/次"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "地点异常/次"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "账号状态"), 1, 0, 'C');
    $pdf->Ln();

    $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "10002"), 1, 0, 'C');
    $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "市场部"), 1, 0, 'C');
    $pdf->Cell(10, 8, iconv("UTF-8", "gbk", "1"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "9.0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Cell(15, 8, iconv("UTF-8", "gbk", "0"), 1, 0, 'C');
    $pdf->Ln();



    $pdf->Output();
    ?> 

  • 相关阅读:
    BZOJ4416 [Shoi2013]阶乘字符串 【序列自动机 + 状压dp】
    BZOJ2159 Crash 的文明世界 【第二类斯特林数 + 树形dp】
    快速求原根
    BZOJ2530 [Poi2011]Party 【贪心】
    BZOJ2213 [Poi2011]Difference 【乱搞】
    BZOJ2276 [Poi2011]Temperature 【单调队列】
    多项式除法
    loj2538 「PKUWC2018」Slay the Spire 【dp】
    loj2537 「PKUWC2018」Minimax 【概率 + 线段树合并】
    Java多线程之线程的暂停
  • 原文地址:https://www.cnblogs.com/qingsong/p/5031294.html
Copyright © 2011-2022 走看看