0

My html/javascript code is supposed to show a pdf file within an iframe, see code below.

The code (and other code in the html page) seems to work well when I look at the resulting page in the (chrome) browser (e.g., the pdf files are shown in iframe and i can scroll them); but the console shows (only) this error

Graphics2DResource.PaintImageData: Bad image resource

with the Chrome browser and the error:

Failed to load resource: the server responded with a status of 404 (Not Found)

with the Safari browser.

Why does that error happen? How can I improve the code to avoid displaying this error? (I googled this error message but I only get logged files)

Related code:

var pdfdocwidth = '800';
var pdfdocheight = '1000';

for(var i=0; i<3;i++){
   form += '<tr><td> <div id="filename'+ i + '"> Document 
  <iframe src="'+Staticvars.documentpath[i] +'" width="'+pdfdocwidth+'" 
  height="'+pdfdocheight+'"></iframe>  </div> </td></tr>';
}
2
  • 1
    404 - not found. Check the generated HTML and see if it's generating a link to a resource that doesn't exist. Commented Nov 12, 2013 at 10:18
  • I checked that the paths in the generated HTML file are correct. Also, as mentioned the pdf files are viewed. Commented Nov 12, 2013 at 11:16

1 Answer 1

1

Not all browsers handle PDFs the same way. I suggest to have a look here : http://pdfobject.com/ it will do exactly what you want.

Sign up to request clarification or add additional context in comments.

2 Comments

Great site and technique to handle pdf's +1
thnx, I read about pdfobject earlier on this site. I'll look at it. But I'm still wondering whether the latest browser versions handle something that's defined in a standard in a different way? Or is the iframe concept not supposed to work with files?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.