Home > Coldfusion > Thumbnails of HTML pages

Thumbnails of HTML pages

September 2nd, 2007


I saw that Raymond Camden posted an example for this in June, and I decided to play with it a little. I am working on a project that needs to grab html files and display thumbs, and I modified the code some and dumped it in a CFC. What I am doing, in a nutshell, is cfhttping to a supplied url and resolving the urls. From there I am stripping the javascript and changing the tags for css files to css @import. I found that if you don’t do this, the css will not render the page correctly. After that, I create a pdf out of the file and then convert it to an image. Everything is great until the image conversion, at which point all the images get a border on the right and bottom. I have no idea what is causing this, but maybe someone out there knows. Anyone know?

Oh yeah, here is the code in case anyone wants to use it: Code is here

Share Some Vintage Coding
  • Digg
  • De.lirio.us
  • del.icio.us
  • Ma.gnolia
  • TwitThis
  • Facebook
  • StumbleUpon
  • Technorati
  • Reddit
  • Simpy
  • Smarking

Lu Sancea Coldfusion

  1. Todd Sharp
    September 2nd, 2007 at 22:52 | #1

    I don’t see a border on the image above…

  2. Lu Sancea
    September 2nd, 2007 at 23:14 | #2

    The image as a whole doesn’t have a border, it’s the individual images in the page. You can tell by the way the background image of the page tiles. the actual background image is just a small square that is repeating. Each square is given a right and bottom border, as well as every other image on the page.

  3. Michael 23
    September 10th, 2007 at 16:54 | #3

    Hi Lu -
    this looks really interesting… I am thinking it’d be perfect in a directory site I’m working on … add a url and get the thumbnail of the page made dynamically – is that right?

  4. Lu Sancea
    September 10th, 2007 at 17:06 | #4

    That’s right, all you have to do is pass in the url and the code will generate a pdf of the document and then convert it to thumbnails. I am still trying to figure out why the black border appears on the individual images in the image itself. It occurs when the cfpdf thumbnail conversion kicks off. As soon as I get a solution I will post up the updated code and will probably post it up on RIAForge.com.

  5. webRat
    October 23rd, 2007 at 12:42 | #5

    I’m rather annoyed with the whole cfhttp/pdf solution. We talked about this during the alpha/beta of Scorpio and Damon/Tom J./Sean was like, “Bah, it’s good enough.” Anyway, forget all that. If you’re on windows server, you can use this ( http://www.websitescreenshots.com/ ) – Yes, unfortunately, the “full” version with the command line costs money. It works though and does everything as advertised.

  6. Lu Sancea
    October 23rd, 2007 at 14:29 | #6

    Screenshot programs are nice and all, but I can easier capture the page with a screenshot and photoshop it down to size. I was trying to find an open source and programmatic method of producing the screenshots. So you have any suggestions on how to produce better quality snapshots via CF?

  1. September 5th, 2008 at 22:07 | #1