Embed Google Drive Pdf In Html

0 views
Skip to first unread message

Favio Cassidy

unread,
Aug 3, 2024, 5:39:13 PM8/3/24
to styltaimaros

You have been using Google Drive to store your documents, images, videos and other important files. You can share your Google Drive images from anyone but there's no simple option to embed images hosted on Google Drive on to your website or email.

Go to drive.google.com, right-click any image file, and choose Get Link to get a shareable link of that image. Make sure that the access is set to Anyone on the internet with this link can view. Paste that file link in the box below to generate the HTML embed code.

The Google Drive embed app is running on Google Cloud Run. It uses Google's Puppeteer library to download the drive image page, extracts the oembed meta tags and converts the URL into an HTML tag for embedding.

Google Drive folders can be embedded and displayed in list and grid views (in which all you can do is click a file or folder to open it on a new tab). To do so, simply replace FOLDER-ID and for private folders (as of 2022) RESOURCE-KEY with your own in:

The id is the hash (alphanumeric gibberish) after folders/ in the URL of the folder. You can see the URL in the address bar of your browser when you open the Drive folder. The Resource Key you can find in the sharing link, after copying it. For example, in:

Since the introduction of the Resource Key parameter in 2022, and as of Jan 2023, embedding G Suite domain folders fails with a 403 Error ("We're sorry but you do not have access to this page. That's all we know."). The following is left just in case they fix it sometime.

This technique works best for folders with public access. Folders that are shared only with certain Google accounts can cause trouble when you embed them this way, depending on which Google accounts are active on the user's browser:

The blank frames are because Google forbids embedding its login page in an IFRAME (presumably to prevent account stealing), via the X-Frame-Options header, which if set to SAMEORIGIN will cause any well-behaved browser to refuse to load the page if it's not in the same domain (v.g. drive.google.com). You can see this in the developer console of your browser.

For private folders, have your users log to the correct account before loading the page with the embedded folder; if the folder is in a Google Apps domain, you can add the domain to the URL. Else, they must log into the authorised account before any other.

At the time of writing this answer, there was no method to embed which let the user navigate inside folders and view the files without her leaving the website (the method in other answers, makes everything open in a new tab on google drive website), so I made my own tool for it. To embed a drive, paste the iframe code below in your HTML:

1.)Go to the google drive folder you want to embed (for example, drive.google.com/drive/u/0/folders/1v7cGug_e3lNT0YjhvtYrwKV7dGY-Nyh5u [this is not a real folder]) Ensure that the folder is publicly shared and visible to anyone.

Note:This works only for files and subfolders you actually uploaded in the GDrive folder, not the subfolders you add as 'shortcut'. If a subfolder is displaying improperly, download it's contents and upload it to drive inside that specific folder. If you 'Move' folder within google drive, GDrive adds it as a 'shortcut'.

I made the widget keeping mobile users in mind, however it suits both mobile and desktop. If you run into issues, leave a comment here.I have attached some screenshots of the content of the iframe here.

Whatfix enables you to embed Google Drive videos to any Pop-up template to deliver more information to your users. The Visual Editor enables you to add a video to the Pop-up template directly using the UI. The video can be embedded in the description section. For more information on Whatfix Pop-up templates, see Choose the Pop-up template.

A link is generated for the video uploaded from your local drive or library. Find this link inside the video content you created on the Dashboard and then insert it in your Flows, Smart Tips, Pop-ups, and other Whatfix content.

When you make changes to the Pop-up using the Drag Handlers, you may not be able to undo certain changes. In that case, you may need to re-create the Pop-up. For more information, see Can I undo the changes made with the Drag Handlers?

Google drive makes it easy to host images online and share it anywhere. If you intend to add an image from your google drive account to you HTML code, it is pretty easy! In this write-up, I will show you a very quick way to go about it with 3 easy straight-forward steps.

First, go to your drive account (obviously, lol). Then you click on the New button and then add the image file (or folder) you wish to save on you Google drive, and tadaa! the image is now on your drive.

