Display embedded doc / docx / pdf inside HTML using Google APIs - google-api

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:
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
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":
Can you please provide a solution / alternative?

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.

Related

Extracting text from a Google document and get particular page

As of now, I export my Google documents by getting the content from this link:
https://docs.google.com/feeds/download/documents/export/Exportid=DOCUMENT_ID&exportFormat=EXPORT_FORMAT
This works fine, in fact I export my doc to an HTML format then I read from it, but there is no way to know when a page starts or ends.
Here's all the export formats I know of:
HTML, PDF, ODT, TXT, RTF and DOCX
PDF, ODT, RTF and DOCX all indicate separate pages when opened in a renderer. However, after searching for countless APIs for all formats (python-docx, PyPDF4, PyRTF etc), I have not been able to find a working way to read a Google document page by page.
Any suggestions?
You could use Apps Script with it you can take advantage of the DocumentApp where you can get PageBreaks.
You could then serve your tailored content as a web app.

Adding image to the GDrive document header

I've got web-application that works with google docs. App is uploading docs to GDrive with convertation and then i need to add image into converted document's header. How can i do this using GDrive API? I can't download full document or some converted formats, so i need to do this on google server. I am using SDK for PHP.
Google Drive API doesn't provide features to manipulate Google Docs files. What you can do is to modify the original file and upload again with conversion switched on. You can also use Google Apps Script. Please check out Document.header-section for more details.

How to get the file extension and size of a document in Google Docs?

Currently I am implementing .NET Google API to display Google Docs in my ASP.NET web application and I want to fetch the extension and size of Google Document, I got a way to get the extension by sub-scripting the Title of the Document from last index of "." but in case of spreadsheet it can be possible as it just contains the name of the spreadsheet document.
Please provide your suggestion here!!
Also, it would be better if you can provide source in C#!!
thanks!
You can use the Google Drive API to retrieve documents stored on Google Drive and check their metadata, including fileExtension, fileSize and many others:
https://developers.google.com/drive/v2/reference/files
All methods have .NET samples and there's also a complete ASP.NET MVC application that you canuse to get started:
https://developers.google.com/drive/examples/dotnet

Which Google API to use to search for files?

I have a search bar which should show me only the PDF files from Google when i start searching for something.Which API can i use for searching in google and how can i integrate that in my code.Are there any tutorial available for it.
You'll use the Documents List API
You'll search by MIME type.
It'll look like this (but needs to be properly encoded):
GET https://docs.google.com/feeds/default/private/full/-/{http://schemas.google.com/g/2005#kind}application/pdf

how to display embed and link in razor?

i'm trying to find out how to display youtube enbed and youtube link in razor
i'm using this #html.raw(item.MyUrl) and it is diplaying the "embed " data but i'm trying to find out (if can do ) a way to display also the youtube link (look like this(http://youtu.be/9hUy9ePyo6Q)
i have tryed decode and encode they also work in enbed but not by the Url link
#Html.Raw(HttpUtility.HtmlDecode(item.MyUrl))
## #Html.Raw(HttpUtility.HtmlEncode(item.MyUrl))
Thanks
did you try to use the item.MyUrl directly instead of using html.raw() ??

Resources