HTML to PDF

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

HTML to PDF

Post by tecktalkcm0391 »

I am trying to use the HTML to PDF class here:
http://html2fpdf.sourceforge.net/

I can get it to make the file fine, but it doesn't display the PDF file, it makes it so you download it, when its suppost to just display the file.... here is my code... PS. There is an auto_append and auto_prepend so i have to cancel them out

Code: Select all

<?
ob_end_clean();
require_once('html2fpdf.php');
require_once('function.php');
define('HTML_URL','http://google.com/');

$html = get_url_contents(HTML_URL);

ob_end_clean();
$pdf = new HTML2FPDF();
$pdf->DisplayPreferences('HideWindowUI');
$pdf->AddPage();
$pdf->WriteHTML($html);
$pdf->Output('doc.pdf','I');
?>
function.php wrote:

Code: Select all

<?php
function get_url_contents($url){
        $crl = curl_init();
        $timeout = 5;
        curl_setopt ($crl, CURLOPT_URL,$url);
        curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
        $ret = curl_exec($crl);
        curl_close($crl);
        return $ret;
}
?>
How do I get it to display the PDF file in the webpage window?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What a browser does with the content-type application/pdf is chosen by the browser and its plugin that handles PDF files.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Ok, cause I am using IE6 to test and it shows fine on the source website, but not on mine... :(
Post Reply