Translate Word, PDF, Web documents in C#

.NET solution for translating documents using AI

Seamless integration with Google Gemini generative language models provides extensive AI-based document processing capabilities for C#, F#, VB.NET applications.

View code snippet

Translate Documents to 300+ Languages in C#

Automate document translation using Google Gemini AI models with Aspose.Words for .NET. Translate DOC, DOCX, RTF, PDF, HTML, Markdown, ODT, TXT, and EPUB files into over 300 languages while preserving the original layout and formatting. The AI-based engine detects the source language automatically — even in multi-language documents — and leaves untranslated only those fragments it cannot identify.

Why Developers Choose Aspose.Words for Document Translation

  • Single API call to translate an entire document
  • Automatic source-language detection for mixed-language documents
  • Output preserved in the original format and layout
  • Support for DOC, DOCX, RTF, PDF, ODT, HTML, Markdown, TXT, EPUB, and more

Authentication requires a Google API key. For a full list of supported AI models, see the API Reference.

Start translating documents in C# today — try the live demo above.

Example code in C# for translating a document
Select the target format from the list
Run code
dotnet add package Aspose.Words
Copy
using Aspose.Words;

Document doc = new Document("Document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");

// Use Google generative language models.
AiModel model = AiModel.Create(AiModelType.GeminiFlashLatest).WithApiKey(apiKey);

Document translatedDoc = model.Translate(doc, Language.Arabic);
translatedDoc.Save("Output.docx");
using Aspose.Words;

Document doc = new Document("Document.docx");
// Pass an empty string if the self-hosted model does not require an API key.
AiModel model = new CustomAiModel("my-model-24b", "https://your-server.com/v1").WithApiKey("");

Document translatedDoc = model.Translate(doc, Language.Arabic);
translatedDoc.Save("Output.docx");

class CustomAiModel : OpenAiModel
{
    private readonly string mUrl;
    internal CustomAiModel(string name, string url) : base(name) { mUrl = url; }
    public override string Url => mUrl;
}
Run code

How to translate a document in C#

  1. Install Aspose.Words for .NET.
  2. Add a library reference (import the library) to your C# project.
  3. Open the source file in C#.
  4. Invoke Translate method, passing in your document along with the target Language.
  5. Once completed, you will receive a translated document that you can save as a new file in the format you need.

.NET library to translate documents

There are three alternative options to install "Aspose.Words for .NET" onto your system. Please choose one that resembles your needs and follow the step-by-step instructions:

System Requirements

Our product is fully cross-platform and supports all major .NET implementations:

  • .NET ≥ 5.0
  • .NET Core ≥ 2.0
  • .NET Standard ≥ 2.0
  • .NET Framework ≥ 3.5
  • MonoMac
  • MonoAndroid
  • Xamarin

As far as .NET code doesn't depend on the underlying hardware or operating system, but only on a Virtual Machine, you are free to develop any kind of software for Windows, macOS, Android, iOS and Linux. Just make sure you have installed the corresponding version of .NET Framework, .NET Core, Windows Azure, Mono or Xamarin.

We recommend using Microsoft Visual Studio, Xamarin, and MonoDevelop integrated development environments to create C#, F#, VB.NET applications.

Fore more details please refer to Product Documentation.

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2026. All Rights Reserved.