Export custom styles to DOC
Available in Start planBetav0.3.0
Consider using DOCX instead
The DOC format is a legacy format from Microsoft Word 97-2003. For modern use, we recommend exporting to DOCX instead. Use DOC only when compatibility with older systems requires it.
When exporting to DOC, you can define custom style overrides that will be applied to the exported document. This is useful when you want to customize the look and feel of your exports beyond the default styling.
Style overrides
The styleOverrides option accepts a Record<string, string> object where keys are style property names and values are the style values. These overrides are sent to the Tiptap convert service and applied during the conversion process.
| Parameter | Type | Description | Default |
|---|---|---|---|
styleOverrides | Record<string, string> | Style overrides to apply to the exported DOC document | undefined |
Example
import { ExportDoc } from '@tiptap-pro/extension-export-doc'
const editor = new Editor({
extensions: [
// Other extensions...
ExportDoc.configure({
token: 'YOUR_TOKEN',
appId: 'YOUR_APP_ID',
styleOverrides: {
'font-family': 'Arial, sans-serif',
'font-size': '12pt',
'line-height': '1.5',
'color': '#333333',
},
}),
// Other extensions...
],
})
// Export with custom styles
editor
.chain()
.exportDoc({
onCompleteExport(result) {
const url = URL.createObjectURL(result)
const a = document.createElement('a')
a.href = url
a.download = 'styled-document.doc'
a.click()
URL.revokeObjectURL(url)
},
})
.run()