expressappframework-405489-document-management-office-module-access-and-customize-pdf-viewer-controls.md
The PDF Viewer Property Editor uses the following components internally: DxPdfViewer (Blazor) or PdfViewer (WinForms). This topic describes how to access and customize these components in XAF applications.
This approach follows the standard method for accessing and customizing a property editor with the CustomizeViewItemControl event, as described in the following guide: Access the Settings of a Property Editor in a Detail View.
PdfViewerPropertyEditor in the OnActivated method handler.ComponentModel (Blazor) or Control (WinForms) property to access the underlying component settings.using DevExpress.Blazor.Reporting.Models;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Blazor.Editors;
using Microsoft.AspNetCore.Components;
public class BlazorPdfViewerController : ViewController<DetailView> {
protected override void OnActivated() {
base.OnActivated();
View.CustomizeViewItemControl<PdfViewerPropertyEditor>(this, editor => {
editor.ComponentModel.ZoomLevel = 0.7;
editor.ComponentModel.CustomizeToolbar =
EventCallback.Factory.Create<ToolbarModel>(this, toolbar => toolbar.AllItems.Clear());
});
}
}
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Win;
namespace MainDemo.Win.Controllers;
public class WinPdfViewerController : ViewController<DetailView> {
protected override void OnActivated() {
base.OnActivated();
View.CustomizeViewItemControl<PdfViewerPropertyEditor>(this, editor => {
editor.Control.ZoomFactor = 70f;
editor.Control.NavigationPaneInitialVisibility =
DevExpress.XtraPdfViewer.PdfNavigationPaneVisibility.Hidden;
});
}
}
PDF Viewer in an XAF Blazor app
PDF Viewer in an XAF WinForms app
The WinForms PDF Viewer can display its menu as a Ribbon or Toolbar. Use the MenuManagerType property to specify the menu type or hide the menu.
PDF Viewer ribbon menu merged into the main form’s ribbon (MenuManagerType = Default and FormStyle = Ribbon)
Separate toolbar menu in PDF Viewer (MenuManagerType = Bars)
No menu in PDF Viewer (MenuManagerType = None)
The WinForms PDF Viewer menu can display the following toolbar groups/ribbon tabs, listed in the PdfViewerToolbarKind enumeration:
You can use the static PdfViewerPropertyEditor.DefaultPdfViewerToolbarKind property to list toolbars/tabs for display. The default property value is All, and the PDF Viewer displays every available toolbar.
using DevExpress.ExpressApp.Office.Win;
// ...
public class Program {
public static void Main(string[] arguments) {
PdfViewerPropertyEditor.DefaultPdfViewerToolbarKind = PdfViewerToolbarKind.Comment;
// Use the vertical bar (|) to list several toolbars/tabs
// PdfViewerPropertyEditor.DefaultPdfViewerToolbarKind = PdfViewerToolbarKind.Comment | PdfViewerToolbarKind.Main;
// ...
}
// ...
}
You can also use the Toolbar Customization menu at runtime. The result is saved to the user’s model differences.