Document AI
The Aspose.Words Document AI for .NET plugin allows developers to translate or summarize documents and check their grammar. Integrates with LLMs such as Gemini, Claude, and OpenAI.
Installation and Setup
- Install the Aspose.Words for .NET package via NuGet or the Package Manager Console.
- Configure Metered Licensing before running mail-merge operations.
Compatible with Windows, Linux, macOS, and mobile platforms using .NET Framework, .NET Core, or Mono. Supported IDEs include Visual Studio (2010–2026), Xamarin, and MonoDevelop 2.4+.
IDEs: Visual Studio 2017–2026, JetBrains Rider, MonoDevelop.
Supported Template / Output Formats: DOC, DOCX, RTF, DOT, DOTX, DOTM, DOCM, Word 2003 XML, and Word 2007 XML.
Translate a Document
Translate your documents into any language represented in the Language enumeration:
Document doc = new Document(MyDir + "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(ArtifactsDir + "AI.AiTranslate.docx");Summarize a Document
Generate a document summary, specifying its length:
- VeryShort – 1-2 sentences
- Short – 3-4 sentences
- Medium – 5-6 sentences
- Long – 7-10 sentences
- VeryLong – 11-20 sentences
Document firstDoc = new Document("Big document.docx");
Document secondDoc = new Document("Document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use OpenAI or Google generative language models.
AiModel model = ((OpenAiModel)AiModel.Create(AiModelType.Gpt4OMini).WithApiKey(apiKey)).WithOrganization("Organization").WithProject("Project");
SummarizeOptions options = new SummarizeOptions();
options.SummaryLength = SummaryLength.Short;
Document oneDocumentSummary = model.Summarize(firstDoc, options);
oneDocumentSummary.Save("AI.AiSummarize.One.docx");
options.SummaryLength = SummaryLength.Long;
Document multiDocumentSummary = model.Summarize(new Document[] { firstDoc, secondDoc }, options);
multiDocumentSummary.Save("AI.AiSummarize.Multi.docx");Check Document Grammar
Check grammar and detect errors in documents:
Document doc = new Document(MyDir + "Big document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use OpenAI generative language models.
AiModel model = AiModel.Create(AiModelType.Gpt4OMini).WithApiKey(apiKey);
CheckGrammarOptions grammarOptions = new CheckGrammarOptions();
grammarOptions.ImproveStylistics = true;
Document proofedDoc = model.CheckGrammar(doc, grammarOptions);
proofedDoc.Save("AI.AiGrammar.docx");Frequently Asked Questions
Q: What file formats can use with the Document AI for .NET? The Aspose.Words Document AI for .NET plugin supports DOC, DOCX, RTF, DOT, DOTX, DOTM, DOCM, Word 2003 XML, and Word 2007 XML formats.
Q: What models can I use with the Aspose.Words Document AI for .NET? Document AI for .NET can be integrated with LLMs such as Gemini, Claude, and OpenAI.