Format Configs
Complete per-format rendering options
Every document opens with a BaseConfig implementation. Pass one to OpenDocumentAsync or let the format catalog create its default. All classes below live in the Doconut namespace.
var token = await viewer.OpenDocumentAsync(path, new PdfConfig
{
AllowSearch = true,
AllowCopy = true,
ImageResolution = 150
});Inheritance and nested PDF settings
Every format inherits the five BaseConfig properties. Formats that can redirect through PDF expose a nested PdfConfig. In WordConfig, ExcelConfig, and PptConfig, AllowSearch and AllowCopy are convenience properties that read and write the nested PdfConfig.
DefaultRender = true selects the native format renderer. On formats with a PDF redirect, false converts to an in-memory PDF first and then uses the PDF viewer. That path is often useful for text-coordinate search, but costs an extra conversion.
Unless stated otherwise, the tables show constructor/property defaults. The automatic format catalog deliberately overrides two of them: it creates ExcelConfig with SplitWorksheets = true, and MhtConfig with DefaultRender = false.
BaseConfig
| Type | Property | Default | Behavior |
|---|---|---|---|
int | ImageResolution | 0 | 0 uses the format default. Valid explicit range is 25-300 DPI; invalid assignments are ignored. |
string | DocumentCulture | "" | Locale for dates and numbers. Nonblank values are trimmed; blank assignments are ignored. |
string | Password | "" | Protected-document password. DocOptions.Password is copied here automatically. |
bool | ShowUI | true | Compatibility property; the current renderer does not use it to control the browser toolbar. |
bool | CachePages | true | Cache rendered page images for the document session. |
PdfConfig
Formats: PDF. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Compatibility switch. The current factory uses the native PDF viewer. |
bool | AllowSearch | false | Build/use the PDF text-search index. Requires the Search license capability for requests. |
bool | AllowCopy | false | Permit text-selection/copy operations. |
bool | ExtractHyperlinks | false | Extract link rectangles for client overlays. |
int | HyperlinksPageCount | 0 | Maximum pages scanned for links; 0 means every page. |
bool | CompressImages | false | Compress embedded images before rendering. |
int | CompressQuality | 100 | JPEG quality used when compression is enabled. |
bool | ResizeImages | false | Resize embedded images before rendering. |
int | ResizeResolution | 300 | Target DPI for resized images. |
bool | CompressFast | false | Prefer the faster, lower-quality compression path. |
bool | FixInvalidImages | false | Attempt to repair invalid embedded images. |
bool | SplitSegments | false | Rejoin words split across line segments to improve search/copy. |
showHyperlinks in ViewerConfig controls the client overlay, while ExtractHyperlinks controls server extraction. Enable both.
WordConfig
Formats: DOC, DOCX, DOCM, DOT, DOTX, DOTM, RTF, ODT, OTT, XML. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Native Word render; false uses the PDF redirect. |
PdfConfig | PdfConfig | new instance | Settings used by the PDF/search path. |
DocPaperSize | PaperSize | A4 | Output paper size. Use Custom with width/height. |
int | PaperWidth | 595 | Custom width in points. |
int | PaperHeight | 841 | Custom height in points. |
bool | RemovePaperMargin | false | Remove document page margins. |
bool | RenderPageColor | true | Preserve Word's configured page color; false renders white pages. |
bool | ExportPdfA | false | Use archival PDF/A on the PDF path. |
Encoding? | FileEncoding | null | Override source encoding. |
string | FontInfo | "" | Font substitution information. |
string[]? | FontFolders | null | Additional font directories, especially useful in Linux/containers. |
bool | AllowSearch | false | Delegates to PdfConfig.AllowSearch. |
bool | AllowCopy | false | Delegates to PdfConfig.AllowCopy. |
TableAutoFitBehavior | AutoFitAllTables | None | None, AutoFitToContents, or AutoFitToWindow. |
ExcelConfig
Formats: XLS, XLSX, XLSM, XLSB, XLTX, XLTM, ODS, CSV. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Native sheet render; false uses the PDF redirect. |
PdfConfig | PdfConfig | new instance | Settings for the PDF/search path. |
ExcelPaperSize | PaperSize | PaperA4 | Output paper size. |
double | PaperMargins | 0.25 | Page margins in inches. |
bool | PaperLandscape | true | Landscape sheet rendering. |
bool | AutoFitContents | false | Auto-fit row heights and column widths. |
bool | RemoveEmptyContent | true | Tighten output by excluding empty content. |
bool | CalculateFormula | true | Recalculate formulas before rendering. |
bool | ShowRowColumnHeaders | true | Include spreadsheet headers. |
bool | ExportPdfA | false | Use PDF/A on the PDF path. |
bool | SplitWorksheets | false | Keep worksheets as separate page groups. |
bool | ShowEmptyWorkSheets | false | Include empty worksheets. |
bool | ExportLandscape | false | Force landscape export. |
bool | ExportOnePagePerSheet | false | Fit each worksheet to one output page. |
bool | MemoryOptimizationPreference | true | Reduce peak memory, potentially trading some speed. |
bool | AutoTrimWorksheetRenderRange | true | Render only the visible used range when no explicit print area exists. |
bool | AutoTrimPreserveExistingPrintArea | true | Preserve workbook-defined print areas during auto-trim. |
string? | PrintArea | null | Explicit range such as "A1:Z100". |
bool | PrintGridlines | false | Print worksheet gridlines. |
bool | PrintHeadings | false | Print row/column headings. |
List<string> | SheetNames | empty | Restrict rendering to named worksheets. |
CustomStyleCell? | CustomStyles | null | Optional date/decimal/integer formatting overrides. |
bool | AllowSearch | false | Delegates to PdfConfig.AllowSearch. |
bool | AllowCopy | false | Delegates to PdfConfig.AllowCopy. |
CustomStyleCell exposes CustomStyleDateTime, CustomStyleNumberDecimal, and CustomStyleNumberInteger, all nullable strings.
new ExcelConfig() sets SplitWorksheets to false; opening an Excel file without an explicit config uses the format catalog, which sets it to true.
PptConfig
Formats: PPT, PPTX, PPTM, PPSX, PPSM, POT, POTX, POTM, ODP. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Native slide render; false uses the PDF redirect. |
bool | FastLoad | false | Avoid rendering the first slide during open; use metadata and render on demand. |
PdfConfig | PdfConfig | new instance | Settings for PDF/search behavior. |
string | FontInfo | "" | Font substitution information. |
string[]? | FontFolders | null | Additional font directories. |
bool | AllowSearch | false | Delegates to PdfConfig.AllowSearch. |
bool | AllowCopy | false | Delegates to PdfConfig.AllowCopy. |
On Linux and macOS, presentation rendering with the current engine requires libgdiplus and System.Drawing.EnableUnixSupport=true. Install the fonts used by the presentation or provide FontFolders.
CadConfig
Formats: DWG, DXF, DGN. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Native CAD render; false uses the PDF redirect. |
PdfConfig | PdfConfig | new instance | PDF-path settings. |
bool | ExportPdfA | false | Archival PDF/A output. |
bool | ShowColor | true | Color rather than monochrome. |
bool | WhiteBackground | true | White instead of black background. |
short | LineWidth | 25 | CAD stroke width. |
bool | ShowLayouts | false | Render layout tabs. |
bool | ShowModel | true | Render model space. |
bool | Check3DSolid | true | Process 3D solids. |
bool | ExportAllLayouts | false | Export all layouts, overriding model/layout selection. |
bool | LimitMinimumSize | false | Apply MinimumSize. |
int | MinimumSize | 700 | Minimum output size in pixels. |
bool | LimitMaximumSize | false | Apply MaximumSize. |
int | MaximumSize | 700 | Maximum output size in pixels. |
bool | ShowAllLayoutsDgn | false | Include all DGN layouts. |
bool | AutomaticLayoutScaling | true | Automatically scale layouts. |
float | PdfMargins | 0.5 | PDF margin in inches. |
RenderQuality | QualityImage | Low | Raster quality: Low, Medium, or High. |
RenderQuality | QualityText | Medium | Text quality: Low, Medium, or High. |
EmailConfig
Formats: EML, EMLX, MSG. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Native email render; false uses the PDF redirect. |
PdfConfig | PdfConfig | new instance | PDF-path settings. |
Encoding? | EmailEncoding | null | Override message encoding. |
Encoding? | SubjectEncoding | null | Override subject encoding. |
Encoding? | BodyEncoding | null | Override body encoding. |
bool | SkipExternalImages | false | Do not load remotely referenced images. Recommended for untrusted email. |
bool | RemoveLastWhitePage | false | Remove a trailing blank page. |
bool | UseAntiAliasing | false | Enable anti-aliasing. |
bool | UseHighQualityRendering | false | Prefer cleaner, slower rendering. |
TimeSpan? | TimeZoneOffset | null | Override the timezone used for dates. |
bool | ForcePageSize | false | Force fixed page dimensions. |
ImageConfig, TiffConfig, and PsdConfig
ImageConfig covers JPG, JPEG, JPE, PNG, BMP, GIF, ICO, EPS, TGA, WEBP, CDR, CMX, DNG, EMF, WMF, AVIF, and SVG. Its default DPI is 100.
| Config | Property | Default | Behavior |
|---|---|---|---|
ImageConfig | MaxImagePixelSize | 3000 | Maximum width/height. 0 means unlimited; nonzero values below 50 are ignored. |
ImageConfig | TransparentPng | true | Preserve PNG transparency; false uses a white background. |
TiffConfig | no additional properties | DPI 200 | Uses only BaseConfig; supports multi-page TIFF. |
PsdConfig | MaxImagePixelSize | 3000 | Same 0/minimum-50 validation as ImageConfig; default DPI is 100. |
DicomConfig
Formats: DCM, IMA. Default effective DPI: 100. Requires the DICOM plugin.
| Type | Property | Default | Behavior |
|---|---|---|---|
int | HorizontalResolution | 100 effective | Explicit horizontal DPI; otherwise ImageResolution, then 100. |
int | VerticalResolution | 100 effective | Explicit vertical DPI; otherwise ImageResolution, then 100. |
int | AnimationFrameDelayMs | 100 | Multiframe animation delay; GIF timing uses 10 ms units. |
ushort | LoopCount | 0 | 0 loops forever; positive values stop after that count. |
DicomDisplayMode | DisplayMode | AnimationAndFrames | AnimationOnly, FramesOnly, or combined overview plus static frames. |
TxtConfig
Format: TXT. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
DocPaperSize | PaperSize | A4 | Output paper size. |
Encoding? | FileEncoding | null | null uses UTF-8. |
string | FontInformation | "" | Font information for text rendering. |
Use WordConfig when plain text needs richer page-layout behavior.
ProjectConfig
Formats: MPP, MPPX, MPX. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Native Gantt image; false uses a text-based PDF path. |
PdfConfig | PdfConfig | new instance | PDF-path settings. |
bool | ExportPdfA | true | Archival PDF/A output. |
MppPaperSize | PaperSize | Ledger | Project output paper size. |
MppTimeScale | TimeScale | Months | Days or Months. |
MppFormat | PresentationFormat | GanttChart | GanttChart, TaskUsage, ResourceUsage, ResourceSheet, or TaskSheet. |
For exact text-coordinate search, use DefaultRender = false.
VisioConfig
Formats: VSD, VSDX, VSS, VSSX, VST, VSTX, VDX, VSX, VSDM. Default DPI: 200.
| Type | Property | Default | Behavior |
|---|---|---|---|
bool | DefaultRender | true | Native diagram render; false uses the PDF redirect. |
PdfConfig | PdfConfig | new instance | PDF-path settings. |
bool | ExportPdfA | true | Archival PDF/A output. |
HtmlConfig, EpubConfig, MhtConfig, and XpsConfig
All four default to 200 DPI and expose a nested PdfConfig.
| Config | Formats | DefaultRender | Additional properties/behavior |
|---|---|---|---|
HtmlConfig | HTML, HTM | true | Native render; use false for a text-based PDF search path. |
EpubConfig | EPUB | true | Native render; false uses PDF. |
MhtConfig | MHT, MHTML | true on the class; false in the automatic catalog | The normal no-config open uses the searchable PDF redirect. An explicitly constructed default instance renders natively. |
XpsConfig | XPS | false | Uses the PDF path by default; set true for native image rendering. |
Configuration examples by family
BaseConfig[] configs =
[
new PdfConfig
{
AllowSearch = true,
ExtractHyperlinks = true,
HyperlinksPageCount = 0
},
new WordConfig
{
PaperSize = DocPaperSize.A4,
RemovePaperMargin = false,
FontFolders = ["/usr/share/fonts/truetype"],
AllowSearch = true
},
new ExcelConfig
{
PaperLandscape = true,
AutoFitContents = true,
CalculateFormula = true,
SplitWorksheets = false,
PrintGridlines = false
},
new PptConfig
{
FastLoad = true,
FontFolders = ["/usr/share/fonts/truetype"],
AllowSearch = true
},
new CadConfig
{
ShowColor = true,
WhiteBackground = true,
ShowModel = true,
ShowLayouts = false,
QualityText = CadConfig.RenderQuality.High
},
new EmailConfig
{
SkipExternalImages = true,
RemoveLastWhitePage = true,
TimeZoneOffset = TimeSpan.Zero
},
new ImageConfig
{
MaxImagePixelSize = 3000,
TransparentPng = true
},
new DicomConfig
{
DisplayMode = DicomDisplayMode.AnimationAndFrames,
AnimationFrameDelayMs = 100,
LoopCount = 0
}
];Per-extension selection
static BaseConfig? ConfigForExtension(string extUpper) => extUpper switch
{
".DOC" or ".DOCX" or ".DOT" or ".DOTX" or ".ODT" => new WordConfig
{
AutoFitAllTables = WordConfig.TableAutoFitBehavior.AutoFitToWindow,
PaperSize = DocPaperSize.Tabloid,
PdfConfig = new PdfConfig { ExtractHyperlinks = true, HyperlinksPageCount = 5, AllowCopy = true }
},
".PDF" => new PdfConfig { AllowSearch = true, AllowCopy = true },
".XLS" or ".XLSX" or ".ODS" or ".CSV" => new ExcelConfig { AllowSearch = true, AllowCopy = true },
".DCM" or ".IMA" => new DicomConfig { DisplayMode = DicomDisplayMode.AnimationAndFrames },
// DefaultRender = false → PDF redirect → pixel-accurate native text search
".HTML" or ".HTM" => new HtmlConfig { DefaultRender = false },
".EML" or ".EMLX" or ".MSG" => new EmailConfig { DefaultRender = false },
_ => null // fall back to the format's default config
};Was this page helpful?