/*! 20251201182703
* Dynamsoft JavaScript Library
* Product: Dynamic Web TWAIN
* Web Site: https://www.dynamsoft.com
*
* Copyright 2025, Dynamsoft Corporation
* Author: Dynamsoft Support Team
*
* Module: PDF
* Version: 19.3
* 
*/
var Dynamsoft=self.Dynamsoft||{};Dynamsoft.DWT=Dynamsoft.DWT||{},Dynamsoft.aryAddonReadyFun=Dynamsoft.aryAddonReadyFun||[],Dynamsoft.AddonReady=Dynamsoft.AddonReady||function(e){Dynamsoft.aryAddonReadyFun.push(e)},function(){Dynamsoft.DWT.EnumDWT_ConvertMode={CM_RENDERALL:1,CM_IMAGEONLY:2,CM_AUTO:3,CM_RENDERALLWITHANNOTATION:4},Dynamsoft.DWT.EnumDWT_PDFCompressionType={PDF_AUTO:0,PDF_FAX3:1,PDF_FAX4:2,PDF_LZW:3,PDF_RLE:4,PDF_JPEG:5,PDF_JP2000:6,PDF_JBIG2:7}}(),Dynamsoft.AddonReady(function(o,e){var t,n;o.product.bHTML5Edition&&(t={code:-2830,message:"The PDF resolution must be a positive number."},o.DynamicLoadAddonFuns)&&o.DynamicLoadAddonFuns.push(function(a){var e,i=o.html5.Funs;n=a.__serverPlatform==Dynamsoft.DWT.EnumDWT_PlatformType.enumMac?a._b64bit?"libDMCodecx64.dylib":"libDMCodec.dylib":a.__serverPlatform==Dynamsoft.DWT.EnumDWT_PlatformType.enumLinux||a.__serverPlatform==Dynamsoft.DWT.EnumDWT_PlatformType.enumEmbed||a.__serverPlatform==Dynamsoft.DWT.EnumDWT_PlatformType.enumChromeOS?"libDMCodec.so":a._b64bit?"DMCodecx64.dll":"DMCodec.dll";try{a._innerSend("GetAddOnVersion",i.makeParams("pdf",n),!0,!1,!1).catch(function(){})}catch(e){}e={PDF:{IsModuleInstalled:function(){var e=a;return e._resetErr(),""!=e._innerFun("GetAddOnVersion",i.makeParams("pdf",n))},IsModuleInstalledAsync:function(){var e=a;return e._resetErr(),e._innerFunV2("GetAddOnVersion",i.makeParams("pdf",n)).then(function(e){return""!=e})},ConvertToImage:function(e,n,r,t){var e=i.replaceLocalFilename(e),o="ConvertPDFToImage",s=a;return s._resetErr(),i.showMask(o),s._innerSend(o,i.makeParams(e,n),!0,function(e){return i.hideMask(o),r&&r(),!0},function(e){return i.hideMask(o),t&&t(),!1}),!0},SetPassword:function(e){var n=a,r=e||"";return n._resetErr(),!!n._checkPDFPasswordValue(r)&&(r=n._mixSavedPdfReaderOptions({password:r}),(r=n._setReaderOptions(r,!1))&&(n._pdfOptions.password=e),r)},SetConvertMode:function(e){return a._setConvertMode(e)},SetConvertModeAsync:function(e){return a._setConvertModeAsync(e)},GetConvertMode:function(){var e=a;return e._resetErr(),e._pdfConvertMode},SetResolution:function(e){var n=a,r=e;return n._resetErr(),r=n._mixSavedPdfReaderOptions({renderOptions:{resolution:r}}),(r=n._setReaderOptions(r,!1))&&(n._pdfOptions.renderOptions.resolution=e),r},SetResolutionAsync:function(n){var r=a;return r._resetErr(),!Dynamsoft.Lib.isNumber(n)||n<=0?Dynamsoft.Lib.Promise.reject(t):r._innerFunV2("SetPDFResolution",i.makeParams(n)).then(function(e){e&&(r._pdfOptions.renderOptions.resolution=n)})},SetReaderOptions:function(e){return a._setReaderOptions(e,!0)},GetReaderOptions:function(){var e,n=a;return n._resetErr(),e=a._innerFun("GetPDFReaderOptions"),e=Dynamsoft.Lib.parse(e),n._pdfOptions=n._mixSavedPdfReaderOptions(e),Dynamsoft.Lib.clone(n._pdfOptions)},IsTextBasedPDF:function(e,n,r){var t=a,e=(t._resetErr(),i.replaceLocalFilename(e)),e=a._innerFun("IsTextBasedPDF",i.makeParams(e));return 0==t.ErrorCode?o.isFunction(n)&&n(e):o.isFunction(r)&&r(t.ErrorCode,t.ErrorString),e},IsRasterizationRequired:function(e){a._resetErr();e=i.replaceLocalFilename(e);return a._innerFun("IsRasterizationRequired",i.makeParams(e))},Write:{Setup:function(e){o.isObject(e)?(n=Dynamsoft.Lib.clone(e),2<o.stringify(n).length&&(o.isNumber(n.version)?1<=n.version&&n.version<2&&(n.version=parseInt(10*n.version)):n.version=15)):n={version:15},o.isNumber(n.compression)&&n.compression==Dynamsoft.DWT.EnumDWT_PDFCompressionType.PDF_FAX3&&(n.compression=Dynamsoft.DWT.EnumDWT_PDFCompressionType.PDF_FAX4);var n,e=a;return e._resetErr(),!(n.password&&(o.isNumber(n.password)&&(n.password=n.password.toString()),!e._checkPDFPasswordValue(n.password)))&&(n=o.stringify(n),n=o.replaceAll(n,'"','\\"'),e._innerFun("SetPDFSettings",['["',n,'"]'].join("")))}}}},a.__addon=a.__addon||{},o.mix(a.__addon,e)})}),Dynamsoft.AddonReady(function(a,e){a.product.bActiveXEdition&&a.DynamicLoadAddonFuns&&a.DynamicLoadAddonFuns.push(function(o){var e,s,n;if(!o.getSWebTwain()||!o.getSWebTwain().Addon)return!1;Dynamsoft.navInfoSync.bWin&&(n=!Dynamsoft.navInfo.bOSx64||Dynamsoft.navInfo.bWOW64?"DMCodec.dll":"DMCodecx64.dll"),s=o.getSWebTwain(),e={PDF:{IsModuleInstalled:function(){var e=s.GetAddOnVersion("pdf",n);return a.setErrorString(o),""!=e},IsModuleInstalledAsync:function(){var e=s.GetAddOnVersion("pdf",n);return a.setErrorString(o),a.Promise.resolve(""!=e)},ConvertToImage:function(e,n,r,t){e=s.ConvertPDFToImage(e,n);return a.wrapperRet(o,e,r,t)},SetPassword:function(e){e=s.SetPDFPassword(e);return a.wrapperRet(o,e)},SetConvertMode:function(e){return o._setConvertMode(e)},SetConvertModeAsync:function(e){return Promise.resolve(o._setConvertMode(e))},GetConvertMode:function(){return o._resetErr(),o._pdfConvertMode},SetResolution:function(e){e=s.SetPDFResolution(e);return a.wrapperRet(o,e)},SetResolutionAsync:function(e){e=s.SetPDFResolution(e);return a.Promise.resolve(a.wrapperRet(o,e))},SetReaderOptions:function(){return!1},GetReaderOptions:function(){return{}},IsTextBasedPDF:function(e){e=s.IsTextBasedPDF(e);return a.wrapperRet(o,e)}}},o.Addon=o.Addon||{},a.mix(o.Addon,e)})});