Reliable Document AI in .NET: LLM Tool Calling vs. LLM-Generated Files
Reliable document AI needs a deterministic engine. With LLM tool calling, the LLM decides what the document should contain, and TX Text Control generates the file.

If you are architecting a .NET workflow with AI-based document generation, one of the most important decisions is how the final file is produced, not which model you use.
LLM tool calling is a more reliable way to generate documents with AI than letting the model generate the file itself. The model decides what the document should contain and turns that intent into structured tool calls; a deterministic document engine decides how, executing those calls and generating the final file.
This article compares the two common architectures, explains why LLM-generated files are not production-ready, and shows how TX Text Control supports a tool-calling approach. In document AI, the output is only as reliable as the engine that produces it.
Two ways to integrate AI into documents
There are two basic architectures for generating documents with AI: let the model fully generate the file, or let the model call a document engine. The difference largely decides whether your document AI is ready for production.
LLM-generated files: the model generates the file. The LLM produces the document itself, typically by writing and running code that builds the file. This is how AI assistants create Word and PDF files behind the scenes. Because the model writes new code on every run, nothing guarantees the layout or the structure.
LLM tool calling: the model calls the engine. The LLM interprets the request and translates it into structured calls to predefined operations. For example: merge this data into that template, add a table, apply this style, and export as PDF/A. A document engine such as TX Text Control executes those calls and produces the file.
| LLM-generated files | LLM tool calling | |
|---|---|---|
| Who produces the layout | The model, by prediction | The document engine, by rules |
| Rendering | Varies by run | Deterministic |
| Pagination, headers, footers, fields | Approximated | Exact |
| PDF/A, PDF/UA, signatures, e-invoice formats | Usually missing | Built-in |
| Audit trail | Logs show new code on every run | Logs show which predefined operations ran |
| Token cost | Grows with document size | Grows with the request, not the document |
| Where the document lives | Sent through the model | Can stay on your server |
Why LLM-generated files are not production-ready
An LLM-generated document can look flawless in a demo and still break in production. The causes usually come down to these recurring problems:
1. Layout is not a language problem. Page breaks, table rows that split across pages, headers that change by section, and list numbering that restarts correctly are produced by a layout engine applying fixed rules. An LLM can imitate how the result looks, but it can't guarantee it. For a contract, that means page and clause references you can't trust.
2. Compliance lives in the file format, not the text. PDF/A for archiving, PDF/UA for accessibility, embedded e-invoice XML, and timestamped digital signatures live in the structure of the file itself, not in its visible text. A model can describe them, but only software built for these standards can produce them correctly and pass validation.
3. Regulated work must be repeatable and auditable. In legal, healthcare, finance, and government, documents often have to be reproduced years later. An LLM can word the same document differently on every run, and its logs show one-off code that changes each time, which makes the process hard to audit or reproduce.
4. Revisions get expensive at scale. Generated documents often need changes after the first draft. When the LLM generates the file, changing one paragraph often means regenerating the whole document, or the code that builds it. Each time, the whole document costs tokens, time, and compute, not just the change.
5. Sensitive documents should stay on your servers. Contracts, patient letters, and HR files are exactly the content companies least want to send to an external model. But when the model generates the file, the entire document has to pass through it, and with a hosted model, that means sending it to a third-party service.
What a deterministic engine provides for document AI
TX Text Control is a document engine built around a word processing layout core, so the same document renders consistently in the editor, on the server, and as a PDF. That consistency is what AI-driven document workflows need underneath them. Here is how it works in practice, using examples we have already published.
Prompts become tool calls, not documents. A common way to set up tool calling is the Model Context Protocol (MCP), an open standard that defines how AI applications connect to external tools. An MCP server exposes a set of tools, such as document operations, that the model can discover and call. In our MCP document generation example, the model never writes the document. It turns a plain-language request into tool calls, and TX Text Control executes them to create the file. Our guide to building an MCP-based document processing backend shows how to apply the same pattern in your own application.
AI suggestions as tracked changes, not direct edits. In legal document AI, we describe an architecture where the model suggests edits and the engine applies them as reviewable tracked changes in the real document. A lawyer then reviews each suggestion and accepts or rejects it, just like edits from a colleague, using a familiar track changes review workflow.
Conversion in code, not in tokens. Converting a document is a deterministic task. For enterprises with large volumes of documents, paying a model for each conversion adds up quickly. TX Text Control converts Word and HTML documents to Markdown in code before they reach the model, which also gives the model leaner input that uses fewer tokens. On the way out, the model writes Markdown, and TX Text Control renders it into a paginated PDF, with no token cost for either conversion.
Explainable analysis, no model required. Our document analysis samples classify documents, extract tables, and map template fields using deterministic rules instead of an AI model. Every result shows its evidence and is reproducible with the same rules, so the automation stays explainable.
Private by design. TX Text Control AI combines local generative AI, private knowledge retrieval, and TX Text Control document processing, so documents don't have to be sent to a public model service. The model runs on infrastructure you control, from a developer workstation to a private GPU server, and you can run it locally in .NET with no API key.
Compliance comes built in. Because TX Text Control produces the final file, AI-driven workflows get the same standards support as any other TX Text Control workflow: accessible PDF/UA documents, digital signatures with timestamps, PDF/A for archiving, and e-invoice formats such as ZUGFeRD and Factur-X.
Where the LLM still fits
The LLM handles language: understanding requests, drafting text, and summarizing. The engine handles everything that must be exact: layout, numbering, and the final file.
| The model decides what | The engine decides how |
|---|---|
| Which template fits this request | Filling it with the right data, with correct pagination |
| What a clause should say | Inserting it as a tracked change in the right place |
| Which fields to pull from the document | Extracting the fields reliably |
| What the user means by "make it formal" | Applying styles, numbering, and headers consistently |
| What the summary should say | Exporting it as a signed, archivable PDF/A |
Conclusion
An LLM adds real value when it decides what a document should say or change. It becomes a risk when it produces the file itself. Keep the model on the intent side through tool calling, put a deterministic engine on the output side, and document AI becomes something you can audit, repeat, and ship.
That is how we build AI into TX Text Control: private models for understanding, and a proven document engine for everything that must be exact. Explore TX Text Control AI, or talk to our team about the document workflows you want to automate.
Frequently Asked Questions
LLM tool calling. The LLM interprets the request and decides the content, then calls a document engine such as TX Text Control to create the file. The engine handles pagination, layout, and compliance features such as PDF/A and PDF/UA, so the results are consistent and reproducible.
With tool calling, the LLM translates a request into structured calls to predefined document operations, such as creating a document, changing styles, or exporting a PDF. A document engine executes those calls. In TX Text Control AI, these operations are exposed to the model through an MCP document server.
Yes, most reliably when a document engine applies the edits instead of the model rewriting the file. In the architecture described in our legal document AI article, the LLM suggests changes and TX Text Control inserts them as tracked changes that a person accepts or rejects.
Yes. TX Text Control AI runs local models on infrastructure you control, from a developer workstation to a private GPU server, with no API key required. Running locally gives you control over where data is processed; security and compliance still depend on how you deploy it.
Not reliably. PDF/A and PDF/UA depend on the internal structure of the file, which an LLM writing the file can't guarantee. When the LLM drafts the content and a document engine produces the final file, the output can meet both standards: TX Text Control can create tagged, PDF/UA-compliant documents and PDF/A output.
ASP.NET
Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.
- Angular
- Blazor
- React
- JavaScript
- ASP.NET MVC, ASP.NET Core, and WebForms
Related Posts
ASP.NETASP.NET CoreDocument Generation
Building a Production-Ready PDF Generation Pipeline in C# with ASP.NET Core
Learn how to build a reliable PDF generation pipeline with TX Text Control and ASP.NET Core. Use durable background jobs, idempotency, renewable leases, PDF validation, and private artifact…
Introducing TX Text Control AI: Private AI for Real Document Workflows in…
Today, we are excited to introduce the TX Text Control AI Preview, a suite of six NuGet packages and ten sample applications that integrate local generative AI, private knowledge retrieval, and TX…
ASP.NETASP.NET CoreDocument Viewer
Native PDF Annotation Support Is Coming to the TX Text Control Document Viewer
The next version of the TX Text Control Document Viewer will introduce an important enhancement to PDF workflows: native support for PDF-compatible annotations. Users will be able to add…
Building a Browser-Based PDF Workflow for Medical Billing using .NET C#
Learn how to create a browser-based PDF workflow for medical billing with .NET C# and TX Text Control. TX Text Control .NET Server offers different components optimized for the individual parts of…
AI Natural Language Document Generation with MCP and TX Text Control .NET
This article explains how AI agents can use natural language to create documents through an MCP server. Instead of letting a language model generate documents directly, the AI translates prompts…
