morris chart into a pdf

hi
i have a form that the user choose date range and some other parameters, when the user submit the form an ajax call is made, php get the data from the database and send the results, and with it the morris chart is made. all that works.
now i need to create a pdf and send it to the user.
i searched the web and realized that morris charts is made with svg, and i have no idea how to go about it. i don't need only the chart there, i need to make a full report with tables and so on.

any idea?
LVL 1
derridaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
See example 58 on this page.  
http://www.tcpdf.org/examples.php

I do not have much experience with TCPDF and none at all with SVG in TCPDF, but I can show you the "hello world" example.
http://iconoun.com/demo/tcpdf_example.php

My teaching example of the basics:
<?php // demo/tcpdf_example.php

/**
 * Demonstrate how to put an image into a TCPDF document
 * and write some text over part of the image
 *
 * See http://www.tcpdf.org/doc/code/annotated.html
 */
error_reporting(E_ALL);

// A DATE SETTING MAY BE REQUIRED - DEPENDS ON PHP INSTALLATION SETTINGS
date_default_timezone_set('America/Chicago');

// SYNTHESIZE THE PDF FILE URL AND FILE NAME
$pdf_file_link    = 'storage/tcpdf_example.pdf';
$pdf_file_name    = getcwd() . DIRECTORY_SEPARATOR . $pdf_file_link;

// LOAD THE TCPDF CLASS AND CONFIGURATION
require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');

// EXTEND THE TCPDF OBJECT SO WE CAN SUBSTITUTE OUR OWN METHODS
class PDF extends TCPDF
{
    // NULLIFY AUTOMATIC HEADER AND FOOTER
    public function Header() {}
    public function Footer() {}
}

// INSTANTIATE THE OBJECT
$pdf = new PDF('P', 'mm', 'LETTER', true, 'UTF-8', false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(0,0,0,TRUE);
$pdf->SetAutoPageBreak(FALSE);
$pdf->setLanguageArray($l);
$pdf->SetFont('times', '', 13);
$pdf->setCellPaddings(0,0,0,0);
$pdf->setCellMargins(0,0,0,0);

// DO NOT DO THIS
// $pdf->setFillColor(255,255,224);


// APPLY CELL BORDERS, IF NEEDED
$bdr = '1TRBL';

// BUT IF NO CELL BORDER IS NEEDED
$bdr = 0;

// ADD A PAGE
$pdf->AddPage('P', 'LETTER', TRUE);

// ADD AN IMAGE
$img = 'images/ray_padded.png';

// I HAVE NO IDEA WHAT THIS IS DOING TO IMAGE SCALE - EXPERIMENT WITH IT
$pdf->setImageScale(1.53);

// GET THE IMAGE SETTINGS
$pdf->Image
( $img
, 0             // $x
, 0             // $y
, 0             // WIDTH
, 0             // HEIGHT
, 'PNG'         // TYPE
, '#'           // LINK URL
, 'T'           // SET POINTER TOP LEFT
, FALSE         // NO RESIZING
, 300           // DPI
, 'L'           // PALIGN
, FALSE         // ISMASK
, FALSE         // IMGMASK
, 0             // BORDER
, FALSE         // FIT TO BOX
, FALSE         // HIDDEN
, FALSE         // FIT ON PAGE
)
;

// ADD SOME TEXT ON TOP OF THE IMAGE
$pdf->Text
( 24            // $x,
, 24            // $y,
, 'This is Ray'
, FALSE         // $fstroke           = false,
, FALSE         // $fclip             = false,
, TRUE          // $ffill             = true,
, $bdr          // $border            = whatever,
, 2             // $ln                = 0, 2=PUT CURSOR BELOW
, ''            // $align             = '', DEFAULT LEFT
, FALSE         // $fill              = false, CELL BACKGROUND
, ''            // $link              = '', NOT A LINK
, 0             // $stretch           = 0, NO TEXT STRETCH
, FALSE         // $ignore_min_height = false,
, 'A'           // $calign            = 'T', A=FONT TOP INSIDE CELL
, 'T'           // $valign            = 'M', T=VERTICAL ALIGN INSIDE CELL
, TRUE          // $rtloff            = false TRUE = USE PAGE TOP LEFT CORNER TO ALIGN
)
;

// WRITE THE PDF FILE TO THE SERVER
$pdf->Output($pdf_file_name, 'F');

// PRESENT A CLICKABLE LINK SO WE CAN D/L AND PRINT THE PDF
echo '<a target="my_PDF" href="' . $pdf_file_link . '"><strong>Print the PDF</strong></a>';

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
derridaAuthor Commented:
i actually see i needed to ask another question. but this one worked and very useful to understand how to work with tcpdf
0
Ray PaseurCommented:
Thanks for the points and best of luck with it! ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.