Google Document Viewer shows "No Preview Available" in php

1k views Asked by At

For some reason with the following embed code:

    https://docs.google.com/gview?url=<?php echo $url;?>&embedded=true

I have been getting a no preview available. It was working, and now it doesn't seem to.

Is there a good alternative where I can view PDF and Office files?

Thank you!

2

There are 2 answers

0
Kevin On BEST ANSWER

After much looking, I found a solution, I used the standard PDF viewer with an iframe.

3
Cullub On

You may have an old version of the viewer URL format. Here's a different link format that's documented in a GitHub gist.

https://docs.google.com/viewer?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true

If you want to embed it within a page, you can use an iframe.

<iframe src="https://docs.google.com/viewer?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>