Back to Devexpress

Use PDF Documents in Business Objects

expressappframework-405488-document-management-office-module-use-pdf-documents-in-business-objects.md

latest3.3 KB
Original Source

Use PDF Documents in Business Objects

  • Oct 23, 2025
  • 2 minutes to read

Blazor and WinForms XAF applications allow you to display PDF documents in a PDF Viewer property editor. The editor can display PDF documents stored in properties of the following types:

  • Byte array
  • Types that implement the IFileData interface

Note

WinForms PDF Viewer saves documents in database as IFileData or byte[].

Tip

Try out the PDF Viewer in the MainDemo.NET.EFCore demo application installed as part of the XAF package. The default application location is %PUBLIC%\Documents\DevExpress Demos 25.2\Components\XAF\MainDemo.NET.EFCore.

You can add the PDF Viewer to your application as follows:

  1. Enable the Office Module.
  2. Assign PdfViewerPropertyEditor to a file data property in code or in the Model Editor (MySolution.Blazor.Server\Model.xafml (for Blazor) or MySolution.Win\Model.xafml (for WinForms)).

Assign the PDF Viewer Property Editor to a Property in Code

Decorate a business class property with the EditorAliasAttribute and pass the PdfViewerPropertyEditor value as the attribute parameter:

csharp
using DevExpress.ExpressApp.Editors;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
// ...
[EditorAlias(EditorAliases.PdfViewerPropertyEditor)] 
public virtual byte[] Data { get; set; }
csharp
using DevExpress.ExpressApp.Editors;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
// ...
private byte[] data;
[EditorAlias(EditorAliases.PdfViewerPropertyEditor)] 
public byte[] Data { 
    get { return data; }
    set { SetPropertyValue(nameof(Data), ref data, value); }
}

Assign the PDF Viewer Property Editor to a Property in the Model Editor

  1. Double-click the corresponding Model.xafml file to start the Model Editor:
  • MySolution.Blazor.Server\Model.xafml (for Blazor)
  • MySolution.Win\Model.xafml (for WinForms)
  1. Navigate to the following node: Views | {AppName}.Module.BusinessObjects | {ObjectType} | {ObjectType}_DetailView | Items | {Property Name}.
  2. Set the PropertyEditorType property to one of the following values:

Display the Document in a Separate Window (WinForms)

In WinForms applications, you select the Show in popup context menu command to open the document in a new popup window.