Google Document Viewer shows "No Preview Available" in php - php

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!

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>

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

Related

how to convert pdf file into html and display them in iframe

I am working on content oriented website and using I frames to display pdf.when I am opening that page in the mobile browser it starts automatically starts downloading the pdf,how could I display pdf file using iframe in browser instead of downloading.
Now i am thinking to convert pdf's into HTML and pass HTML file as source in frame.
Suggest me some other alternative if I'm wrong and if I'm right then suggested me some pdf to HTML convertors,which can convert in bulk as I have very large number of files.
**EDIT:**thanks,it worked but can how can i stop it from being download,i'm thinking of disabling right click,will it work
One thing you can do is to upload your PDF somewhere and just use its URL.
You can also use Google PDF viewer for this purpose.
For more information check this Recommended way to embed PDF in HTML?
There are many ways you can make this possible one of them would be use the following <embed> element with source link to your pdf file :
<embed src="http://example.com/yourfile.pdf" width="1000" height="500" type='application/pdf'>
Another one is you can use the javascript library also :
pdf.js
and one last i have in mind is you can use google docs api url to view the : docx,doc,xls,pdf,ppt or any other document file online by using the method below:
https://docs.google.com/viewer?url=http://example.com/yourfile.pdf

How to display video a url in php?

I'm trying to create a form in which a user inserts their youtube code into a field, which is then stored in mysql.
how can i display video?... while fetching data from my database it displays the video url name
How can I do it so that the link is permanently fixed in the php document and the end part is retrieved from mysql in a way that when the page is opened it displays the video correctly?
Very simple stuff when you know how to do it but I don't so I would appreciate if someone could tell me the way of doing this.
without embed only for example this url which will insert into database "https://www.youtube.com/watch?v=T95zFC4Z2pY" while retiring it by <?php echo $res['link']; ?> is there any other why except embed tag
you can use <iframe></iframe> tag. I hope it will helpful for you.
Try this:
<iframe width="420" height="345"
src="https://www.youtube.com/watch?v=T95zFC4Z2pY">
</iframe>
Since you are not giving an example of any code you have tried so far, I will not provide the code, instead I am going to point you in the direction.
Open up the youtube video Embed Tutorial
Then click on 'Share' under the description, then click on 'Embed'. Youtube will give you the code you need to embed your video.

Embedding Video Stream into webpage

This is a progress after the question Embedding Image/Video Stream into webpage that was answered for the picture only using curl, video is still an open issue.
Resuming, I need to avoid that the visitor of a web page see the real source of an image streming. So I want to embed the video a some wrapper php page that doesnt use any userid/password but is under my control. Embedding the video stream into any HTML page it's really easy:
<img src="http://5.246.77.89:8090/videostream.cgi?user=stack&pwd=overflow&resolution=32&rate=15" alt="">
For some time I'll give you the opportunity to test the source of the video streaming that I want to hide here
http://93.58.198.189:8090/videostream.cgi?user=stack&pwd=overflow&resolution=32&rate=15
Now all I need is a simple web page let say video.php that is able to stream the video without asking credentials and hiding the original source IP, something like
<img src='my.php'>
How can I obtain this behavior?
Note that despite the source is a video stream, the header is image/jpeg as you can see by yourself and it works with any browser. I've tried to use
<?php
header("content-type:image/jpeg");
passthru("http://93.58.198.189:8090/videostream.cgi?user=stack&pwd=overflow&resolution=32&rate=15");
?>
but for some reason doesn't work. Any idea?
Good question, i was also had a same problem.
Now its solved for me. just you can go to you tube video url where your video is stored and below the video there is share ad embed, you go to embed and there you will get a url which can be embeded to your video.php. it works.

PHP to view PDF on web page and disable user to download

I'm going to write a site that lets users to view pdf files but I don't want them to save the files to their own hard drive due to the copy right law. I'm researching how to view it by using PHP, but I have no idea how to disable user not to download the files.
Actually, I want to use JavaScript to disable this action, but I get suggestions from other people not to do so because it's annoying to user.
So any suggestion or help would be very much appreciated.
USE CSS opacity: 1.0 with a <div> positioned over your content...
You could output the pdf using <object> or <iframe>, then place a with absolute position and use z-index to cover your pdf. Use the css opacity: 1.0.
Now when users try to click or copy, they get nothing because they are really clicking on a blank <div>!!!!
Its a hack, but it works! The user will be able to read the content, they could take a screen shot, but they won't be able to actually copy the text and paste it anywhere.
Method 01
Implementing that useing Google books
<iframe frameborder="0" scrolling="no" style="border:0px" src="https://books.google.com.kh/books?id=e5MkzETNcsgC&lpg=PP1&dq=typography&pg=PA11&output=embed" width="500" height=500>
</iframe>
In above image it shows Embed that will be the code. And Download or Print option is not available on this. Google dosc can prevent download but its allow to Save to Drive option. Then in drive i can download it. But Google books not allow any of that.
in view
Method 02
Using Google Drive
Right click on pdf and goto Share(below image)
Then go to Advanced option in left bottom
Tick Both check boxes. After copy embed link and paste it to your src. No download and Save drive option is not allowed
Note: Method 01 and Method 02 is Tested
You can't prevent your visitors from downloading, copying or scrapping anything you're outputting to their browsers. If they can view it they can always screenshot it. Which brings in the optimal solution to your problem: Simply offer image copies of your documents instead of actual PDF files. You can convert / mass convert PDF files to JPEG easily with Photoshop.
I hope I am not very late to reply. But here's is something you can do to prevent the users. Use iFrame to display your PDF and make sure that you are displaying using Google. I used the following code :
<iframe src="http://docs.google.com/gview?url=http://www.tutorialspoint.com/php/php_tutorial.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0">
</iframe>
Here you can simply change the url=http://www.tutorialspoint.com/php/php_tutorial.pdf and replace it by your own URL where you kept your PDF.
Try this one:
<iframe src="test1.pdf" scrolling="no" frameborder="0" height="100%" width="100%" style="position:absolute; clip:rect (190px,1100px,800px,250px);">
try this
<embed src="http://URL_TO_PDF.com/pdf.pdf#toolbar=0&navpanes=0&scrollbar=0" width="500" height="500">

How do i display a part of the frame?

Here is the image :
So now how do i show only the "Red Boxed" part in my frame.
So is there any way i can position my frame or something to that dimensions ?
The short is that if you want to do it with google, you can't. (show a specific part of it)
To show all of it you can:
<iframe src ="http://google.com" width="100%" height="300">
<p>Your browser does not support iframes.</p>
</iframe>
See iframe
You can modify the width and height but you can't say where to start showing (because it's not you page).
The only thing you can do is put some div over it covering some parts
IMPORTANT, THIS IS JUST AN EXAMPLE
From Google's guidelines: Don’t frame or mirror any Google page (including the page that appears in response to a click on the Google logo or Google search box).
Thanks #Gordon!
Good luck!
with PHP you can retrieve the html and than quite easily edit it pragmatically.
Or try and use HTML FRAME Attributes... http://www.w3schools.com/tags/tag_frame.asp
The latter will only work if you try to get a part of your own page, and not google's..

Categories