Document Template Designer Web App
Budget: ₹37,500 – ₹75,000 INR
A) Web app (template designer UI)
Use an embedded DOCX editor:
ONLYOFFICE Docs (most common for embedding)
Flow:
Your UI has a page /templates/:id/edit
You embed ONLYOFFICE editor in that page (iframe + their JS config)
Add a custom button: Insert Placeholder
Clicking it inserts something like {{Customer.Name}} at the cursor
B) Backend services
You typically have 3 backend parts:
File service
Store original DOCX + edited template DOCX (S3 / Azure Blob / disk)
Template metadata
Store “field definitions” in DB:
field_key: Customer.Name
label: “Customer Name”
type: string/date/number
optional formatting rules
Document generation service
Input: template DOCX + JSON data
Output: generated DOCX (and optional PDF)
For merging placeholders, a popular approach in Node is docxtemplater
(If you’re .NET-heavy, you can also do OpenXML-based merging, but Node tooling is often faster to implement.)
Step-by-step implementation
Step 1: Upload DOCX
User uploads a DOCX file
Backend stores it and creates a template_id
DB:
templates(id, name, original_docx_path, working_docx_path, created_by, created_at)
Step 2: Open DOCX in embedded editor
Embed ONLYOFFICE Docs editor in your template page.
What you need:
ONLYOFFICE Document Server running (Docker is common)
Your backend provides:
a file URL that ONLYOFFICE can load
a callback URL that ONLYOFFICE calls when user saves
ONLYOFFICE is designed for this “embed and save back” flow via their Docs API.
Step 3: Add placeholders in “editable mode”
There are two ways:
Approach 3A (fastest): insert placeholder as text
Insert exactly {{FieldName}}
Example: {{Customer.Name}}
Pros: simple
Cons: user can accidentally edit/break the tag
Approach 3B (more robust): use structured fields (content controls)
Some editors allow content controls / protected regions. This is more reliable but more work and depends on editor APIs.
For MVP, do 3A. Most products start there.
Step 4: Capture what placeholders exist
When the user finishes editing:
On save, backend receives the updated DOCX
Backend scans the DOCX for {{...}} tags and stores the unique keys in DB
Now your app can show:
“Detected fields: Customer.Name, Loan.Amount, Loan.StartDate”
Let user map these to your system fields
Step 5: Generate document with real data
When you need to generate:
Load template DOCX
Prepare a JSON object:
{
"Customer": { "Name": "John Doe" },
"Loan": { "Amount": 25000, "StartDate": "2026-02-10" }
}
Run merge → output DOCX (optionally convert to PDF)
If using docxtemplater, it’s built for “replace placeholders in docx using data”.
Important details you should plan for
Placeholder rules: restrict allowed characters (A-Z a-z 0-9 . _) so parsing is reliable.
Escaping: avoid {{ in normal text or allow an escape format.
Repeating tables: eventually you’ll want lists (e.g., line items). Most templating engines support loops, but that’s a “phase 2”.
PDF output: can be done later via LibreOffice headless, ONLYOFFICE conversion, or a paid converter.
Frontend: React / Angular / plain HTML
Editor: ONLYOFFICE Docs embedded
Backend: .NET API (for auth/storage/metadata)
Merge service: Node.js microservice using docxtemplater
(or do it in .NET with OpenXML if you prefer single-stack)
Use an embedded DOCX editor:
ONLYOFFICE Docs (most common for embedding)
Flow:
Your UI has a page /templates/:id/edit
You embed ONLYOFFICE editor in that page (iframe + their JS config)
Add a custom button: Insert Placeholder
Clicking it inserts something like {{Customer.Name}} at the cursor
B) Backend services
You typically have 3 backend parts:
File service
Store original DOCX + edited template DOCX (S3 / Azure Blob / disk)
Template metadata
Store “field definitions” in DB:
field_key: Customer.Name
label: “Customer Name”
type: string/date/number
optional formatting rules
Document generation service
Input: template DOCX + JSON data
Output: generated DOCX (and optional PDF)
For merging placeholders, a popular approach in Node is docxtemplater
(If you’re .NET-heavy, you can also do OpenXML-based merging, but Node tooling is often faster to implement.)
Step-by-step implementation
Step 1: Upload DOCX
User uploads a DOCX file
Backend stores it and creates a template_id
DB:
templates(id, name, original_docx_path, working_docx_path, created_by, created_at)
Step 2: Open DOCX in embedded editor
Embed ONLYOFFICE Docs editor in your template page.
What you need:
ONLYOFFICE Document Server running (Docker is common)
Your backend provides:
a file URL that ONLYOFFICE can load
a callback URL that ONLYOFFICE calls when user saves
ONLYOFFICE is designed for this “embed and save back” flow via their Docs API.
Step 3: Add placeholders in “editable mode”
There are two ways:
Approach 3A (fastest): insert placeholder as text
Insert exactly {{FieldName}}
Example: {{Customer.Name}}
Pros: simple
Cons: user can accidentally edit/break the tag
Approach 3B (more robust): use structured fields (content controls)
Some editors allow content controls / protected regions. This is more reliable but more work and depends on editor APIs.
For MVP, do 3A. Most products start there.
Step 4: Capture what placeholders exist
When the user finishes editing:
On save, backend receives the updated DOCX
Backend scans the DOCX for {{...}} tags and stores the unique keys in DB
Now your app can show:
“Detected fields: Customer.Name, Loan.Amount, Loan.StartDate”
Let user map these to your system fields
Step 5: Generate document with real data
When you need to generate:
Load template DOCX
Prepare a JSON object:
{
"Customer": { "Name": "John Doe" },
"Loan": { "Amount": 25000, "StartDate": "2026-02-10" }
}
Run merge → output DOCX (optionally convert to PDF)
If using docxtemplater, it’s built for “replace placeholders in docx using data”.
Important details you should plan for
Placeholder rules: restrict allowed characters (A-Z a-z 0-9 . _) so parsing is reliable.
Escaping: avoid {{ in normal text or allow an escape format.
Repeating tables: eventually you’ll want lists (e.g., line items). Most templating engines support loops, but that’s a “phase 2”.
PDF output: can be done later via LibreOffice headless, ONLYOFFICE conversion, or a paid converter.
Frontend: React / Angular / plain HTML
Editor: ONLYOFFICE Docs embedded
Backend: .NET API (for auth/storage/metadata)
Merge service: Node.js microservice using docxtemplater
(or do it in .NET with OpenXML if you prefer single-stack)
Related categories:
.NET
Node.js
Web Development
Backend Development
Frontend Development
Database Design
API Development
Microservices