Just a little background: As you might know, if you have an image in Google drive and you try to open it with Google Docs, Google tries to extract the text within your image (OCR) and show the text alongside the image in a newly created Google Docs file.
I am writing a script and within that script I would like to open an image (with some text) with Google Docs.
When I try to do it through the following code, I just an Error message with no explanation on why it fails.
var file_url = file.getUrl();
try
{
var doc = DocumentApp.openByUrl(file_url);
}catch (e) {
Logger.log("Error Occurred: " + e.toString());
}
Any help would be appreciated.
Edit 1: Here is an actual scenario. I have the following .png image and I can open it with Google Docs.
When I open with Google Docs, I get the following document:
Document generated after opening the .png image with Google Doc.
Having the url of this .png file, I would like to do all this through my script so I can have the OCR generated text.
I would like to open an image (with some text) with Google Docs.
, do you want to insert an image to Google Document? About this, can you provide a sample result you want? 2. What isfile_url
ofvar doc = DocumentApp.openByUrl(file_url);
? – Tanaikefile_url
is just a url of an image file in Google Drive. – Sep