For the complete documentation index, see llms.txt. This page is also available as Markdown.

Classic .doc Generation (DOC/DOC-NEW)

Use legacy DOC and DOC-NEW formats, understand preview behavior, fix common RTF issues, and add page numbers.

Use this page when you maintain legacy DOC or DOC-NEW templates.

These formats generate Word-compatible output from HTML-based template content.

They are not true binary .doc files.

Choose Microsoft Word (DOCX) when you need true .docx output and Word-native template design.

How classic DOC generation works

DOC and DOC-NEW are legacy Word-compatible formats.

They render from the HTML created in the template editor.

That lets S-Docs turn template markup directly into a file Microsoft Word can open.

In practice, the generated file is Word-compatible rather than a true DOC binary.

That is why Word usually opens the file without issue, even when Salesforce preview behavior is inconsistent.

Preview behavior for DOC-NEW files

Salesforce file preview does not reliably render DOC-NEW output.

It can display the file encoding or underlying source instead of the expected document.

This happens because Salesforce does not properly preview the MHT-style structure used for these files.

1

Get the latest content version ID

Use ContentDocument.LatestPublishedVersionId for the generated file.

2

Build the download path

Append /sfc/servlet.shepherd/version/download/ to your Salesforce domain.

3

Add the content version ID

Place the version ID at the end of the path.

The final URL downloads the file directly instead of opening preview.

Example pattern:

You can use the same pattern with a my.salesforce.com domain if needed.

RTF fields in DOC-NEW

DOC-NEW can remove the next two characters after an equals sign inside an RTF field.

This can affect normal text and URLs.

Example:

  • Input: something = something

  • Output: something =omething

Use this replacement to avoid the issue:

Apply that fix in the affected RTF field.

Add page numbers to DOC or DOC-NEW

To add page numbers like Page 1 of 3, place this markup in the template footer:

Microsoft Word resolves those field codes when the file opens.

Key considerations

Keep these legacy format rules in mind:

  • DOC and DOC-NEW are HTML-based Word-compatible outputs

  • Salesforce preview may not render DOC-NEW correctly

  • direct download is the safest delivery pattern for DOC-NEW

  • some legacy RTF patterns need workarounds

  • page numbering works through Word field-code markup

When to use DOCX instead

Use Microsoft Word (DOCX) for new Word-based implementations when you need:

  • true .docx output

  • Word-native layout and styling

  • clearer long-term support patterns

  • fewer preview and legacy format edge cases

Last updated

Was this helpful?