Back to Blog

Claude + Custom Apex vs Claude + ZeroExport MCP for Salesforce Documents

Claude + Custom Apex vs Claude + ZeroExport MCP for Salesforce Documents

You can ask Claude to write your own Apex PDF generator, or connect Claude to the ZeroExport DocGen MCP server. A side-by-side look at build time, governor limits, complex tables, validation and who maintains the result.

ZeroExport Team

Claude writes good Apex. Ask it for a class that queries an Opportunity, builds some HTML and calls Blob.toPdf(), and you will have a working quote PDF in an afternoon. So why buy a document generation product at all?

Because the afternoon is the cheap part. This post compares the two ways to put Claude to work on Salesforce documents:

  • Claude + custom Apex: Claude writes your own document generator, and your team owns the code.
  • Claude + ZeroExport MCP: Claude builds templates for an existing native engine through the ZeroExport DocGen MCP server.

The difference is in what Claude is asked to be. In the first, Claude is writing the rendering engine. In the second, Claude authors templates for an engine that already exists, and that engine validates every one.


Side by side

Claude + custom ApexClaude + ZeroExport MCP
What Claude producesApex classes, a Visualforce or HTML page, CSS and unit testsA ZeroExport template: data sources, layout and rules
First documentQuick for a flat, one-page documentQuick for any layout, including grouped tables
Getting to productionCode review, at least 75% test coverage, a deploymentValidation in the org, an inactive draft, review in the builder
Field namesWhatever Claude writes, checked when the code compiles or runsLooked up in your org, then checked again by ZeroExport's validator
Complex tablesCustom code for every merge, group and subtotalBuilt-in grouping, merged cells and subtotals
Large documentsYour code's responsibility, against Apex CPU and heap limitsA compiled template engine built for many rows
Missing dataWhatever the code does with a nullFail-closed checks before generation
A wording or colour changeA developer edits code, updates tests and deploysAn admin edits the template in the builder
AI at generation timeNone, once the code is writtenNone. Generation is deterministic Apex

The last row is the same for both, and it matters. Neither approach puts an AI model in the generation path. The difference is in everything around it.


Where custom Apex gets hard

The first version of a custom generator is rarely the problem. The problems arrive with real data and real change requests.

Governor limits arrive with real data

Synchronous Apex has a 10-second CPU limit and a 6 MB heap limit. Code that builds HTML by string concatenation inside nested loops is fine on a five-line test quote. Then it meets a 500-line bill of materials or a quote with grouped products, and the transaction fails.

Fixing that is real engineering: building the output efficiently, querying once instead of per row, and testing at production volumes. Claude can help with it, but someone has to know it is needed, test for it and keep it fixed as the template changes.

ZeroExport compiles each template once, when it is saved, and merges documents from the compiled form. The compiled templates docs give the measured numbers: an invoice with 400 lines dropped from 1,123 ms to 682 ms of Apex CPU.

The PDF renderer is not a browser

Blob.toPdf() and Visualforce renderAs="pdf" use an older rendering engine with limited CSS support. Layouts that look right in a browser, especially ones using flexbox or grid, come out differently in the PDF. Getting repeated table headers, page breaks and signature blocks right becomes trial and error.

ZeroExport renders on the same Salesforce PDF engine, so it does not add modern CSS support. What it does is handle that engine's CSS 2.1 quirks for you out of the box. Templates are built in the builder, and ZeroExport writes HTML and CSS that the engine renders correctly, including table headers repeated across pages and page breaks. Nobody on your team has to learn the engine's limits by trial and error.

Complex tables are a project of their own

The documents that justify a custom build are rarely flat. A quote grouped by product family, with merged cells and a subtotal per group, and a grand total, is a substantial amount of custom code. It has to handle empty groups, single-row groups and page breaks.

In ZeroExport these are template features: multi-level grouping and subtotals, merged cells, and nested data up to five levels (the primary object plus four levels of child records). Claude configures them instead of writing them.

Every change is a deployment

Legal changes a clause. Marketing changes the brand colour. Sales wants a new column. With custom Apex, each request becomes a developer ticket, a code change, updated tests and a deployment. Admins cannot make the change themselves.

That backlog is what we call DocGen debt. Claude makes each change faster to write, but it does not remove the deployment, the tests or the developer dependency.

Failure modes are yours to design

What should happen when a required field is blank, or a lookup is null? Custom code either throws an exception or prints a document with gaps, unless someone wrote checks for each case. ZeroExport checks required data and the template's schema before generation and stops instead of producing an incomplete document. See document readiness.


What changes with the ZeroExport MCP server

With the MCP server, Claude is still doing the work you would ask of it: reading the requirement, choosing fields and designing the layout. It does that against tools instead of a blank editor:

  1. It reads your org's schema, read-only, so field and relationship names are real.
  2. It writes a ZeroExport template, not code: data sources, layout, visibility rules, totals.
  3. ZeroExport's own validator checks the template in your org, including a dry-run import that is rolled back. Claude fixes every error it reports.
  4. The template is imported as an inactive draft after you confirm, and compiled like any saved template.
  5. You test it on real records and an admin reviews and activates it in the Lightning builder.

After that the template belongs to your admins. The next wording change is an edit in the builder, not a pull request. Claude can also make the change again through the MCP server.

The MCP server has limits too. It cannot change org metadata, so a missing field still needs a separate change. A few things need your input, such as filters and Conga query logic. The MCP architecture page lists them all.


When custom Apex still makes sense

A custom build can be the right call when:

  • the document is one simple, stable layout that rarely changes
  • a developer will own it long term
  • volumes are small and predictable

If that describes your documents, Claude can write that code well. Once you have grouped tables, large line-item counts, regular change requests or more than a handful of templates, you are building and maintaining a document generation product. For the full cost picture, see build vs buy for Salesforce document generation.


FAQ

Can Claude build a Salesforce PDF generator in Apex?

Yes. For a simple document it works. The cost is in what follows: test coverage, deployments, governor limits on large documents, complex tables and every later change.

Is Claude involved when documents are generated with the ZeroExport MCP server?

No. Claude helps build the template. Documents are generated by ZeroExport's deterministic Apex engine inside Salesforce, with no AI model and no external call.

Does the MCP server write Apex into my org?

No. It writes ZeroExport template records through the package's own import. It cannot deploy code or change metadata.

Can I use Claude Code with the ZeroExport MCP server?

Yes. Claude Code, and other MCP clients such as Codex, connect to the server, which runs on your own machine. It is included in the Standard plan from ZeroExport 1.13.


Related Reading

Ready to try ZeroExport?

Start generating documents directly in your Salesforce org. No integrations, no setup overhead, no complexity.