←选择平台

是类

总结

主题是类是文档查看器使用的主类。

语法
c#
VB
c++
公共DocumentViewer: IDisposable
公共主题是
公共ref类主题是
讲话

文档查看器使用LEADTOOLS光栅而且文档的支持,缓存SVG光学字符识别注释,图像查看器创建应用程序的技术,可以查看、编辑和修改桌面或web上的任何类型的文档,只需最少的代码。

主题是文档查看器使用的主类。它本身不是控件:相反,它使用用户提供的父容器来创建必要的UI控件。这些容器是调用平台中的本机控件(例如,Windows窗体中的本机控件和HTML/JavaScript中的DIV元素)。

主题是具有以下部分:

DocumentViewerParts
  1. 视图:文件的主要内容在此阅览。本部分为可选配置。

  2. 缩略图:网页的缩略图可在此阅览。本部分为可选配置。

  3. 书签:在这里可以添加、查看和操作文档的书签和目录。本部分为可选配置。

  4. 注释:注释工具栏和对象列表在这里被添加、查看和操作。本部分为可选配置。

  5. 应用程序用户界面:其余部分是用户应用程序的UI元素(它们不是文档查看器的一部分)。这些通常是绑定到文档查看器的标准菜单和工具栏项命令

使用DocumentViewerFactory。CreateDocumentViewer的新实例主题是.然后使用SetDocument设置LEADDocument用于查看、文本搜索、注释和转换的对象。指使用LEADTOOLS文档查看器获取更多信息。

例子

这个例子将展示如何创建一个函数主题是在Windows窗体应用程序中。

