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.

csharp
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

TypePropertyDefaultBehavior
intImageResolution00 uses the format default. Valid explicit range is 25-300 DPI; invalid assignments are ignored.
stringDocumentCulture""Locale for dates and numbers. Nonblank values are trimmed; blank assignments are ignored.
stringPassword""Protected-document password. DocOptions.Password is copied here automatically.
boolShowUItrueCompatibility property; the current renderer does not use it to control the browser toolbar.
boolCachePagestrueCache rendered page images for the document session.

PdfConfig

Formats: PDF. Default DPI: 200.

TypePropertyDefaultBehavior
boolDefaultRendertrueCompatibility switch. The current factory uses the native PDF viewer.
boolAllowSearchfalseBuild/use the PDF text-search index. Requires the Search license capability for requests.
boolAllowCopyfalsePermit text-selection/copy operations.
boolExtractHyperlinksfalseExtract link rectangles for client overlays.
intHyperlinksPageCount0Maximum pages scanned for links; 0 means every page.
boolCompressImagesfalseCompress embedded images before rendering.
intCompressQuality100JPEG quality used when compression is enabled.
boolResizeImagesfalseResize embedded images before rendering.
intResizeResolution300Target DPI for resized images.
boolCompressFastfalsePrefer the faster, lower-quality compression path.
boolFixInvalidImagesfalseAttempt to repair invalid embedded images.
boolSplitSegmentsfalseRejoin 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.

TypePropertyDefaultBehavior
boolDefaultRendertrueNative Word render; false uses the PDF redirect.
PdfConfigPdfConfignew instanceSettings used by the PDF/search path.
DocPaperSizePaperSizeA4Output paper size. Use Custom with width/height.
intPaperWidth595Custom width in points.
intPaperHeight841Custom height in points.
boolRemovePaperMarginfalseRemove document page margins.
boolRenderPageColortruePreserve Word's configured page color; false renders white pages.
boolExportPdfAfalseUse archival PDF/A on the PDF path.
Encoding?FileEncodingnullOverride source encoding.
stringFontInfo""Font substitution information.
string[]?FontFoldersnullAdditional font directories, especially useful in Linux/containers.
boolAllowSearchfalseDelegates to PdfConfig.AllowSearch.
boolAllowCopyfalseDelegates to PdfConfig.AllowCopy.
TableAutoFitBehaviorAutoFitAllTablesNoneNone, AutoFitToContents, or AutoFitToWindow.

ExcelConfig

Formats: XLS, XLSX, XLSM, XLSB, XLTX, XLTM, ODS, CSV. Default DPI: 200.

TypePropertyDefaultBehavior
boolDefaultRendertrueNative sheet render; false uses the PDF redirect.
PdfConfigPdfConfignew instanceSettings for the PDF/search path.
ExcelPaperSizePaperSizePaperA4Output paper size.
doublePaperMargins0.25Page margins in inches.
boolPaperLandscapetrueLandscape sheet rendering.
boolAutoFitContentsfalseAuto-fit row heights and column widths.
boolRemoveEmptyContenttrueTighten output by excluding empty content.
boolCalculateFormulatrueRecalculate formulas before rendering.
boolShowRowColumnHeaderstrueInclude spreadsheet headers.
boolExportPdfAfalseUse PDF/A on the PDF path.
boolSplitWorksheetsfalseKeep worksheets as separate page groups.
boolShowEmptyWorkSheetsfalseInclude empty worksheets.
boolExportLandscapefalseForce landscape export.
boolExportOnePagePerSheetfalseFit each worksheet to one output page.
boolMemoryOptimizationPreferencetrueReduce peak memory, potentially trading some speed.
boolAutoTrimWorksheetRenderRangetrueRender only the visible used range when no explicit print area exists.
boolAutoTrimPreserveExistingPrintAreatruePreserve workbook-defined print areas during auto-trim.
string?PrintAreanullExplicit range such as "A1:Z100".
boolPrintGridlinesfalsePrint worksheet gridlines.
boolPrintHeadingsfalsePrint row/column headings.
List<string>SheetNamesemptyRestrict rendering to named worksheets.
CustomStyleCell?CustomStylesnullOptional date/decimal/integer formatting overrides.
boolAllowSearchfalseDelegates to PdfConfig.AllowSearch.
boolAllowCopyfalseDelegates 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.

TypePropertyDefaultBehavior
boolDefaultRendertrueNative slide render; false uses the PDF redirect.
boolFastLoadfalseAvoid rendering the first slide during open; use metadata and render on demand.
PdfConfigPdfConfignew instanceSettings for PDF/search behavior.
stringFontInfo""Font substitution information.
string[]?FontFoldersnullAdditional font directories.
boolAllowSearchfalseDelegates to PdfConfig.AllowSearch.
boolAllowCopyfalseDelegates 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.

