能告诉我简单的pdf代码吗?
一个表格之类的简简单单就可以
用php pdflib的

解决方案 »

  1.   

    <?php
    $pdf = pdf_new();
    // 打开一个文件
    pdf_open_file($pdf, "pdftest.pdf");
    // 开始一个新页面(a4)
    pdf_begin_page($pdf, 595, 842);
    // 得到并使用字体对象
    $arial = pdf_findfont($pdf, "arial", "host", 1);
    pdf_setfont($pdf, $arial, 10);
    // 输出文字
    pdf_show_xy($pdf, "this is an exam of pdf documents, it is a good lib,",50, 750);
    pdf_show_xy($pdf, "if you like,please try yourself!", 50, 730);
    // 结束一页
    pdf_end_page($pdf);
    // 关闭并保存文件
    pdf_close($pdf);
    ?>
    但打开会出现这个
    Fatal error: Uncaught exception 'PDFlibException' with message 'Font 'arial' with encoding 'host': Font file (AFM, PFM, TTF, OTF etc.) or host font not found' in C:\pleiades\xampp\htdocs\aaaa\xxx.php:17 Stack trace: #0 
    C:\pleiades\xampp\htdocs\aaaa\xxx.php(17): pdf_findfont() #1 {main} thrown in C:\pleiades\xampp\htdocs\aaaa\xxx.php on line 17
    这个是什么原因???
      

  2.   

    给你个实例.
    你的错误是因为没有指定font的路径.<?php
    /* $Id: hello.php,v 1.6.2.1 2008/04/06 17:55:03 rp Exp $
     *
     * PDFlib client: hello example in PHP
     */try {
        $p = new PDFlib();    # This means we must check return values of load_font() etc.
        $p->set_parameter("errorpolicy", "return");    /* This line is required to avoid problems on Japanese systems */
        $p->set_parameter("hypertextencoding", "winansi");    /*  open new PDF file; insert a file name to create the PDF on disk */
        if ($p->begin_document("", "") == 0) {
    die("Error: " . $p->get_errmsg());
        }    $p->set_info("Creator", "hello.php");
        $p->set_info("Author", "Rainer Schaaf");
        $p->set_info("Title", "Hello world (PHP)!");    $p->begin_page_ext(595, 842, "");    $font = $p->load_font("Helvetica-Bold", "winansi", "");
        if ($font == 0) {
    die("Error: " . $p->get_errmsg());
        }    $p->setfont($font, 24.0);
        $p->set_text_pos(50, 700);
        $p->show("Hello world!");
        $p->continue_text("(says PHP)");
        $p->end_page_ext("");    $p->end_document("");    $buf = $p->get_buffer();
        $len = strlen($buf);    header("Content-type: application/pdf");
        header("Content-Length: $len");
        header("Content-Disposition: inline; filename=hello.pdf");
        print $buf;}
    catch (PDFlibException $e) {
        die("PDFlib exception occurred in hello sample:\n" .
    "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
    $e->get_errmsg() . "\n");
    }
    catch (Exception $e) {
        die($e);
    }$p = 0;
    ?>
      

  3.   

    谢谢
    那在那段字里画框怎么画啊?还有一个问题 为什么我的pdf 有pdflib.com 这个文字啊?
    网站上说把pdflib.reg改了就可以
    但是我找不到阿
    谢谢帮忙
      

  4.   

    我这也有,
    呵呵,
    不知道我们是不是相同的版本.
    我的是family版
    可能要付费的才去掉吧.
      

  5.   

    啊??
    我的也是family 
    晕阿
    那个就算了
    边框怎么画啊??
    我现在想做的是华表个然后写字
    谢谢先