Building an automated script to copy a page of text, translate it in Google Translator and paste it in Word

StackOverflow https://stackoverflow.com/questions/23262419

سؤال

So, as the title says, I would like to make an automated script that is going to take all the text from one PDF page, copy it, paste it into Google Translate and then copy the translated text into another Microsoft Word document.

Since that PDF has a lot of pages (150+), I thought it may be easier to make an automated script to do that.

What language would I have to use, would it be complicated for me to do it and in the end, will I actually save time by using this script (implying that I have to learn it first, but I have some programming experience (I know C++, Javascript, PHP), but I do not have a strong grasp of algorithms (like Flood Fill, ...))?

Thanks in advance!

EDIT : I found that I could use AutoIt for scripting... but I don't know would I be better off using AutoIt or Powershell... I also want to learn something that would be enable me to create other scripts (for example to automate some processes I do in Camtasia Studio)... So, AutoIt or Powershell?

هل كانت مفيدة؟

المحلول

As an AutoIt user I would say AutoIt.

Copying text out of PDFs is not quite as simple as you might imagine. Mileage will vary on how the PDF was created, and there are several methods you can use:

  • Most PDFs will have most of the text in the file itself, allowing you to get the text using a simple method like this
  • This method uses zlib to do something to the pdf. Not sure what as I've never tried it.
  • There are a variety of examples of using third party programs to do this, which may be better. There is one using Debenu and another using XPDF
  • Automating other programs such as acrobat should be possible, in acrobats case they have an api that can be used, though I'm not aware of this already being wrapped in AutoIt.

As to the rest of the requirements, there is a UDF to translate with google translate here, and the word UDF is a standard one that comes with the AutoIt installation.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top