Open a ticket
Chat with us
Click or drag to resize

Viewer Options

TWPdfViewer component has two parameters:

1. IsStatic
2. Options

IsStatic property is only important if render-mode is set to Static.
In that case, that property must be set to "Yes".
For remaining two rendering modes: Server and ServerPrerender that property can be omitted.

Setting properties is done through Options parameter.

Example for RazorPages/MVC:

C#
@using PdfViewer = Terminalworks.PdfViewer.AspNetCore
<component
  type="typeof(PdfViewer.Pages.Shared.TWPdfViewer)"
  render-mode="Static"
  IsStatic="Yes"
  param-Options='@new PdfViewer.Options {
        Bookmark = new PdfViewer.BookmarkOptions {
                ShowBookmarksOnOpen = true,
                BookmarksFullyExpanded = false,    
                PreserveBookmarksState = true
          }
    }
/>

Another way of defining options is in C# part:

C#
using PdfViewer = Terminalworks.PdfViewer.AspNetCore;
var options = new PdfViewer.Options {
  Bookmark = new PdfViewer.BookmarkOptions {
    ShowBookmarksOnOpen = true,
    BookmarksFullyExpanded = false,
    PreserveBookmarksState = true
  }
};

And how to use them in Blazor app:

C#
<TWPdfViewer Options='@options' />

Rest of examples, for brevity, will show only how to change Options in C# code.
How to apply it depends if you are using RazorPages/MVC component (param-Options='@options') or Blazor/WebAssembly (Options='@options')

Copyright © 2024 Terminalworks. All Rights Reserved