Jump to content

Removing page style


littlemiss

Recommended Posts

Hey, I am very very very very bad at PHP and I am trying to improve.

 

But anyway, I found a great script which turns a HTML page into a PDF, but the problem is it turns the whole page, with layout etc, into the pdf, which looks really bad with all the navigation etc, on it.

 

I am trying to come up with a function to only include in the pdf the actual things I want, if you understand me.

 

This is the original code:

 

<?php

require('html_to_pdf.inc.php');

$htmltopdf = new HTML_TO_PDF();

 

//$htmltopdf->useURL(HKC_USE_EASYW);  // default HKC_USE_ABC other HKC_USE_EASYW

$htmltopdf->saveFile("abc.pdf");

$htmltopdf->downloadFile("abc.pdf");

//$result = $htmltopdf->convertHTML("<b>MY TEST</b>");

$result = $htmltopdf->convertURL("$value");

if($result==false)

echo $htmltopdf->error();

?>

 

and so far this is all i managed to work out myself,

 

$beginingofcontent = "<!--top-->";

$finishofcontent = "<!--bottom-->";

 

LOL, i know i am bad, but I am not asking for someone to code it for me, I am just asking on someone to give me tips on how and where to look, any help would be really great.

 

Thanks :D

Link to comment
Share on other sites

Are you trying to convert html pages with .html extension to pdf or are your trying to convert HTML pages that are created from php files?

 

If you are converting php created html files then I would make the following suggestion:

 

On all you pages have two possible style sheets, one for normal viewing and one for pdf creation that hides or changes the display of elements for a better printed output. Then create a switch using a $_GET variable on each page to determine which style sheet to use.

 

Something like:

 

if (isset($_GET['pdf']) && $_GET['pdf']==true) {

    $stylesheet = "pdfstyle.css";

} else {

    $stylesheet = "userstyle.css";

}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.