473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Class to convert HTML to PDF

zorgi
431 Expert 256MB
Is there a class for converting HTML file to PDF document?
Oct 5 '09 #1
7 4092
Atli
5,058 Expert 4TB
I don't know. If only there were a way to search the internet for such things...
O wait!

Google: PHP class for converting HTML file to PDF
Oct 5 '09 #2
zorgi
431 Expert 256MB
@Atli
If I didnt do that I wouldn't post here. Thank You.

Anybody with some experience on this subject? I am looking for an advice.Alredy tested fpdf and am currently testing dompdf.
Oct 5 '09 #3
Atli
5,058 Expert 4TB
@zorgi
Well, the answer to your original question was answered about 5 times just in that first Google result page, so it certainly appeared that you had not.

Anyhow, I've tested the HTML2PDF thing from the first link on that Google result page a bit before. It's simple enough and seems to work fine.
Oct 5 '09 #4
zorgi
431 Expert 256MB
@Atli
I probably should have defined my question better.

@Atli
HTML2PDF is based on fpdf class. fpdf class I already tested (as I stated in my previous post) and there are some font issues with fpdf... number of characters are not very well supported (like €). In any case

Thaks for trying.
Oct 5 '09 #5
zxfr
2
I wonder if it is really possible to build a HTML renderer (a significant part of HTML-to-PDF converter, which is much more than a HTML parser) in PHP? We've been working on such product in Java (HTML+CSS->PDF) since more than 5 years and the task is really untrivial despite the fact we may use all power of JDK.

PHP PDF classes make the task simplier (from computing perspective), but they require a PHP programmer to define document layouts, which is normally a task for less technically-, but more "artistic-" skilled persons.

The best alternative is to use PHP wrappers around native or cross-platform HTML-to-PDF applications.

Our solution looks like that in PHP code:
Expand|Select|Wrap|Line Numbers
  1. <?
  2.   if (array_key_exists('url', $_POST)) {
  3.  
  4.     header('Content-type: application/pdf');
  5.     header('Content-disposition: inline');
  6.     //header('Content-disposition: attachment; filename=test.pdf');
  7.  
  8.     // UNIX version
  9.     // Please make sure, that web user is allowed to write to ./stderr.txt.
  10.     // If not, please remove 2>>stderr.txt command-line suffix
  11.  
  12.     passthru('java -Xmx512m -Djava.awt.headless=true -cp .:pd4ml_demo.jar Pd4Php \'' . $_POST['url'] . '\' 800 A4 2>>stderr.txt');
  13.  
  14.     // Windows version
  15.     //passthru('java -Xmx512m -cp .;pd4ml_demo.jar Pd4Php ' . $_POST['url'] . ' 800 A4');
  16.  
  17.   } else {
  18.     echo 'invalid usage';
  19.   }
  20. ?>
  21.  
Here is some more info how to define, for example, "As PDF" button for your PHP pages: http://pd4ml.com/php.htm
Jan 20 '10 #6
htmldoc linux command is other alternate. In any case, you won't get accurate result though.
Jan 21 '10 #7
itsloop
18
man you can use DOMPDFis the best one...
Jan 23 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
15
by: bugzilla | last post by:
hi,all, I have a C++ program need to convert to c language to be used in a emabedded system. the problem is that the original code was writtern in C++ language with Parent class and some child...
5
by: BuddyWork | last post by:
Hello, Does anyone know where the class Hex is in the framework. According to articles that I read it should be in System.Security.Util, but I cannot find the Util namespace. Here is the...
2
by: Makarand | last post by:
Hi Can anybody tell me how to use TypeConvertor class? Thing is i want to do dynamic(during runtime) type casting in my code. Thnanx Makarand
36
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a...
1
by: momo | last post by:
Okay guys, I have this one problem and I admitted I am a novice at this. This is a Code Behind in an aspx page. You will see where I have the plus signs below in SecureQueryString2.vb where I am...
1
by: quantass | last post by:
Im using C#, ASP.NET v1.1. My class contains intrinsic types, ArrayList, and XmlDocument types. Some variables have the value NULL. After usng XmlSerializer and the information on:...
1
by: =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?= | last post by:
I need to be able to take Wikipedia WikiText markup and convert to HTML. Haven't found anything really useful yet. Anyone? Thanks, Peter -- Site: http://www.eggheadcafe.com UnBlog: ...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.