TypePropertyDefaultBehavior
boolDefaultRendertrueNative CAD render; false uses the PDF redirect.
PdfConfigPdfConfignew instancePDF-path settings.
boolExportPdfAfalseArchival PDF/A output.
boolShowColortrueColor rather than monochrome.
boolWhiteBackgroundtrueWhite instead of black background.
shortLineWidth25CAD stroke width.
boolShowLayoutsfalseRender layout tabs.
boolShowModeltrueRender model space.
boolCheck3DSolidtrueProcess 3D solids.
boolExportAllLayoutsfalseExport all layouts, overriding model/layout selection.
boolLimitMinimumSizefalseApply MinimumSize.
intMinimumSize700Minimum output size in pixels.
boolLimitMaximumSizefalseApply MaximumSize.
intMaximumSize700Maximum output size in pixels.
boolShowAllLayoutsDgnfalseInclude all DGN layouts.
boolAutomaticLayoutScalingtrueAutomatically scale layouts.
floatPdfMargins0.5PDF margin in inches.
RenderQualityQualityImageLowRaster quality: Low, Medium, or High.
RenderQualityQualityTextMediumText quality: Low, Medium, or High.

EmailConfig

Formats: EML, EMLX, MSG. Default DPI: 200.

TypePropertyDefaultBehavior
boolDefaultRendertrueNative email render; false uses the PDF redirect.
PdfConfigPdfConfignew instancePDF-path settings.
Encoding?EmailEncodingnullOverride message encoding.
Encoding?SubjectEncodingnullOverride subject encoding.
Encoding?BodyEncodingnullOverride body encoding.
boolSkipExternalImagesfalseDo not load remotely referenced images. Recommended for untrusted email.
boolRemoveLastWhitePagefalseRemove a trailing blank page.
boolUseAntiAliasingfalseEnable anti-aliasing.
boolUseHighQualityRenderingfalsePrefer cleaner, slower rendering.
TimeSpan?TimeZoneOffsetnullOverride the timezone used for dates.
boolForcePageSizefalseForce 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.

ConfigPropertyDefaultBehavior
ImageConfigMaxImagePixelSize3000Maximum width/height. 0 means unlimited; nonzero values below 50 are ignored.
ImageConfigTransparentPngtruePreserve PNG transparency; false uses a white background.
TiffConfigno additional propertiesDPI 200Uses only BaseConfig; supports multi-page TIFF.
PsdConfigMaxImagePixelSize3000Same 0/minimum-50 validation as ImageConfig; default DPI is 100.

DicomConfig

Formats: DCM, IMA. Default effective DPI: 100. Requires the DICOM plugin.

TypePropertyDefaultBehavior
intHorizontalResolution100 effectiveExplicit horizontal DPI; otherwise ImageResolution, then 100.
intVerticalResolution100 effectiveExplicit vertical DPI; otherwise ImageResolution, then 100.
intAnimationFrameDelayMs100Multiframe animation delay; GIF timing uses 10 ms units.
ushortLoopCount00 loops forever; positive values stop after that count.
DicomDisplayModeDisplayModeAnimationAndFramesAnimationOnly, FramesOnly, or combined overview plus static frames.

TxtConfig

Format: TXT. Default DPI: 200.

TypePropertyDefaultBehavior
DocPaperSizePaperSizeA4Output paper size.
Encoding?FileEncodingnullnull uses UTF-8.
stringFontInformation""Font information for text rendering.

Use WordConfig when plain text needs richer page-layout behavior.

ProjectConfig

Formats: MPP, MPPX, MPX. Default DPI: 200.

TypePropertyDefaultBehavior
boolDefaultRendertrueNative Gantt image; false uses a text-based PDF path.
PdfConfigPdfConfignew instancePDF-path settings.
boolExportPdfAtrueArchival PDF/A output.
MppPaperSizePaperSizeLedgerProject output paper size.
MppTimeScaleTimeScaleMonthsDays or Months.
MppFormatPresentationFormatGanttChartGanttChart, 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.

TypePropertyDefaultBehavior
boolDefaultRendertrueNative diagram render; false uses the PDF redirect.
PdfConfigPdfConfignew instancePDF-path settings.
boolExportPdfAtrueArchival PDF/A output.

HtmlConfig, EpubConfig, MhtConfig, and XpsConfig

All four default to 200 DPI and expose a nested PdfConfig.

ConfigFormatsDefaultRenderAdditional properties/behavior
HtmlConfigHTML, HTMtrueNative render; use false for a text-based PDF search path.
EpubConfigEPUBtrueNative render; false uses PDF.
MhtConfigMHT, MHTMLtrue on the class; false in the automatic catalogThe normal no-config open uses the searchable PDF redirect. An explicitly constructed default instance renders natively.
XpsConfigXPSfalseUses the PDF path by default; set true for native image rendering.

Configuration examples by family

csharp
BaseConfig[] configs =
{
    new PdfConfig
    {
        AllowSearch = true,
        ExtractHyperlinks = true,
        HyperlinksPageCount = 0
    },
    new WordConfig
    {
        PaperSize = DocPaperSize.A4,
        RemovePaperMargin = false,
        FontFolders = new[] { "/usr/share/fonts/truetype" },
        AllowSearch = true
    },
    new ExcelConfig
    {
        PaperLandscape = true,
        AutoFitContents = true,
        CalculateFormula = true,
        SplitWorksheets = false,
        PrintGridlines = false
    },
    new PptConfig
    {
        FastLoad = true,
        FontFolders = new[] { "/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

csharp
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?