ViewerConfig

Client viewer widget options

ViewerConfig (namespace Doconut) describes the browser viewer's appearance and behavior. It does not affect document rendering quality; use a format config for that. The C# class and the legacy JavaScript plugin have different defaults, so map values explicitly.

C# properties

TypePropertyDefaultDescription
boolShowThumbstrueShow the thumbnail panel.
boolAutoLoadfalseAutomatically load after initialization. The normal token flow calls View(token) explicitly.
boolAutoFocustrueMove browser focus/scroll to the viewer during initialization.
boolAutoPageFocustrueKeep the current thumbnail visible while pages change.
intPageZoom100Initial zoom percentage.
intZoomStep10Percentage added or removed by zoom commands.
intMaxZoom300Maximum zoom percentage.
boolShowToolTiptrueShow the page-position tooltip while scrolling.
stringToolTipPageText"Page "Prefix used in the page tooltip.
boolCacheEnabledfalseRetain a moving window of page images in browser memory. It does not use localStorage.
boolLargeDocfalseAppend page elements in timed batches for large documents.
boolShowHyperlinksfalseRender hyperlink overlays when the server config extracted them.
boolFixedZoomtrueUse a fixed zoom percentage rather than responsive recalculation.
intFixedZoomPercent100Fixed desktop zoom.
intFixedZoomPercentMobile75Fixed mobile zoom.
stringBasePath"/"Where the viewer sends page requests. "/" is the DocImage.axd handler at the site root. For an application in a virtual directory, use the directory name without a leading / ("myapp" means /myapp/DocImage.axd).
stringResPath"doconut-res/images"Folder the widget loads its own images from: the images folder under ResourcesPath, without a leading /.
stringFitType"width""width", "height", or empty for no automatic fit. "page" is not accepted by the current widget.
boolRetryOn409falseRetries page requests that answer "still rendering". DocImage.axd renders synchronously and never sends that signal; leave it false.
csharp
var config = new ViewerConfig
{
    ShowThumbs = true,
    AutoLoad = false,
    PageZoom = 100,
    MaxZoom = 300,
    FitType = "width",
    BasePath = "/",                 // "/" = the DocImage.axd handler at the site root (Web.config)
    ResPath = "doconut-res/images", // the images folder under ResourcesPath, no leading '/'
    ShowHyperlinks = true
};
// Emit it with viewer.RenderViewer("viewerEl", token, config) - see the Viewer reference.

Emitting a ViewerConfig with RenderViewer

Viewer.RenderViewer(elementId, token, config) turns a ViewerConfig into the widget's initialisation script. It writes six of the properties above — BasePath, ResPath, ShowThumbs, AutoLoad, PageZoom, and FitType — and then calls View(token). The other properties are not written: for MaxZoom, ShowHyperlinks, the zoom settings, or any callback, initialise the widget yourself with the JavaScript options below. See Viewer for RenderViewer.

C# to JavaScript mapping

Do not pass a directly serialized ViewerConfig to docViewer(...). Most widget keys are camelCase, while three established path/fit keys are PascalCase.

C#JavaScript
ShowThumbsshowThumbs
AutoLoadautoLoad
AutoFocusautoFocus
AutoPageFocusautoPageFocus
PageZoompageZoom
ZoomStepzoomStep
MaxZoommaxZoom
ShowToolTipshowToolTip
ToolTipPageTexttoolTipPageText
CacheEnabledcacheEnabled
LargeDoclargeDoc
ShowHyperlinksshowHyperlinks
FixedZoomfixedZoom
FixedZoomPercentfixedZoomPercent
FixedZoomPercentMobilefixedZoomPercentMobile
BasePathBasePath
ResPathResPath
FitTypeFitType
RetryOn409retryOn409

JavaScript defaults

The widget has older defaults that differ from the C# class. The following values come from the current docViewer.js implementation.

OptionDefaultNotes
leftMinWidth / leftMaxWidth220 / 800Thumbnail pane width bounds.
showThumbstrueInitial thumbnail visibility.
autoFocus / autoPageFocustrue / falseautoPageFocus differs from the C# default.
thumbWidth / thumbHeight / thumbPadding150 / 200 / 10Thumbnail geometry in pixels.
pageZoom / zoomStep / maxZoom100 / 10 / 200JavaScript maxZoom differs from C# (300).
showToolTip / toolTipPageTexttrue / "Page "Page-position tooltip.
format / doc / AccessToken"" / 0 / ""Internal initialization values; normally populated by View(token).
debugModefalseAdditional client diagnostics.
FitType""No automatic fit unless supplied.
BasePath"DocImage.axd"Legacy default. Set it explicitly: '/' for the handler at the site root.
ResPath""Set explicitly to the embedded images path.
cacheEnabled / cacheCount / cacheDelayfalse / 3 / 3In-memory page preloading window and delay.
autoLoadfalseExplicit token flow is recommended.
largeDoctrueDiffers from the C# default.
fixedZoomfalseDiffers from the C# default.
fixedZoomPercent / fixedZoomPercentMobile100 / 50Mobile value differs from C# (75).
showHyperlinkstrueRequires server-side extraction to produce overlays.

Set all behaviorally important values instead of relying on either set of defaults:

html
<div id="divDocViewer"><div id="div_ctlDoc"></div></div>

<script>
const objViewer = $('#div_ctlDoc').docViewer({
    showThumbs: true,
    autoLoad: false,
    autoFocus: true,
    autoPageFocus: true,
    pageZoom: 100,
    zoomStep: 10,
    maxZoom: 300,
    FitType: 'width',
    cacheEnabled: false,
    largeDoc: false,
    showHyperlinks: true,
    fixedZoom: true,
    fixedZoomPercent: 100,
    fixedZoomPercentMobile: 75,
    BasePath: '/',
    ResPath: 'doconut-res/images',
    onViewerReady: function () {},
    onError: function (message) { console.error('DocViewer:', message); }
});
</script>

Callbacks

CallbackArgumentsPurpose
onPageLoadingpageNumA page request is starting.
onPageLoadedpageNumA page image finished loading.
onThumbnailClickedpageNumThe user selected a thumbnail.
onPageClickedpageNumThe user selected a page.
onDoubleClicknoneThe viewer received a double-click.
onViewerBusynoneThe viewer entered a busy state.
onViewerReadynoneInitialization completed.
onViewerErrornoneThe viewer entered its error state.
onErrormessageAn operation returned an error message.
onCopydataText-copy data is available.
onAutoLoadStatuspageNumAuto-loading progressed to a page.
onThumbsShownnoneThe thumbnail panel became visible.
onAnnLoadednoneAnnotation data loaded.
onAnnSavednoneAnnotation data saved.
onAnnSaveErrornoneAnnotation saving failed.
onAnnClosednoneAnnotation UI closed.

Keep callbacks fast; send telemetry asynchronously and do not block page rendering.

Public method groups

GroupCommon methods
LifecycleView(token, accessToken?), Close(server?), Token(), Init(), IsLoaded()
NavigationGotoPage(page), ShowPage(page, focus?), Next(next), CurrentPage(), TotalPages()
Zoom and fitZoom(zoomIn), CurrentZoom(), FitType(value), Refit()
OrientationRotate(page, angle), Flip(page, flipType)
ThumbnailsHideThumbs(hide), ThumbSize(size), ReloadThumbs(width), ScrollToThumb(thumb)
SearchCanSearch(), Search(...), SearchMatchCount(), SearchSummary(...), GotoSearchMatch(...)
AnnotationSaveAnnotations(), GetAnnotations(), PushAnnotations(...), CloseAnnotations(...), ShowAnnotations(...)
CopyCopy(...), CopyPage(pageNumber), CopyMode(enabled)

The JavaScript file contains internal helpers too. Treat only methods used by the reference UI and documented here or in the feature guides as stable integration points.

Retry options

The widget also accepts retryOn409 and its backoff settings (retryInitialDelayMs, retryBackoffFactor, retryMaxDelayMs, retryMaxAttempts, retryMaxTotalMs). They serve deployments whose pages are produced in the background. DocImage.axd renders every page during the request, so leave retryOn409 off.

Path checklist

  • BasePath is '/' when the DocImage.axd handler is at the site root — the path attribute of the handler in Web.config decides where it answers. In a virtual directory, use the directory name without a leading / ('myapp', not '/myapp': the viewer adds the slash, and //myapp/... is a request to another host).
  • DoconutOptions.ResourcesPath is where the resource module serves the embedded files (/doconut-res by default).
  • ResPath targets its images subfolder, also without a leading / ('doconut-res/images'). Pointing it at 'doconut-res' makes every icon 404 while the document still renders.
  • In MVC, routes.IgnoreRoute("doconut-res/{*pathInfo}") must follow ResourcesPath if you change it.
  • ExtractHyperlinks must be enabled in the server format config before showHyperlinks can display anything.

Var den här sidan hjälpsam?