Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
339 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to use the api to move files (.docx etc) through the translator api. Is this possible?
Hi,
Thanks for reaching out to us. The API itself can not take .docx file directly, if you want to do that, you can write a function to read the .docx file first. The code following for your reference.
Application word = new Application();
Document doc = new Document();
object fileName = path;
// Define an object to pass to the API for missing parameters
object missing = System.Type.Missing;
doc = word.Documents.Open(ref fileName,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
String read = string.Empty;
List<string> data = new List<string>();
for (int i = 0; i < doc.Paragraphs.Count; i++)
{
string temp = doc.Paragraphs[i + 1].Range.Text.Trim();
if (temp != string.Empty)
data.Add(temp);
}
((_Document)doc).Close();
((_Application)word).Quit();
GridView1.DataSource = data;
GridView1.DataBind();
Please let me know if you have more questions. Thanks!
Regards,
Yutong
Thank you Yutong - I will test this out.