back to home

DaveMoudy / SalesforceDocGen

This package contains all the parts and moving pieces needed to run the DocGen app in Salesforce.

View on GitHub
184 stars
38 forks
0 issues
ApexHTMLJavaScript

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing DaveMoudy/SalesforceDocGen in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/DaveMoudy/SalesforceDocGen)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

DocGen — Free Document Generation for Salesforce Turn any Word template into a merged PDF or DOCX, straight from your Salesforce records. --- Install (2 minutes) **Latest (v2.2.0 — PDF Merger)**: Or click: Install in Production | Install in Sandbox **Previous (v2.0.0 — Apollo)**: Or click: Install in Production | Install in Sandbox **After install:** • Assign the **DocGen Admin** permission set to yourself (Setup > Permission Sets) • Enable the **Blob.toPdf() Release Update** (Setup > Release Updates > "Use the Visualforce PDF Rendering Service for Blob.toPdf() Invocations") • Open the **DocGen** app — the getting started guide walks you from there --- How It Works • **Name your template** — pick a name, output type (PDF or Word), and the Salesforce object • **Pick your data** — use the visual query builder to select fields, parent lookups, and child lists (supports deep nesting: Account → Opportunities → Line Items) • **Upload your Word file** — add merge tags like , , or where you want data • **Generate** — from any record page, or in bulk, or from a Flow That's it. DocGen handles the rest — merging data, injecting images, rendering PDFs, all server-side. --- What You Can Put in Your Templates | Tag | What It Does | Example | |-----|-------------|---------| | | Inserts a field value | , , | | | Pulls from a related record | , | | | Repeats for each child record | | | | Nested loops (deep relationships) | | | | Formatted date | | | | Dynamic image from ContentVersion | | | | Show/hide based on field value | | | | Full rich text (bold, italic, images) | on a Rich Text Area | Tags inherit the formatting from your Word template — whatever font, color, and size the tag has in Word is what the output gets. --- Why No Signatures? DocGen generates documents. That's it. Electronic signatures carry legal requirements (ESIGN Act, eIDAS) that change by jurisdiction. Getting it wrong exposes you to liability. Dedicated providers like DocuSign and Adobe Sign carry their own compliance certifications. We don't, and we won't pretend to. Generate your document with DocGen. Send it to a signature provider. Best tool for each job. --- Features | Feature | Description | |---------|-------------| | **Command Hub** | One-tab experience: create templates, generate in bulk, get help — all in one place | | **Visual Query Builder** | Point-and-click field selection with parent lookups and nested child lists | | **Deep Relationships** | Account → Opportunities → Line Items → Schedules. No depth limit in templates. | | **PDF Generation** | Server-side via with zero-heap image rendering | | **DOCX Output** | Client-side assembly for unlimited file sizes. Custom fonts carry through. | | **Bulk Generation** | Hundreds of records with real-time progress tracking | | **Flow Integration** | (single) and (bulk) invocable actions | | **Image Injection** | Dynamic images from ContentVersion IDs, rich text fields, or template-embedded graphics | | **Template Versioning** | Full history with preview, download, restore, and sample generation | | **PDF Merger** | Merge generated PDFs with existing PDFs on the record — client-side, no heap limits | | **Zero External Dependencies** | No HTTP callouts, no JavaScript libraries, no external services | --- How DocGen Stays Under Salesforce Limits Salesforce gives each transaction 6 MB of memory. DocGen uses three techniques to stay well under that: | Technique | What It Does | Impact | |-----------|-------------|--------| | **Pre-decomposition** | When you save a template, DocGen unzips the .docx and stores each piece separately. At generation time, it loads only the XML — never the full ZIP. | ~75% heap reduction | | **Zero-heap images** | Images are passed to the PDF engine by URL, not loaded into memory. 20+ large images render without using any of your 6 MB. | Unlimited images in PDFs | | **Client-side DOCX** | For Word output, the browser assembles the final file. Each image gets its own request with fresh memory. | No size limit on DOCX | | **Client-side PDF merge** | Existing PDFs are fetched one at a time (fresh heap each call), merged in the browser via a pure JS PDF engine. | Unlimited merge size | | **Multi-level queries** | Deep relationships (grandchildren) use one SOQL query per level, not per record. Results are stitched together in Apex. | 3 levels = 3 queries | --- For Developers Permission Sets | Permission Set | Who | What | |---------------|-----|------| | **DocGen Admin** | Template managers | Full CRUD, template sharing, setup | | **DocGen User** | End users | Generate documents, view templates | Flow Actions | Action | Inputs | Output | |--------|--------|--------| | | templateId, recordId | contentDocumentId | | | templateId, queryCondition | jobId | Architecture | Class | Role | |-------|------| | | Core merge engine — tags, images, ZIP | | | XML → HTML for PDF rendering | | | Dynamic SOQL with multi-level stitching | | | LWC controller — template CRUD, generation | | | Batch Apex for bulk jobs | PDF Merger Generate a document from your template and merge it with existing PDFs already attached to the record — all in one step. • Select a PDF template from the record page • Check **Merge with existing PDFs on this record** • Pick which PDFs to append • Click **Generate & Merge** — downloads or saves a single combined PDF The merge runs entirely client-side using (pure JS, no external libraries). Each source PDF is fetched via its own Apex call with fresh 6 MB heap, then the browser handles the binary merge — no server-side size constraints. PDF Font Support PDF output supports **Helvetica**, **Times**, **Courier**, and **Arial Unicode MS** only — this is a Salesforce platform limitation ( does not support ). For custom fonts, generate as DOCX. Known Limits | Limit | Value | Notes | |-------|-------|-------| | Heap (synchronous) | 6 MB | Single record generation from UI or Flow | | Heap (asynchronous) | 12 MB | Bulk ge…