chenop
chenop

Reputation: 5133

Display embedded doc / docx / pdf inside HTML using Google APIs

I have a problem to display doc / docx / pdf docs assuming I have an online link to them (i.e. http://my.site.com/files/file_id_123423234)

2 Alternative I know Google provide are 2 following links:

  1. http://docs.google.com/gview?url=[link_to_file]

    Example:
    http://docs.google.com/gview?url=http://my.site.com/files/file_id_123423234&embedded=true

  2. https://docs.google.com/viewerng/viewer?url=[link_to_file]

    Example:
    https://docs.google.com/viewerng/viewer?url=http://my.site.com/files/file_id_123423234&embedded=true

Both alternatives not always manage to successfully display the doc ending up the http call with "no preview available": enter image description here

Can you please provide a solution / alternative?

Upvotes: 2

Views: 4622

Answers (2)

Hulunlante Worku
Hulunlante Worku

Reputation: 9

Yes you can embed docs through tag with url like this HTML

First make sure the url must be valid doc by itself.

make sure to replace your url value

<iframe src="https://docs.google.com/viewerng/viewer?url=your_file_url&embedded=true">

you can set width and height properties

    <iframe src="https://docs.google.com/viewerng/viewer?url=your_file_url&embedded=true" width="900" height="900">

Upvotes: 0

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17613

You just need to make use of the Embedded links. To do this, you have to publish the files on the web as stated in Publish and embed Google Docs, Sheets, Slides & Forms.

File -> Publish to the Web. Get the Embed Link.

Upvotes: 0

Related Questions