How to set the font for the PDF using PHP in windows ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santhanalakshmi
    New Member
    • May 2009
    • 147

    #1

    How to set the font for the PDF using PHP in windows ?

    Hi ,


    I am trying to Create a PDF File in PHP :

    This is the coding which i followed :
    Code:
    <?php
    $pdffile=pdf_new();
    pdf_open_file($pdffile,"F:\bharat.pdf");
    pdf_begin_page($pdffile,595,842);
    $fontdir = "C:\WINDOWS\Fonts";
    [B]pdf_set_parameter($$pdffile, "FontOutline", "arialMyName=$fontdir\arial.ttf");[/B]
    $font1=pdf_findfont($pdffile,arialMyName,"host",0);
    pdf_setfont($pdffile,$font1,10);
    pdf_show_xy($pdffile,"Keep Trusting God",50,750);
    pdf_end_page($pdffile);
    pdf_close($pdffile);
    ?>

    But when i am trying to run this program,i am facing an error is :

    Fatal error: Uncaught exception 'PDFlibExceptio n' with message 'pdf_set_parame ter() expects parameter 1 to be resource, null given' in C:\Program Files\xampp\htd ocs\pdf_file.ph p:44 Stack trace: #0 C:\Program Files\xampp\htd ocs\pdf_file.ph p(44): pdf_set_paramet er() #1 {main} thrown in C:\Program Files\xampp\htd ocs\pdf_file.ph p on line 44


    thanks.....
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    You are using two $ chars in the first parameter for the pdf_set_paramet er function on line #5. Removing one of them should fix this error.

    Comment

    Working...