Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
HTML to PDF conversion online
Old 10-15-2007, 03:33 PM HTML to PDF conversion online
Skilled Talker

Posts: 81
Trades: 0
Hi, I'd like to offer the option of saving a dynamically produced webpage as a PDF file. Preferably with the option of either downloading or viewing, rather than just displaying the pdf version in Acrobat.

I've tried several of the scripts available, but find them hard to understand or get to work. Has anyone got anything like this implemented I can see working?

thanks and best wishes

Tony
soon is offline
Reply With Quote
View Public Profile Visit soon's homepage!
 
 
Register now for full access!
Old 10-15-2007, 05:52 PM Re: HTML to PDF conversion online
247SiteAlert's Avatar
Average Talker

Posts: 28
Trades: 0
Are you looking only at free scripts that do this? If so, you may have to actually search for one that a company sells. Which scripts have you already tried?
__________________
Free Website Uptime Monitoring

Please login or register to view this content. Registration is FREE
247SiteAlert is offline
Reply With Quote
View Public Profile
 
Old 10-16-2007, 06:10 AM Re: HTML to PDF conversion online
Skilled Talker

Posts: 81
Trades: 0
Thanks - well I have tried http://www.ros.co.nz/pdf/, http://www.fpdf.org/, http://www.gnuvox.com/pdf4php/, and http://www.potentialtech.com/ppl.php which are all free options. I'm probably not understanding the best way to use them though!


soon is offline
Reply With Quote
View Public Profile Visit soon's homepage!
 
Old 10-16-2007, 07:06 AM Re: HTML to PDF conversion online
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
i want a pdf converter too. i was lookingh but couldnt find a option which i could understand and do, or a person who was willing to do it for me,

i want it for something differant tho, i want have it connected so i can upload a word .doc and as well as saving the doc converts it to pdf so i have the same document in pdf and doc instantly

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 10-16-2007, 01:29 PM Re: HTML to PDF conversion online
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
It's quite simply a matter of knowing how a PDF is made up.

I know that you need to edit the headers to make the file a PDF.

I found a perl way of doing it:
http://www.tufat.com/s_html2ps_html2pdf.htm

** Edit**

Just look at php.net (the PHP Manual), and it seems there is a set of functions to do this:
http://uk3.php.net/manual/en/ref.pdf.php
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 10-16-2007 at 01:30 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-16-2007, 01:58 PM Re: HTML to PDF conversion online
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
thanks im looking at how i could use that...
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 10-16-2007, 02:37 PM Re: HTML to PDF conversion online
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
To be honest, the perl thing is the best way forward. Unless someone makes a html>pdf converter in php.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-16-2007, 05:00 PM Re: HTML to PDF conversion online
Skilled Talker

Posts: 81
Trades: 0
I have found what seems like a fairly simple expanation of php to pdf here:
http://www.zend.com/zend/spotlight/creatingpdfmay1.php

except I am not sure how to apply it to an existing dynamic page, or how to make a button 'save this page as a pdf file'.

thanks for any more ideas

tony
soon is offline
Reply With Quote
View Public Profile Visit soon's homepage!
 
Old 10-16-2007, 05:59 PM Re: HTML to PDF conversion online
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
How can i use this to convert a .doc to a pdf?
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 10-16-2007, 07:35 PM Re: HTML to PDF conversion online
247SiteAlert's Avatar
Average Talker

Posts: 28
Trades: 0
This link explains how to convert .html to .pdf:

http://www.javaworld.com/javaworld/j...0410-html.html


This website will actually do it for you free:

http://www.pdfonline.com
__________________
Free Website Uptime Monitoring

Please login or register to view this content. Registration is FREE
247SiteAlert is offline
Reply With Quote
View Public Profile
 
Old 10-17-2007, 11:18 AM Re: HTML to PDF conversion online
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
I'm not a big fan of PDF's in general, when I open them my computer almost grinds to a halt.

Also, that pdfonline site uses ASP it seems.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-26-2007, 06:02 AM Re: HTML to PDF conversion online
Skilled Talker

Posts: 81
Trades: 0
Hi
I've looked at several of the options available, and find them fiendishly complicated, or have not managed to get them to work. A friend gave me some simple PHP code to try. The following does convert the page to PDF as soon as it is opened in the browser - which is not want I want. Plus, it just puts all the html code for the page into the PDF:
Code:
<?php
ob_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tips</title>
</head>
<body>
Testing the pdf converter
</body>
</html>
<?php
# grab the HTML above as a string from the buffer
$html = ob_get_contents();
ob_end_clean(); # discard the buffer - we have it already in $html and don't want to output it to the browser - this would send headers and cause errors.

# now the pdf
include( 'class.ezpdf.php' );
$pdf = new Cezpdf( 'a4', 'P' );  //A4 Portrait
$pdf -> ezSetCmMargins( 2, 1.5, 1, 1);
$pdf->selectFont( '.Helvetica.afm' );
$pdf->ezText( $html, 10 );
$pdf->ezStream();
?>
What I really want is a button that will convert the page, iwhen someone wants to. And, ideally, will just offer to save the PDF as a file, rather than opening it in Acrobat. So I tried the following, but it does not work:

Code:
<?php
ob_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tips</title>
</head>
<body>
<form action="pdftest7.php" method="get">
Testing the pdf converter
<input type="submit" value="save this page as pdf">
</form>
</body>
</html>
<?
$html = ob_get_contents();
ob_end_clean(); 
if (array_key_exists('pdf', $_GET)) {
  include( 'class.ezpdf.php' );
  $pdf = new Cezpdf( 'a4', 'P' );  //A4 Portrait
  $pdf -> ezSetCmMargins( 2, 1.5, 1, 1);
  $pdf->selectFont( './Helvetica.afm' );
  $pdf->ezText( $html, 10 );
  $pdf->ezStream();}
else {
  echo $html;
}
?>

Thanks for any wisdom on this!

Best wishes

Tony
soon is offline
Reply With Quote
View Public Profile Visit soon's homepage!
 
Old 10-26-2007, 08:58 AM Re: HTML to PDF conversion online
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
i have no clue what the if(array_key_exsits its all about...

i would just have

if($_GET['pdf'] == 1)
{
Converter thingy
}

else {
echo page
}

with regards to haveing it download not open that might be a setting with ur browser.

but there is something in PHP which im looking up now.
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to HTML to PDF conversion online
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37066 seconds with 12 queries