Automated PDF Reporting with In-House LLMs: From Raw Data to Executive Reports
AIEnterprise AI Series · Part 2/5

2026-09-08•8 min

Automated PDF Reporting with In-House LLMs: From Raw Data to Executive Reports

We turn your ERP, accounting, and operational data into annotated, on-brand PDF reports without sending your data to the cloud.

PDF reportingon-prem LLMreport automationdocument processingdata privacyMersin

The Hidden Cost of Reporting

In many SMEs in Mersin, the weekly sales report, monthly inventory analysis, or export performance summary is still produced the same way: someone exports data from the ERP to Excel, builds pivot tables, copies charts into a slide deck or Word file, and writes a few paragraphs of commentary for management. It takes hours every week, depends on specific people, and is prone to copy-paste errors.

The most valuable part, answering questions like 'Why did citrus exports drop this month?' or 'Which customer segment is paying later?', usually stays superficial because there is no time left. This is exactly where large language models help: they can read tables and summarize notable changes, anomalies, and likely causes in plain language.

But sales figures, customer lists, and cost data are among a company's most sensitive information. Sending them to a cloud AI service abroad raises serious questions about commercial confidentiality and about cross-border data transfer rules under Turkey's data protection law (KVKK). The solution is to run the language model on the company's own servers.

A Reliable Architecture: Numbers from Code, Commentary from the Model

The most common mistake in LLM-based reporting is handing raw data to the model and saying 'write me a report'. Language models are not calculators; they can make mistakes when computing totals, percentage changes, or averages over long tables. A single wrong number in an executive report destroys trust in the whole document.

In the architecture we build, responsibilities are strictly separated. In the first layer, SQL queries and Python/.NET code pull data from ERP, accounting, or production systems, and all totals, ratios, period comparisons, and charts are computed deterministically in code. In the second layer, the LLM receives these computed metrics as a structured (JSON) summary and produces only commentary, summaries, and recommendations. The model never invents a number; it only refers to the numbers it was given.

A third layer runs validation: every number in the model's output is automatically checked against the source metrics, and any mismatch triggers regeneration or human review. Finally, text and charts are placed into a branded HTML template and converted with a tool such as headless Chromium or WeasyPrint into an archivable PDF with logo and page numbers. The report is then emailed or stored in the document management system.

Structured Output and Corporate Voice

Delivering the report in the same structure every week helps executives read it quickly. Instead of free text, we ask the model for output that follows a predefined JSON schema with fields such as 'executive summary', 'three key developments', 'risk alerts', and 'recommended actions'. Modern inference servers such as vLLM support guided decoding, which guarantees during generation that output conforms to the schema.

Corporate language and terminology can be taught to the system too. In most cases retraining is unnecessary: a well-written system prompt, a glossary of company-specific terms, and a few example reports from past periods (few-shot examples) are enough. When a very specific style or format is required, lightweight fine-tuning techniques such as LoRA can adapt the model to the company's voice with a few hundred examples.

Producing Turkish and English reports from the same data is particularly valuable for exporters in Mersin: a Turkish report for the board and an English one for international partners come out of the same pipeline with consistent figures.

The Other Direction: Extracting Data from Incoming PDFs

PDFs are not only a report output; supplier invoices, bills of lading, customs declarations, certificates of analysis, quotes, and contracts mostly arrive as PDFs, and their contents are typed into systems by hand. The same on-prem LLM infrastructure works in this direction too: the document's text and layout are extracted, and the model returns the required fields (invoice number, date, amount, HS code, weight, consignee) as structured data.

For scanned or photographed documents, OCR and layout analysis tools are used, while vision-language models that understand the image directly improve accuracy on hard cases such as tables and stamped documents. A confidence score is computed for each extracted field; low-confidence fields go to an operator for approval, high-confidence ones flow straight into the ERP. This human-in-the-loop approach combines the speed of automation with the reliability of review.

For a logistics or trading company in the Mersin Port and Free Zone ecosystem that handles hundreds of documents a day, this means a clear reduction in data-entry time and errors. And because every document is processed in-house, customer and commercial information is never passed to a third-party service.

Implementation Steps and Data Protection

A successful reporting automation project starts small. First, pick the most time-consuming and most standardized report (for example, the weekly sales summary) and identify existing samples, data sources, and readers. Second, build the data pipeline and template. Third, generate model commentary in parallel with the existing reports for a few weeks so the team can evaluate it. Once quality and trust are established, the report moves to automatic distribution and new report types are added.

From a KVKK and GDPR perspective, the on-prem advantage is clear: personal data and trade secrets stay on servers under the company's control, no cross-border transfer takes place, and access can be restricted using existing user management (Active Directory, LDAP). It is still necessary to document which data is processed for which purpose, log model inputs and outputs for auditing, and define retention periods.

At MeSoft we deliver end-to-end reporting solutions for manufacturing, logistics, agriculture, and trading companies in Mersin, from data-source integration and PDF template design to on-prem model deployment and the validation layer. The first article in this series covers the hardware side of this infrastructure, and the inference article covers performance optimization.

Back to all posts