c#
VB
使用Leadtools;使用Leadtools.Controls;使用Leadtools.Document;使用Leadtools.Document.Viewer;使用Leadtools.Codecs;使用Leadtools.Caching;使用Leadtools.Annotations.Engine;使用Leadtools.Ocr;公共无效DocumentViewer_Example ()//新表单用作我们的应用程序var形式=MyForm ();form.ShowDialog ();MyForm:表单公共MyForm ().Size =规模(800、800);。text =“LEADTOOLS文档查看器示例”受保护的覆盖无效OnLoad (EventArgs e)如果(DesignMode !)// Init OCR。这是可选的,对于我们正在加载的PDF文档来说不是必需的。//但如果加载图像文档,并使用文本功能,那么我们需要OCR_ocrEngine = OcrEngineManager.CreateEngine(ocrengintype . lead);_ocrEngine。启动(@“C: \ LEADTOOLS21 \ Bin \常见\ OcrLEADRuntime”);Init ();基地.OnLoad (e);//文档查看器实例私人主题是_documentViewer;//示例中使用的可选OCR引擎私人IOcrEngine _ocrEngine;私人无效Init ()//初始化用户界面InitUI ();// Init cache这是可选的,但它可以加快大型文档的查看速度//如果不需要,删除这个sectionDocumentFactory。缓存=FileCache ();// Init文档查看器,沿着面板传递varcreateOptions =DocumentViewerCreateOptions//视图的中间面板ViewContainer =.Controls.Find (“middlePanel”) [0],//用于缩略图的左边面板ThumbnailsContainer =.Controls.Find (“leftPanel”) [0],//右边的面板是书签BookmarksContainer =.Controls.Find (“rightPanel”) [0],//暂不使用注释UseAnnotations =};//创建文档查看器_documentViewer = DocumentViewerFactory.CreateDocumentViewer(createOptions);//我们更喜欢SVG视图_documentViewer.View。PreferredItemType = DocumentViewerItemType.Svg;//加载一个文档var文件名=@“C: \ LEADTOOLS21 \资源\ \ Leadtools.pdf图像”vardocument = DocumentFactory。LoadFromFile (文件名,LoadDocumentOptions {UseCache = DocumentFactory。缓存! =});_documentViewer。操作+= (sender, e) =>如果(e.Operation == DocumentViewerOperation.LoadingBookmarks)//加载时禁用书签,加载完成时启用书签varrightPanel =.Controls.Find (“rightPanel”真正的) [0];如果(rightPanel.InvokeRequired)rightPanel.Invoke ((MethodInvoker)委托{rightPanel。Enabled = e.IsPostOperation;});其他的rightPanel。Enabled = e.IsPostOperation;};//如果我们有一个OCR引擎,使用它document.Text.OcrEngine = _ocrEngine;//在查看器中设置_documentViewer.SetDocument(文档);//执行命令pan/zoomvarinteractiveComboBox =.Controls.Find (“interactiveComboBox”真正的) [0]作为组合框;interactiveComboBox。设置SelectedItem=主题是Commands.InteractivePanZoom;私人无效InitUI ()//在左侧添加一个面板用于文档查看器缩略图部分varleftPanel =面板();leftPanel。Name =“leftPanel”leftPanel。宽度= 200;leftPanel。Dock = DockStyle.Left;leftPanel。BackColor = Color.Gray;leftPanel。BorderStyle = BorderStyle. fixedsingle;.Controls.Add (leftPanel);//在右边添加一个面板,这将用于书签或注释部分varrightPanel =面板();rightPanel。Name =“rightPanel”rightPanel。宽度= 200;rightPanel。Dock = DockStyle.Right;rightPanel。BackColor = Color.LightBlue;rightPanel。BorderStyle = BorderStyle. fixedsingle;.Controls.Add (rightPanel);//添加一个面板来填充其余部分,用于文档查看器varmiddlePanel =面板();middlePanel。Name =“middlePanel”middlePanel。BackColor = color .深灰色;middlePanel。BorderStyle = BorderStyle. none;middlePanel。Dock = DockStyle.Fill;.Controls.Add (middlePanel);//添加一个顶部面板来承载我们的应用程序控件vartopPanel =面板();topPanel。Name =“topPanel”topPanel。高度= 100;topPanel。Dock = DockStyle.Top;topPanel。BorderStyle = BorderStyle. fixedsingle;.Controls.Add (topPanel);middlePanel.BringToFront ();//为UI添加按钮//交互模式的组合框varinteractiveComboBox =组合框();interactiveComboBox。Name =“interactiveComboBox”interactiveComboBox。DropDownStyle = ComboBoxStyle.DropDownList;//项目的命令名,这样我们就可以运行它们interactiveComboBox.Items.Add (DocumentViewerCommands.InteractivePanZoom);interactiveComboBox.Items.Add (DocumentViewerCommands.InteractiveSelectText);interactiveComboBox。SelectedIndexChanged += (sender, e) =>varcommandName = interactiveComboBox。设置SelectedItem作为字符串_documentViewer.Commands.Run (commandName);};topPanel.Controls.Add (interactiveComboBox);//示例使用的信息的通用标签varinfoLabel =标签();infoLabel。Name =“infoLabel”infoLabel。文本=“信息……”infoLabel。AutoSize =infoLabel。宽度= 400;infoLabel。左=interactiveComboBox。右+ 20;topPanel.Controls.Add (infoLabel);varexampleButton =按钮();exampleButton。前=interactiveComboBox。底部+ 2;exampleButton。Name =“exampleButton”exampleButton。文本=“例子”exampleButton。点击+= (sender, e) =>示例(exampleButton);topPanel.Controls.Add (exampleButton);私人无效示例(按钮exampleButton)//在这里添加示例代码控制台。WriteLine (+“准备好了”);
进口Leadtools进口Leadtools。控制进口Leadtools。文档进口Leadtools.Document.Viewer进口Leadtools。编解码器进口Leadtools。缓存进口Leadtools.Annotations.Engine进口Leadtools。光学字符识别公共DocumentViewer_Example ()新表格将被用作我们的申请昏暗的形式作为MyForm ()form.ShowDialog ()结束MyForm继承了形式公共().Size =大小(800、800)。text =“LEADTOOLS文档查看器示例”结束受保护的覆盖OnLoad (e作为EventArgs)如果DesignMode然后初始化OCR。这是可选的,对于我们正在加载的PDF文档来说不是必需的。“但如果要加载图像文档并使用文本功能,那么我们就需要OCR_ocrEngine = OcrEngineManager.CreateEngine(ocrengintype . lead)_ocrEngine。启动(没有什么没有什么没有什么“C: \ LEADTOOLS21 \ Bin \常见\ OcrLEADRuntime”Init ()结束如果MyBase.OnLoad (e)结束我们的文档查看器实例私人_documentViewer作为主题是’示例中使用的可选OCR引擎私人_ocrEngine作为IOcrEngine私人Init ()初始化用户界面InitUI ()初始化缓存。这是可选的,但它可以加快大型文档的查看速度’如果不需要,请删除此部分DocumentFactory。缓存=FileCache ()初始化文档查看器,沿着面板传递昏暗的createOptions作为DocumentViewerCreateOptions ()中间的面板是视图createOptions。视图Container =.Controls.Find (“middlePanel”) (0)左边的面板是缩略图createOptions。缩略图Container =.Controls.Find (“leftPanel”) (0)右边的面板是书签createOptions。书签Container =.Controls.Find (“rightPanel”) (0)目前不使用注释createOptions。使用注释=创建文档查看器_documentViewer = DocumentViewerFactory.CreateDocumentViewer(createOptions)我们更喜欢SVG观看_documentViewer.View。PreferredItemType = DocumentViewerItemType.Svg加载一个文档昏暗的文件名作为字符串“C: \ LEADTOOLS21 \资源\ \ Leadtools.pdf图像”昏暗的loadOptions作为LoadDocumentOptions ()loadOptions。UseCache =没有(DocumentFactory.Cache)昏暗的文档作为LEADDocument = DocumentFactory。LoadFromFile (文件名,loadOptions)AddHandler_documentViewer。操作,(发送者,e)如果e.Operation = DocumentViewerOperation。LoadingBookmarks然后加载时禁用书签,加载完成时启用书签昏暗的rightPanel作为控制=.Controls.Find (“rightPanel”真正的) (0)如果rightPanel。InvokeRequired然后rightPanel。调用(DirectCast() rightPanel。Enabled = e.IsPostOperation, MethodInvoker))其他的rightPanel。Enabled = e.s ispostoperation结束如果结束如果结束如果我们有OCR引擎,就使用它document.Text.OcrEngine = _ocrEngine在查看器中设置_documentViewer.SetDocument(文档)运行pan/zoom昏暗的interactiveComboBox作为组合框=CType.Controls.Find (“interactiveComboBox”真正的)(0),组合框)interactiveComboBox。设置SelectedItem=主题是Commands.InteractivePanZoom结束私人InitUI ()在左侧添加一个面板用于文档查看器缩略图部分昏暗的leftPanel作为面板()leftPanel。Name =“leftPanel”leftPanel。宽度= 200leftPanel。Dock = DockStyle。左leftPanel。BackColor =颜色。灰色的leftPanel。BorderStyle = BorderStyle。FixedSingle.Controls.Add (leftPanel)“在右侧添加一个面板,这将用于书签或注释部分昏暗的rightPanel作为面板()rightPanel。Name =“rightPanel”rightPanel。宽度= 200rightPanel。Dock = DockStyle。正确的rightPanel。BackColor =颜色。LightBluerightPanel。BorderStyle = BorderStyle。FixedSingle.Controls.Add (rightPanel)为文档查看器添加一个面板来填充其余部分昏暗的middlePanel作为面板()middlePanel。Name =“middlePanel”middlePanel。BackColor =颜色。DarkGraymiddlePanel。BorderStyle = BorderStyle。没有一个middlePanel。Dock = DockStyle。填满.Controls.Add (middlePanel)添加一个顶部面板来存放我们的应用程序控件昏暗的topPanel作为面板()topPanel。Name =“topPanel”topPanel。高度= 100topPanel。Dock = DockStyle。前topPanel。BorderStyle = BorderStyle。FixedSingle.Controls.Add (topPanel)middlePanel.BringToFront ()为用户界面添加按钮’用于交互模式的组合框昏暗的interactiveComboBox作为组合框()interactiveComboBox。Name =“interactiveComboBox”interactiveComboBox。DropDownStyle = ComboBoxStyle。DropDownList这些项目的命令名称,这样我们就可以直接运行它们interactiveComboBox.Items.Add (DocumentViewerCommands.InteractivePanZoom)interactiveComboBox.Items.Add (DocumentViewerCommands.InteractiveSelectText)AddHandlerinteractiveComboBox。SelectedIndexChanged,(发送者,e)昏暗的commandName作为字符串CType(interactiveComboBox。设置SelectedItem,字符串_documentViewer.Commands.Run (commandName)结束topPanel.Controls.Add (interactiveComboBox)'用于示例使用的信息的通用标签昏暗的infoLabel作为标签()infoLabel。Name =“infoLabel”infoLabel。文本=“信息……”infoLabel。AutoSize =infoLabel。宽度= 400infoLabel。左=interactiveComboBox。右+ 20topPanel.Controls.Add (infoLabel)昏暗的exampleButton作为按钮()exampleButton。前=interactiveComboBox。底部+ 2exampleButton。Name =“exampleButton”exampleButton。文本=“例子”AddHandlerexampleButton。点击,(sender, e)示例(exampleButton)topPanel.Controls.Add (exampleButton)结束私人示例(exampleButton作为按钮)在这里添加示例代码对话框。显示(“准备好了”结束结束
需求
目标平台
Leadtools.Document.Viewer.WinForms组装
188金宝搏的网址客服|支持|联系我们|知识产权公告
©1991 - 2021领德科技有限公司版权所有。