A typical link is of this format [image_id]/view?usp=sharing. Adding this to your img tag will not display the image. So what is the essence, yeah?
The link can be tweaked to =view&id=[image_id]. This new link can be used on your image tags and image displayed as desired.

Thanks for this! I actually created a CodePen incorporating your solution to make it easier for a customer to convert their Drive URLs in this way. They just paste in the sharing URL, click Convert, and it replaces the URL with the embeddable version.

I have studied the methods to embed a video file into a Google site using the Embed Gadget. There is documentation about the case when the video is from YouTube. In this case, in the iframe clause we can add ?autoplay=1&loop=1. This causes an auto start and when the end of the video is reached, it starts over again.

The problem however is that the loop instruction is ignored when the video is not from YouTube but from our own Google Drive. The reason I want the video to be loaded from the Google Drive is video quality. The conversion to YouTube results in an object which is much less sharp and clear.

So, why does the loop parameter not work when the source is different? Do I have to use a different syntax? (I also tried several approaches by modifying the resulting html code but I never was successful.)

As you can see, it is easy to embed videos on your site. Although there are well-known services, you might consider embedding a Google drive video rather than using them. There are several benefits. When you upload your video, most sites consider that as public. It means that you might not be able to specify who you want to show. When you share something from Google drive, you can easily set who can see. It also has a handy permission scope, an organization.

That being said, embedding a Google drive video supports a better permission scope and security. If you consider it, here are the steps. After uploading your video, you first need to share it. You can set specific users or an organization.

You used to be able to drag and make Google Docs larger, but in the past 4-6 months it changed and you are no longer able to do that in the rich content editor. Now you have to use HTML and guess what size you want the document. Why is it not working any longer?

After playing around with this for awhile, this is what I have found. Adding the height and width code does work, but it takes a LONG time for changes to show up. To make changes show up automatically, I had to go about it in an entirely different way.

Instead of publishing, I embedded it as if it were a video (and then changed the html code). It takes more steps, but I ended up liking the result a lot more (and for more reasons than just the automatic updates). See below for the steps.

That's all I found that works. But when you have multiple items embedded it gets really tough. I also have more knowledge than many in my building about computers, so the majority of people would not be okay with this. Dragging though is easier. We used to be able to do this.

Yes, you can change the size, but then you have changed the address and the "embedded" document no longer automatically updates when you make changes to the file. That is a pain. Then you must re-embed the document..

Just providing a shared link to the document does work, but it provides everything including the notes section if linking a Google Slide. It is a really clunky error that is still happening when less than a year ago we could drag embedded objects to change the size.

I sort of feel like you are doubting what happened. So I will tell you that I have already embedded google slides multiple times with no problem. When I embed a Google doc, it gives a super tiny screen like your blog post said, "Ugh". So I changed the numbers in the HTML code and got a viewing window that was appropriate, but then my updates to the original document would NOT show up on the Canvas embedded document. I kept refreshing the screen. But nothing changed until I re-embedded the document. I didn't see anything in your post you referenced that would help this. Did I miss something?

@rmerrill , I'm sorry you got the impression I'm doubting what happened, as I absolutely did not mean to convey that sentiment at all; rather (and I hope this is stated more eloquently), what you've reported here is brand-new behavior that I have not heretofore encountered, and commented in the hope that we can work toward a remedy. Have you asked Canvas Support to look into this?

I've been reading this thread and I have used Stefanie Sanders' very helpful tip on embedding dynamic content from Google Docs in Canvas, but now I just want to embed my course calendar- something I don't want students to be able to edit. When I use the embed code (and not the share link), the table comes out with narrower columns and in a frame that does not support its size without side scrolling and up/down scrolling.

I don't know if this helps, but I embed a few google docs in my Canvas pages and the only way I know how to do it is by embedding an iframe. You get the code from the "share" function in Google Docs. But the way I frames work is that you HAVE to specify the width and height as it can't be calculated in real-time. That's the one big drawback to any iframe.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages