bigfunkychief 0 Newbie Poster

Hello,

I have a system that generates quotes, it opens a new window with the quote itself. I am trying to make it so I can generate a PDF automatically to a temp file on my webserver, and then use a script I wrote to email the attachment to the client.

Right now I'm just trying to get the PDF to generate. Below is the code I'm using, I've tried collecting different pieces of code from all over, no luck. I'm sure I'm missing something major but hopefully easy.

I'm hoping to eventually have this so it just simply opens the URL for the dynamic page (http://www.mydomain.com/page?client=1) into a variable and generates the PDF from there...for now, the code below reads the HTML output as it's being displayed on the screen.

Thanks in advance for any help, I've burned about 14 hours trying to figure this out!

ob_start();

<html>
<!-- all my HTML code, it's a table with dynamic PHP data -->
</html>

<!-- Code to make PDF -->
$page = ob_get_contents();
ob_end_flush();
$fp = fopen("output.html","w");
fwrite($fp,$page);
fclose($fp);

$fp = fopen("output.html","r");
$strContent = fread($fp, filesize("output.html"));
fclose($fp);

 require('includes/pdf/fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,$strContent);
$pdf->Output();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.