You could create an png from the PDF. PDF is not something a browser can render in HTML (sure Chrome and Firefox can open a PDF; but that's fullscreen, just the pdf itself; e.g. another URL). Could be out of scope: In some projects I use a crontab that converts uploaded PDF's to jpg to provide a preview:
#Render all PDF's to thumb when no thumb is found
#convert -thumbnail x600 -background white "1.pdf"[0] "1.jpg"
import os,sys
OVERWRITE_EXISTING=False
PDFDIR='uploads'
THUMBDIR=os.path.join('static','thumbs')
import glob
import os
def insensitive_glob(pattern):
def either(c):
return '[%s%s]'%(c.lower(),c.upper()) if c.isalpha() else c
return glob.glob(''.join(map(either,pattern)))
#get all the pdf file names in the current folder
os.chdir('uploads')
files = insensitive_glob("*.pdf")
# and convert each file if needed
for f in files:
convert_needed=True
newFile=os.path.join('..',THUMBDIR,'%s.jpg' % f[:-4])
if not OVERWRITE_EXISTING:
if os.path.exists(newFile):
#print 'Warning:: .jpg already exists; skipping %s' % f
convert_needed=False
if convert_needed:
cmd='convert -density 144 %s[0] %s' % (f,newFile)
print "Converting with: %s" % cmd
os.system(cmd)