2

Using the following code to generate thumbnails from PDFs (ColdFusion 8):

<cfpdf
    action="thumbnail"
    source="#LOCAL.PathToMyPDF#"
    destination="#LOCAL.ImageDestination#"
    format="png"
    scale="100"
    resolution="high"
    overwrite="true"
    pages="1" />

Sometimes it works great and generates a beautiful PNG representation of the first page. However, many times, it ends up creating a PNG with none of the text that's in the PDF, or with the text mangled or background images out of arrangement.

Is there any way to prevent this? I'm open to using a non-commercial java library, if necessary.

Eric Belair
  • 10,574
  • 13
  • 75
  • 116

1 Answers1

1

Without looking into this too deep, I would think you are having a font problem.

Try to run that bit of code with this parameter nofonts = "true" (which removes font styling) and see if you get your text (not styled).

If that works then you may need to register your fonts in Coldfusion (so Coldfusion has access to the fonts library). If you are not sure what fonts your PDF uses then you can check file, properties and click the font tab to see the fonts your PDF uses.

Check this link for more explanation on Coldfusion and fonts.

Again, I am not sure about your server and font set up because it wasn't mentioned in your post, so this is my best guess for you...

:)

Frank Tudor
  • 4,226
  • 2
  • 23
  • 43
  • Sorry, "nofonts" is not an option. I get the following exception: "Attribute validation error for tag CFPDF. The tag does not allow the attribute(s) NOFONTS. The valid attribute(s) are ACTION,DESTINATION,FORMAT,IMAGEPREFIX,OVERWRITE,PAGES,PASSWORD,RESOLUTION,SCALE,SOURCE,TRANSPARENT." – Eric Belair May 15 '14 at 13:10
  • FYI, these PDFs are provided by a third party vendor, and we do not have access to the fonts. – Eric Belair May 15 '14 at 13:10
  • nofont is in version 9 of Coldfusion. What version are you running? – Frank Tudor May 15 '14 at 13:15
  • "FYI, these PDFs are provided by a third party vendor"...Ah, that could pose a problem. – Frank Tudor May 15 '14 at 13:15
  • Well nofonts is not a show stopper because you can still try the second part and register the fonts you need with Coldfusion. Also, I am not sure how many of these PDFs you have but if you have Photoshop you can try to convert them to an image with that tool and upload your thumbs that way. Your other option is to go back to the third party that made them and see if they can alter the problem font to something you have access too (unlikely option). – Frank Tudor May 15 '14 at 13:22
  • There are an indefinite amount of PDFs, and they come in via FTP daily and a program runs in ColdFusion to create thumbnails of each using the above code. So, there could be any number of fonts as well (I'm trying to eliminate any manual processes here). – Eric Belair May 15 '14 at 17:52
  • I'm using ColdFusion 8 – Eric Belair May 15 '14 at 17:52
  • @EricBelair I completely understand, these PDFs... are they generated by a graphics design team? If so, maybe you can request a thumbnail (along with your PDF) with the explanation on this font issue is causing you a bottleneck. Hopefully that is not too much of an unreasonable request. Something tells me this is not an option. Going back to Coldfusion 8. I have to look something things up. I can tell you there will not be an easy solution for this (that I can see). – Frank Tudor May 15 '14 at 18:21
  • thank you, that's why I'm here. I've spent many hours trying to solve this problem over the past few years. – Eric Belair May 16 '14 at 02:56
  • @EricBelair I am having trouble finding something that has rendering problems plus I am on Coldfusion 9 so my environment is nuanced with cfpdf changes between releases. I cannot properly replicate your problem. I know you said you couldn't, but if you could edit your post and link a PDF and the image thumbnail output (file) it could help solve your mystery (or get you closer). Also if possible create a new post so fresh eyes will catch it. – Frank Tudor May 16 '14 at 19:21