目前,我想使用DWT Javascript库来扫描我按照这些步骤http://www.codepool.biz/javascript-global-library-angular-cli.html进行新项目的文档,它工作得很好。当我试图融入我的主要项目时,我面临的问题很少,例如progress bar model is will be present all the time no matter what happens
。
但是当在模型中使用相同的代码时,无法获得结果。
码
<ng-template #scanModal let-c="close " let-d="dismiss ">
<div class="modal-header ">
<h6 class="modal-title text-uppercase ">Scan Document</h6>
<button type="button " class="close pointer" aria-label="Close " (click)="d( 'Cross click') ">
<span aria-hidden="true ">×</span>
</button>
</div>
<div class="modal-body">
<button (click)="acquireImage()">Scan Document</button>
<div id="dwtcontrolContainer"></div>
</div>
<span id="alert alert-danger"> </span>
<div id="info" style="display:none; padding:20px 30px; width: 350px; border: solid 1px #e7e7e7;">
The <strong>PDF Rasterizer</strong> is not installed on this PC
<br />Please click the button below to get it installed
<p> <button (click)="downloadPDFR();">Install PDF Rasterizer</button></p>
<i><strong>The installation is a one-time process</strong> <br />
It might take some time depending on your network.</i>
</div>
<br/>
</div>
</ng-template>
当模型打开时,我收到了这个错误
RegisterComponent.html:376错误TypeError:无法读取null的属性'SelectSource'
我只是将HTML代码段粘贴到模型中,TS代码没有变化。
TS代码
acquireImage(): void {
const dwObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
const bSelected = dwObject.SelectSource();
if (bSelected) {
const onAcquireImageSuccess = () => { dwObject.CloseSource(); };
const onAcquireImageFailure = onAcquireImageSuccess;
dwObject.OpenSource();
dwObject.AcquireImage({}, onAcquireImageSuccess, onAcquireImageFailure);
}
}
提前致谢。
对于第一个问题,请查看另一篇文章dwt-java-script-library-progress-dialogue-automatically-displays-with-angular-5
对于第二个问题。如果看起来是由于缺少类型定义引起的。您是否在TS中包含以下行?
/// <reference types="dwt" />