When I paste the URL of a PDF to my Facebook page it gives me the first part of the URL as the preview image which is terrible. How can I get it to show a picture of the first page of the PDF instead or at least something that is better to look at?

For example, the URL https://primarysite-prod.s3.amazonaws.com/uploads/9fe2f8f2134040fda4f9608fb4cf1ff4/afc3/GlossaryoftermsforYear6grammar,punctuationandspellingtests.pdf .

  • Probably have to beg facebook devs to implement that feature, don't hold your breath... I can think of a hacky way to do it, but it wouldn't be useful for you. Commented May 30, 2016 at 5:02
  • 1
    @SamWatkins I would be interested in any workaround too.
    – Simd
    Commented May 31, 2016 at 6:37
  • I posted my idea as an "answer" below. I haven't implemented it yet, but I'm pretty sure it would work. Commented Jun 2, 2016 at 1:47
  • I updated my "answer" with a prototype implementation that more or less works. I'll probably rewrite it and make it more user-friendly some time... Commented Jun 2, 2016 at 6:26

1 Answer 1


One idea is to make a script that serves the PDF documents. When Facebook comes to get the preview we check the user agent, and give the facebook preview crawler a JPG or PNG instead of the PDF, but when the user clicks we give them the actual PDF (possibly by redirecting to another site). We could do this using CGI or php, for example. Also we need to create preview pics using pdftoppm or something. If you really need it I could possibly do this for you. This technique could also be used to give custom preview images for any file or page.

I implemented a dodgy prototype for this, as a cgi script written in bash shell (!). It seems to work, but might need to try the link more than once or use the facebook debugger to reload it. Once the preview image for a post is working, it will keep working, I guess.

Example post and comment with PDF links and previews here: https://www.facebook.com/sswam/posts/10207525028737818

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.