0

i have the following code

<?php
   require_once 'includes/initialize.php';
    set_include_path( get_include_path() . PATH_SEPARATOR . CHARTS_PATH);

    require_once "class/pDraw.class.php";
    require_once "class/pImage.class.php";
    require_once "class/pData.class.php";

    // create data set
    $myDataset = array(0, 1, 1, 2, 3, 5, 8, 13);
    $myData = new pData();
    $myData->addPoints( $myDataset );
    $myData->setAxisName( 0, "Numbers" );

    // define image object
    $myImage = new pImage( 600, 300, $myData );
    $myImage->setFontProperties( array( "FontName" => CHARTS_PATH . "/fonts/GeosansLight.ttf", "FontSize" => 15 ) );
    $myImage->setGraphArea( 25,25, 475,275 );
    $myImage->drawScale();
    // output bar chart
    $myImage->drawBarChart();
    header( "Content-Type: image/png" );
    $myImage->Render( null );
?>

how can i modify the code so that it produces pdf document instead of image files

3
Contributors
3
Replies
13
Views
3 Years
Discussion Span
Last Post by Mahesh_12
1

Use one of the PDF libraries out there. I use tcpdf and am very happy with it. Find a function in your pdf library that deals with images. In tcpdf it is the Image() function (see an example here). You can either save the generated image to disk and use it in the Image() function or send the Image() function a base64 encoded string representing the image.

Edited by broj1

Votes + Comments
Thanks.. I am following same idea but i am strugling to save the image can you explain how to save the image and how to get the saved image url
0

Thanks.. I am following same idea but i am strugling to save the image can you explain how to save the image and how to get the saved image url

0

Thanks.. I am following same idea but i am strugling to save the image can you explain how to save the image and how to get the saved image url

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.