Occurs when an operation is invoked inside this document viewer.
Object.defineProperty(DocumentViewer.prototype,'operation',
get:function(),
set:function(value)
)
operation:LeadEvent;
Parameter | Type | Description |
---|---|---|
sender | var | The source of the event. |
e | DocumentViewerOperationEventArgs | The event data. |
TheOperationevent occurs anytime the document viewer is performing an operation (for example, when rendering the place holder of a page on theView, or when a new annotation object is added, etc.).
EachOperationevent fires twice. The first time the value ofDocumentViewerOperationEventArgs.IsPostOperationis set tofalseto indicate that the operation is about to happen. The second timeDocumentViewerOperationEventArgs.IsPostOperationis set totrueto indicate that the operation is completed.
The operation type is stored inOperation. WhenIsPostOperationisfalse, some operations allow the user to change the behavior or abort the operation.
Refer toDocument Viewer Operationsfor a detailed list of all document viewer operations.
In this example, clicking the example button will add an intercept callback that will prevent clicked links from being run.
import{ ViewerInitializer } from"../utilities/ViewerInitializer";
exportclassOperationTSExample {
publicrun = () => {
newViewerInitializer(this.addOperationEvent);
}
addOperationEvent = (documentViewer: lt.Document.Viewer.DocumentViewer) => {
// Add a callback for when the user clicks a link (bookmark on the page, for example)
documentViewer.operation.add((sender:any, e: lt.Document.Viewer.DocumentViewerOperationEventArgs) => {
// When the user clicks a link and we're going to start running the link...
if(e.operation == lt.Document.Viewer.DocumentViewerOperation.runLink && !e.isPostOperation) {
constlink = e.data1;
if(link) {
// Cancel the operation
e.abort =true;
// Show a message
let message ="Link will be ignored!";
if(link.bounds) {
message +="\nbounds: "+ link.bounds.x +", "+ link.bounds.y +", "+ link.bounds.width +", "+ link.bounds.bottom;
}
if(link.target && link.target.pageNumber) {
message +="\ntarget page: "+ link.target.pageNumber;
}
alert(message);
}
}
});
}
}
exportclassViewerInitializer {
privatecallback: (viewer: lt.Document.Viewer.DocumentViewer) =>void=null;
constructor(callback?: (viewer: lt.Document.Viewer.DocumentViewer) =>void) {
this.callback = callback;
this.init();
}
publicstaticshowServiceError = (jqXHR, statusText, errorThrown) => {
alert('Error returned from service. See the console for details.')
constserviceError = lt.Document.ServiceError.parseError(jqXHR, statusText, errorThrown);
console.error(serviceError);
}
privateinit = () => {
this.initFactory();
this.testConnection();
}
privateinitFactory = () => {
lt.RasterSupport.setLicenseUri('https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt','EVAL',null);
// To communicate with the DocumentsService, it must be running!
// Change these parameters to match the path to the service.
lt.Document.DocumentFactory.serviceHost ='http://localhost:40000';
lt.Document.DocumentFactory.servicePath ='';
lt.Document.DocumentFactory.serviceApiPath ='api';
}
privatetestConnection = () => {
constserviceStatus = document.getElementById('serviceStatus');
serviceStatus.innerHTML ='Connecting to service: '+ lt.Document.DocumentFactory.serviceUri;
lt.Document.DocumentFactory.verifyService()
.done((serviceData) => {
serviceStatus.innerHTML ='Service connection verified!';
this.createDocumentViewer();
})
.fail((jqXHR, statusText, errorThrown) => {
serviceStatus.innerHTML ='Service connection unavailable.';
ViewerInitializer.showServiceError(jqXHR, statusText, errorThrown);
});
}
privatecreateDocumentViewer = () => {
// Initialize the user interface
constinteractiveSelect = document.getElementById('interactiveSelect');
constpanZoomOption = document.createElement('option');
panZoomOption.innerHTML ='Pan / Zoom';
panZoomOption.value = lt.Document.Viewer.DocumentViewerCommands.interactivePanZoom;
interactiveSelect.appendChild(panZoomOption);
const文本Option = document.createElement('option');
文本Option.value = lt.Document.Viewer.DocumentViewerCommands.interactiveSelectText;
文本Option.innerHTML ='Select Text';
interactiveSelect.appendChild(textOption);
let documentViewer: lt.Document.Viewer.DocumentViewer =null;
interactiveSelect.onchange = (e) => documentViewer.commands.run((e.target as HTMLSelectElement).value,null);
constannotationsSelect = document.getElementById('annotationsSelect');
constannSelectOption = document.createElement('option');
annSelectOption.innerHTML ='Select Annotation';
annSelectOption.value = lt.Annotations.Engine.AnnObject.selectObjectId.toString();
annotationsSelect。appendChild(annSelectOption);
constannLineOption = document.createElement('option');
annLineOption.innerHTML ='Line Object';
annLineOption.value = lt.Annotations.Engine.AnnObject.lineObjectId.toString();
annotationsSelect。appendChild(annLineOption);
constannRectOption = document.createElement('option');
annRectOption.innerHTML ='Rectangle Object';
annRectOption.value = lt.Annotations.Engine.AnnObject.rectangleObjectId.toString();
annotationsSelect。appendChild(annRectOption);
annotationsSelect。onchange = (e) => {
constvalue = +(e.currentTarget as HTMLSelectElement).value;
documentViewer.annotations.automationManager.currentObjectId = value;
}
// Init the document viewer, pass along the panels
constcreateOptions =newlt.Document.Viewer.DocumentViewerCreateOptions();
// We are not going to use elements mode in this example
createOptions.viewCreateOptions.useElements =false;
createOptions.thumbnailsCreateOptions.useElements =false;
// The middle panel for the view
createOptions.viewContainer = document.getElementById('viewer');
// The left panel for the thumbnails
createOptions.thumbnailsContainer = document.getElementById('thumbnails');
// The right panel is for bookmarks
createOptions.bookmarksContainer = document.getElementById('bookmarks');
createOptions.useAnnotations =true;
// Create the document viewer
documentViewer = lt.Document.Viewer.DocumentViewerFactory.createDocumentViewer(createOptions);
// We prefer SVG viewing
documentViewer.view.preferredItemType = lt.Document.Viewer.DocumentViewerItemType.svg;
// Create html5 rendering engine
documentViewer.annotations.automationManager.renderingEngine =newlt.Annotations.Rendering.AnnHtml5RenderingEngine();
// Initialize documentViewer annotations
documentViewer.annotations.initialize();
documentViewer.annotations.automationManager.currentObjectIdChanged.add(function(sender, e) {
// When done drawing, the manager will return to the select object; so we need force the annotationsSelect element to return to the select object option
(annotationsSelect as HTMLSelectElement).value = sender.currentObjectId;
});
this.loadDefaultDoc(documentViewer, interactiveSelect as HTMLSelectElement)
}
privateloadDefaultDoc = (viewer: lt.Document.Viewer.DocumentViewer, interactiveSelect: HTMLSelectElement) => {
// Load a PDF document
consturl ='https://demo.leadtools.com/images/pdf/leadtools.pdf';
lt.Document.DocumentFactory.loadFromUri(url,null)
.done((doc: lt.Document.LEADDocument) => {
constready = () => {
viewer.setDocument(doc);
constpanZoom = lt.Document.Viewer.DocumentViewerCommands.interactivePanZoom;
interactiveSelect.value = panZoom;
viewer.commands.run(panZoom,null);
if(this.callback)
this.callback(viewer);
}
if(doc.isStructureSupported && !doc.structure.isParsed)
doc.structure.parse()
.done(ready)
.fail(ViewerInitializer.showServiceError);
else
ready();
})
.fail(ViewerInitializer.showServiceError);
}
}
import{ ViewerInitializer } from"../utilities/ViewerInitializer";
exportclassOperationJSExample {
run = () => {
newViewerInitializer(this.addOperationEvent);
}
addOperationEvent = (documentViewer) => {
// Add a callback for when the user clicks a link (bookmark on the page, for example)
documentViewer.operation.add((sender, e) => {
// When the user clicks a link and we're going to start running the link...
if(e.operation == lt.Document.Viewer.DocumentViewerOperation.runLink && !e.isPostOperation) {
constlink = e.data1;
if(link) {
// Cancel the operation
e.abort =true;
// Show a message
let message ="Link will be ignored!";
if(link.bounds) {
message +="\nbounds: "+ link.bounds.x +", "+ link.bounds.y +", "+ link.bounds.width +", "+ link.bounds.bottom;
}
if(link.target && link.target.pageNumber) {
message +="\ntarget page: "+ link.target.pageNumber;
}
alert(message);
}
}
});
}
}
exportclassViewerInitializer {
constructor(callback) {
this.callback = callback;
this.init();
}
staticshowServiceError = (jqXHR, statusText, errorThrown) => {
alert("Error returned from service. See the console for details.")
constserviceError = lt.Document.ServiceError.parseError(jqXHR, statusText, errorThrown);
console.error(serviceError);
}
init = () => {
this.initFactory();
this.testConnection();
}
initFactory = () => {
lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt","EVAL",null);
// To communicate with the DocumentsService, it must be running!
// Change these parameters to match the path to the service.
lt.Document.DocumentFactory.serviceHost ="http://localhost:40000";
lt.Document.DocumentFactory.servicePath ="";
lt.Document.DocumentFactory.serviceApiPath ="api";
}
testConnection = () => {
constserviceStatus = document.getElementById("serviceStatus");
serviceStatus.innerHTML ="Connecting to service: "+ lt.Document.DocumentFactory.serviceUri;
lt.Document.DocumentFactory.verifyService()
.done((serviceData) => {
serviceStatus.innerHTML ="Service connection verified!";
this.createDocumentViewer();
})
.fail((jqXHR, statusText, errorThrown) => {
serviceStatus.innerHTML ="Service connection unavailable.";
ViewerInitializer.showServiceError(jqXHR, statusText, errorThrown);
});
}
createDocumentViewer = () => {
// Initialize the user interface
constinteractiveSelect = document.getElementById("interactiveSelect");
constpanZoomOption = document.createElement("option");
panZoomOption.innerHTML ="Pan / Zoom";
panZoomOption.value = lt.Document.Viewer.DocumentViewerCommands.interactivePanZoom;
interactiveSelect.appendChild(panZoomOption);
const文本Option = document.createElement("option");
文本Option.value = lt.Document.Viewer.DocumentViewerCommands.interactiveSelectText;
文本Option.innerHTML ="Select Text";
interactiveSelect.appendChild(textOption);
let documentViewer =null;
interactiveSelect.onchange = (e) => documentViewer.commands.run(e.target.value,null);
constannotationsSelect = document.getElementById("annotationsSelect");
constannSelectOption = document.createElement("option");
annSelectOption.innerHTML ="Select Annotation";
annSelectOption.value = lt.Annotations.Engine.AnnObject.selectObjectId.toString();
annotationsSelect。appendChild(annSelectOption);
constannLineOption = document.createElement("option");
annLineOption.innerHTML ="Line Object";
annLineOption.value = lt.Annotations.Engine.AnnObject.lineObjectId.toString();
annotationsSelect。appendChild(annLineOption);
constannRectOption = document.createElement("option");
annRectOption.innerHTML ="Rectangle Object";
annRectOption.value = lt.Annotations.Engine.AnnObject.rectangleObjectId.toString();
annotationsSelect。appendChild(annRectOption);
annotationsSelect。onchange = (e) => {
constvalue = +e.currentTarget.value;
documentViewer.annotations.automationManager.currentObjectId = value;
}
// Init the document viewer, pass along the panels
constcreateOptions =newlt.Document.Viewer.DocumentViewerCreateOptions();
// We are not going to use elements mode in this example
createOptions.viewCreateOptions.useElements =false;
createOptions.thumbnailsCreateOptions.useElements =false;
// The middle panel for the view
createOptions.viewContainer = document.getElementById("viewer");
// The left panel for the thumbnails
createOptions.thumbnailsContainer = document.getElementById("thumbnails");
// The right panel is for bookmarks
createOptions.bookmarksContainer = document.getElementById("bookmarks");
createOptions.useAnnotations =true;
// Create the document viewer
documentViewer = lt.Document.Viewer.DocumentViewerFactory.createDocumentViewer(createOptions);
// We prefer SVG viewing
documentViewer.view.preferredItemType = lt.Document.Viewer.DocumentViewerItemType.svg;
// Create html5 rendering engine
documentViewer.annotations.automationManager.renderingEngine =newlt.Annotations.Rendering.AnnHtml5RenderingEngine();
// Initialize documentViewer annotations
documentViewer.annotations.initialize();
documentViewer.annotations.automationManager.currentObjectIdChanged.add(function(sender, e) {
// When done drawing, the manager will return to the select object; so we need force the annotationsSelect element to return to the select object option
annotationsSelect。值= sender.currentObjectId;
});
this.loadDefaultDoc(documentViewer, interactiveSelect)
}
loadDefaultDoc = (viewer, interactiveSelect) => {
// Load a PDF document
consturl ="https://demo.leadtools.com/images/pdf/leadtools.pdf";
lt.Document.DocumentFactory.loadFromUri(url,null)
.done((doc) => {
constready = () => {
viewer.setDocument(doc);
constpanZoom = lt.Document.Viewer.DocumentViewerCommands.interactivePanZoom;
interactiveSelect.value = panZoom;
viewer.commands.run(panZoom,null);
if(this.callback)
this.callback(viewer);
}
if(doc.isStructureSupported && !doc.structure.isParsed)
doc.structure.parse()
.done(ready)
.fail(ViewerInitializer.showServiceError);
else
ready();
})
.fail(ViewerInitializer.showServiceError);
}
}
"en">
DocViewer Example | DocumentViewer "stylesheet"type="text/css"href="../css/examples.css">
class="container">
class="toolbar">
class="vcenter push-right">
class="vcenter push-right">
class="vcenter push-right">
"output"class="vcenter push-right">
"serviceStatus"class="vcenter push-right">
class="docContainer">
class="sidepanel"id="thumbnails">
class="centerpanel"id="viewer">
class="sidepanel"id="bookmarks">window.onload = () => {
constbutton = document.getElementById('exampleButton');
button.onclick = () => {
constexample =newwindow.examples.OperationExample();
example.run();
}
};
> < /脚本
/*
Removedefaultbody styling.
Set the body to flex as a column;
*/
body {
margin: 0;
display: flex;
flex-direction: column;
}
.container {
margin: 10px;
width: calc(100% - 20px);
height: calc(100vh - 20px);
}
.toolbar {
height: 5%;
width: 100%;
border-bottom: 2px solid #333;
flex-direction: row;
display: flex;
}
#bookmarks{
overflow: hidden;
}
.vcenter {
margin-top: auto;
margin-bottom: auto;
}
.hcenter{
margin-left: auto;
margin-right:汽车;
}
.push-right{
margin-left: 10px;
}
.docContainer{
height: 95%;
width: 100%;
display: flex;
flex-direction: row;
}
.sidepanel{
width: 15%;
height: 100%;
}
.centerpanel{
width:100%;
height:100%;
}
/* StylesforElements Mode. */
.lt-item, .lt-image-border {
/* Box Shadow (view, item, image border) */
box-shadow: #333 2px 2px 5px 1px;
}
.lt-view,.lt-thumb-item {
/* View */
margin: 5px;
padding: 5px;
}
.lt-item {
/* Item */
border: 2px solid #6ecaab;
background-color: #b2decf;
padding: 10px;
}
.lt-image-border {
/* Image Border */
border: 3px solid #444;
background-color: white;
}
.lt-thumb-item {
/* Thumbnail Item */
border: 2px solid #6ecaab;
background-color: #b2decf;
}
.lt-thumb-item.lt-thumb-item-selected {
/* Selected Thumbnail Item */
border: 2px solid #59b2ba;
background-color: #8ce1e1;
}
.lt-thumb-item-hovered {
/* Hovered Thumbnail Item */
border: 2px solid #52b996;
background-color: #87c7b1;
}
.small-modal {
max-width: 200px;
width: 200px;
}
Help Collections
Raster.NET|C API|C++ Class Library|HTML5 JavaScript
Document.NET|C API|C++ Class Library|HTML5 JavaScript
Medical.NET|C API|C++ Class Library|HTML5 JavaScript
Medical Web Viewer.NET
188宝金博怎么下载
Media Foundation.NET|C API|Transforms
Supported Platforms
net, Java, Android和iOS / macOS组件
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.