0

Hi
I have a php script that reads in the contents of an existing html file and saves it to a variable called $home_page.

For a test I displayed this by printing variable out and the output displays as expected.

Then using fpdf I wrote this variable out to create a pdf and email it.

'When I received the pdf the output I get is the contents of the html file raw code instead of the displayed output.

How do I resolve this?

    require("fpdf.php");
    $the_file       = "/temp/your-app-test.html";
    $myfile         = fopen($the_file, "r") or die("Unable to open file!!!!<br><br><br>");
    $homepage   = file_get_contents($the_file);
    fclose($myfile);
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',9);
    $pdf->Cell(40,10, $homepage);

    $pdf->Output();


    etc...
    etc..
    code to email pdf

Edited by kathymac

2
Contributors
1
Reply
12
Views
1 Year
Discussion Span
Last Post by mcglk
0

So, there seems to be some misunderstanding.

When you open a file and read it in this way, what you get is the HTML source. When a browser receives the HTML source, it interprets it and comes up with a graphical rendering of that HTML source.

What you seem to want is the graphical rendering rather than the HTML source, and you’ve done nothing to get that. The program does exactly what you’ve asked it to do.

To get a graphical representation takes a lot more work. Fortunately, some of it has been done for you. See python-webkit2png.

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.