SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to create an pdf for a dynamic html page?

    Hi all,
    I want to generate a pdf file dynamically, based on the html page....

    Means,
    Html page is generated from the user submitting the details, based on the details, dynamically i generated one html file contains 3 images, now i want this final html page as pdf format..

    I tried some tools by giving the URL of that page, but it is generating only the text part, but not the images... and also i have submit buttons in that html page, i don't want that in the generated pdf...

    Can you give me any regarding this problem, in a better and simple way...

    Thanking you..

  2. #2
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've used DOM-PDF for this before: dompdf - HTML to PDF converter (PHP5) - Google Project Hosting

    Give it a shot. It's pretty good stuff!

  3. #3
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,547
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)

  4. #4
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by venkat6134 View Post
    Hi all,
    I want to generate a pdf file dynamically, based on the html page....

    Means,
    Html page is generated from the user submitting the details, based on the details, dynamically i generated one html file contains 3 images, now i want this final html page as pdf format..

    I tried some tools by giving the URL of that page, but it is generating only the text part, but not the images... and also i have submit buttons in that html page, i don't want that in the generated pdf...

    Can you give me any regarding this problem, in a better and simple way...

    Thanking you..
    You'll find there are many PDF libraries out there that claim to handle HTML to PDF document conversion, but the vast majority of these only partially support CSS and HTML.

    What you'll generally end up with is a PDF document with all the unsupported elements missing. If the HTML is within your control, you may be able to work around some of these issues.

    If you need to reproduce high quality PDF documents from arbitrary web pages, the good news is it is possible, but your choice may be limited to commercially developed libraries and may also depend on your server platform.

    I can't recommend one product or another (forum rules! ), but what I'd like to suggest is this:

    Find an online service that can handle the type of pages you want to convert, on the platform that you will be using. Download their output and examine the contents of the file in a text editor. You might be able to identify the PDF component used in the file header.

    BTW, if the file's contents appear gibberish, you may need to decode it first.

  5. #5
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,547
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by AffineMesh94464 View Post
    You'll find there are many PDF libraries out there that claim to handle HTML to PDF document conversion, but the vast majority of these only partially support CSS and HTML.
    This is why wkhtmltopdf is so good - it's a full webkit engine so you get full css and html support. It's also massively faster than the pure php solutions around. The down side is you can only use it if you have sufficient access on your hosting to install or execute applications.

  6. #6
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The choice of rendering engine will certainly affect the appearance of HTML when converted to PDF, so it's a point worth considering.

    Webkit is fine, as used in Chrome and Safari. But you probably wouldn't want to select this if your user base was heavily dependent on another browser.

    This is sometimes the case in corporate environments, where users choice of browser can be limited. South Korea is another example, where the vast majority of Internet users are obliged to use Internet Explorer (90%?).

    FireFox uses the Gecko rendering engine, Internet Explorer uses Trident.

    Pick a browser and PDF library that use the same engine, you'll stand a better chance of producing a PDF that matches what you'd expect to see in your browser.

    All the main web browsers use rendering engines that support HTML and CSS. Yes, even Micorsoft's browser!

    Web pages can also include technologies that require browser plug-ins to support, such as Flash. You may want to ask if the PDF library support this too, and JavaScript, etc.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •