←Select platform

PreferredItemType Property

Summary

The preferred mode to use when viewing the image data of the pages.

Syntax
C#
VB
C++
public virtual DocumentViewerItemType PreferredItemType { get; set; } 
Public Overridable Property PreferredItemType() As DocumentViewerItemType 
   Get 
   Set 
public:  
   virtual property DocumentViewerItemType^ PreferredItemType 
   { 
      DocumentViewerItemType^ get() 
      void set(DocumentViewerItemType^ value) 
   } 

Property Value

The preferred mode to use when viewing the image of a page. Default value is DocumentViewerItemType.Image.

Remarks

ImageViewer supports using RasterImage or SvgDocument images.

When DocumentViewerItemType.Image is set, the document viewer will use DocumentPage.GetImage to get the image data of a page and use it for viewing. This is supported by all document types.

When DocumentViewerItemType.Svg is set, the document viewer will check IsSvgViewingPreferred the property of the current LEADDocument set. If SVG is supported, then it use use DocumentPage.GetSvg to get the SVG data of a page and use it for viewing. This is supported by all document formats but not by most raster file formats.

Use PreferredItemType property to set the preferred mode to use. In other words, when you set it as DocumentViewerItemType.Image, then raster images will always be used. If you set it to DocumentViewerItemType.Svg, then SVG documents is used if supported, otherwise, use raster images.

The ItemType property returns the actual value being used currently based on the document type.

Example

Start with the example created in DocumentViewer, remove all the code in the Example function and add the code below.

When the user clicks the Example button, we will switch between SVG and Image viewing showing information on what happened.

C#
VB
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Document; 
using Leadtools.Document.Viewer; 
using Leadtools.Codecs; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
 
 
// Switch between SVG and Raster image viewer 
var view = _documentViewer.View; 
if (view.PreferredItemType == DocumentViewerItemType.Svg) 
   view.PreferredItemType = DocumentViewerItemType.Image; 
else 
   view.PreferredItemType = DocumentViewerItemType.Svg; 
 
// When we ste the preferred, ItemType gets updated accordingly with 
// the actual value supported by the document format 
// Formats such as PDF and DOCX support both 
// Formats such as TIF and JPEG support only raster 
var message = string.Format("We prefer {0} and it is currently {1} - document MIME type is {2}", 
   view.PreferredItemType, 
   view.ItemType, 
   _documentViewer.Document.MimeType); 
Console.WriteLine(message); 
Imports Leadtools 
Imports Leadtools.Controls 
Imports Leadtools.Document 
Imports Leadtools.Document.Viewer 
Imports Leadtools.Codecs 
Imports Leadtools.Caching 
Imports Leadtools.Annotations.Engine 
Imports Leadtools.Ocr 
 
' Switch between SVG and Raster image viewer 
Dim view As DocumentViewerView = _documentViewer.View 
If view.PreferredItemType = DocumentViewerItemType.Svg Then 
   view.PreferredItemType = DocumentViewerItemType.Image 
Else 
   view.PreferredItemType = DocumentViewerItemType.Svg 
End If 
 
' When we ste the preferred, ItemType gets updated accordingly with 
' the actual value supported by the document format 
' Formats such as PDF and DOCX support both 
' Formats such as TIF and JPEG support only raster 
Dim message As String = String.Format("We prefer {0} and it is currently {1} - document MIME type is {2}", 
   view.PreferredItemType, 
   view.ItemType, 
   _documentViewer.Document.MimeType) 
MessageBox.Show(message) 
Requirements
Target Platforms
Help Version 21.0.2021.3.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Viewer.WinForms Assembly