的主题是类是文档查看器使用的主类。
公共类DocumentViewer: IDisposable
公共类主题是
公共:
ref类主题是
文档查看器使用LEADTOOLS光栅而且文档的支持,缓存,SVG,光学字符识别,注释,图像查看器创建应用程序的技术,可以查看、编辑和修改桌面或web上的任何类型的文档,只需最少的代码。
主题是文档查看器使用的主类。它本身不是控件:相反,它使用用户提供的父容器来创建必要的UI控件。这些容器是调用平台中的本机控件(例如,Windows窗体中的本机控件和HTML/JavaScript中的DIV元素)。
的主题是具有以下部分:
视图:文件的主要内容在此阅览。本部分为可选配置。
缩略图:网页的缩略图可在此阅览。本部分为可选配置。
书签:在这里可以添加、查看和操作文档的书签和目录。本部分为可选配置。
注释:注释工具栏和对象列表在这里被添加、查看和操作。本部分为可选配置。
应用程序用户界面:其余部分是用户应用程序的UI元素(它们不是文档查看器的一部分)。这些通常是绑定到文档查看器的标准菜单和工具栏项命令.
使用DocumentViewerFactory。CreateDocumentViewer的新实例主题是.然后使用SetDocument设置LEADDocument用于查看、文本搜索、注释和转换的对象。指使用LEADTOOLS文档查看器获取更多信息。
这个例子将展示如何创建一个函数主题是在Windows窗体应用程序中。
使用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这是可选的,但它可以加快大型文档的查看速度
//如果不需要,删除这个section
DocumentFactory。缓存=新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/zoom
varinteractiveComboBox =这.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。宽度= 200
leftPanel。Dock = DockStyle。左
leftPanel。BackColor =颜色。灰色的
leftPanel。BorderStyle = BorderStyle。FixedSingle
我.Controls.Add (leftPanel)
“在右侧添加一个面板,这将用于书签或注释部分
昏暗的rightPanel作为新面板()
rightPanel。Name =“rightPanel”
rightPanel。宽度= 200
rightPanel。Dock = DockStyle。正确的
rightPanel。BackColor =颜色。LightBlue
rightPanel。BorderStyle = BorderStyle。FixedSingle
我.Controls.Add (rightPanel)
为文档查看器添加一个面板来填充其余部分
昏暗的middlePanel作为新面板()
middlePanel。Name =“middlePanel”
middlePanel。BackColor =颜色。DarkGray
middlePanel。BorderStyle = BorderStyle。没有一个
middlePanel。Dock = DockStyle。填满
我.Controls.Add (middlePanel)
添加一个顶部面板来存放我们的应用程序控件
昏暗的topPanel作为新面板()
topPanel。Name =“topPanel”
topPanel。高度= 100
topPanel。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。宽度= 400
infoLabel。左=interactiveComboBox。右+ 20
topPanel.Controls.Add (infoLabel)
昏暗的exampleButton作为新按钮()
exampleButton。前=interactiveComboBox。底部+ 2
exampleButton。Name =“exampleButton”
exampleButton。文本=“例子”
AddHandlerexampleButton。点击,子(sender, e)示例(exampleButton)
topPanel.Controls.Add (exampleButton)
结束子
私人子示例(exampleButton作为按钮)
在这里添加示例代码
对话框。显示(我,“准备好了”)
结束子
结束类
帮助收藏
光栅net|C API|c++类库|HTML5 JavaScript
文档net|C API|c++类库|HTML5 JavaScript
医疗net|C API|c++类库|HTML5 JavaScript
医疗网络查看器net
188宝金博怎么下载
支持的平台上
.NET、Java、Android和iOS/macOS程序集
C API/ c++类库
HTML5 JavaScript库
您的邮件已发送给技术支持!应该有人联系!如果你的事情很紧急,请回来聊天。
聊天时间:
周一至周五,美国东部时间上午8:30至下午6:00
感谢您的反馈!
请再次填写表格,开始新的聊天。
所有代理目前都离线。
聊天时间:
星期一至星期五
美国东部时间上午8:30 -下午6点
如需与我们联系,请填写此表格,我们将通过电子邮件与您联系。