{"id":9421,"date":"2026-11-06T14:17:39","date_gmt":"2026-11-06T06:17:39","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=9421&#038;preview=true&#038;preview_id=9421"},"modified":"2026-11-06T14:17:41","modified_gmt":"2026-11-06T06:17:41","slug":"uiextension-%e5%8a%9f%e8%83%bd%e6%8c%89%e9%92%ae%e9%9a%90%e8%97%8f%e4%b8%8e%e7%a6%81%e7%94%a8%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=9421","title":{"rendered":"UIExtension \u529f\u80fd\u6309\u94ae\u9690\u85cf\u4e0e\u7981\u7528\u6700\u4f73\u5b9e\u8df5"},"content":{"rendered":"<p><strong>\u9002\u7528\u7248\u672c<\/strong>\uff1aFoxit PDF SDK for Web 11.1 \uff5c <strong>\u9002\u7528\u793a\u4f8b<\/strong>\uff1a<code>examples\/UIExtension\/complete_webViewer\/index.html<\/code> \uff5c <strong>\u6587\u6863\u65e5\u671f<\/strong>\uff1a2026-09-29<\/p>\n<h2>\u4e00\u3001\u80cc\u666f<\/h2>\n<p><code>complete_webViewer<\/code> \u662f\u798f\u6615 Web SDK \u63d0\u4f9b\u7684\u529f\u80fd\u6700\u5b8c\u6574\u7684\u793a\u4f8b\u5de5\u7a0b\uff0c\u9ed8\u8ba4\u628a\u4e0b\u8f7d\u3001\u6253\u5370\u3001\u6253\u5f00\u3001\u6ce8\u91ca\u3001\u8868\u5355\u7b49\u5168\u90e8\u80fd\u529b\u4e00\u6b21\u6027\u5448\u73b0\u51fa\u6765\u3002\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u7edd\u5927\u591a\u6570\u5ba2\u6237\u53ea\u9700\u8981\u5176\u4e2d\u4e00\u90e8\u5206\uff1a\u6709\u7684\u8981\u5c4f\u853d\u4e0b\u8f7d\u4ee5\u9632\u5916\u6cc4\uff0c\u6709\u7684\u8981\u4fdd\u7559\u6253\u5370\u5165\u53e3\u4f46\u6309\u7528\u6237\u7b49\u7ea7\u4e34\u65f6\u7f6e\u7070\uff0c\u6709\u7684\u5e72\u8106\u53ea\u8981\u4e00\u4e2a\u7eaf\u9605\u8bfb\u5668\u3002<\/p>\n<p>\u8fd9\u4e9b\u9700\u6c42\u90fd\u6307\u5411\u540c\u4e00\u4e2a\u52a8\u4f5c\u2014\u2014<strong>\u5728 PDF \u6253\u5f00\u6210\u529f\u540e\uff0c\u5bf9 UIExtension \u7684\u7ec4\u4ef6\u505a\u53ef\u89c1\u6027\u6216\u53ef\u7528\u6027\u63a7\u5236<\/strong>\u3002\u672c\u6587\u7ed9\u51fa\u6807\u51c6\u505a\u6cd5\u3001\u53ef\u76f4\u63a5\u590d\u7528\u7684\u4ee3\u7801\uff0c\u4ee5\u53ca\u51e0\u4e2a\u5bb9\u6613\u8e29\u7684\u5751\u3002<\/p>\n<h2>\u4e8c\u3001\u5148\u5206\u6e05\u4e24\u4ef6\u4e8b\uff1a\u7ec4\u4ef6\u540d\u4e0e CSS \u7c7b\u540d<\/h2>\n<p>UIExtension \u7684\u754c\u9762\u662f\u7531\u4e00\u5957\u6a21\u677f + \u7ec4\u4ef6\u6811\u6784\u6210\u7684\uff0c\u6bcf\u4e2a\u53ef\u4ea4\u4e92\u5143\u7d20\u5728\u7ec4\u4ef6\u6811\u91cc\u90fd\u6709\u4e00\u4e2a <code>name<\/code>\u3002\u6240\u6709\u63a7\u5236\u90fd\u5fc5\u987b\u901a\u8fc7 <code>name<\/code> \u8fdb\u884c\uff0c\u800c<strong>\u4e0d\u662f<\/strong>\u901a\u8fc7 CSS \u7c7b\u540d\u3002<\/p>\n<p>\u8fd9\u4e24\u8005\u957f\u5f97\u5f88\u50cf\uff0c\u6781\u6613\u6df7\u6dc6\uff0c\u662f\u5b9e\u8df5\u4e2d\u6700\u5e38\u89c1\u7684\u9519\u8bef\u6765\u6e90\uff1a<\/p>\n<table border=\"1\">\n<thead>\n<tr>\n<th style=\"text-align:center;vertical-align:middle\">\u6982\u5ff5<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u793a\u4f8b<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u7528\u9014<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u7ec4\u4ef6\u540d\uff08component name\uff09<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>download-file-button<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u4f20\u7ed9 <code>getComponentByName()<\/code>\uff0c\u7528\u4e8e\u63a7\u5236\u903b\u8f91<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">CSS \u56fe\u6807\u7c7b<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>fv__icon-toolbar-download<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u4ec5\u7528\u4e8e\u6837\u5f0f\u5b9a\u4f4d\uff0c<strong>\u4e0d\u80fd<\/strong>\u4f5c\u4e3a\u7ec4\u4ef6\u540d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u547d\u540d\u4e0a\u8fd8\u6709\u4e00\u6761\u89c4\u5f8b\u503c\u5f97\u8bb0\u4f4f\uff1a<strong>\u53f3\u952e\u83dc\u5355\u7c7b\u7ec4\u4ef6\u540d\u5e26 <code>fv--<\/code> \u524d\u7f00<\/strong>\uff08\u5982 <code>fv--contextmenu-item-print<\/code>\uff09\uff0c<strong>\u5de5\u5177\u680f\u6309\u94ae\u7c7b\u4e00\u822c\u4e0d\u5e26\u524d\u7f00<\/strong>\uff08\u5982 <code>download-file-button<\/code>\u3001<code>print-button<\/code>\uff09\u3002\u4e0d\u8981\u51ed CSS \u7c7b\u540d\u53cd\u63a8\u7ec4\u4ef6\u540d\u3002<\/p>\n<h3>\u5e38\u7528\u7ec4\u4ef6\u540d\u5bf9\u7167\u8868<\/h3>\n<table border=\"1\">\n<thead>\n<tr>\n<th style=\"text-align:center;vertical-align:middle\">\u529f\u80fd<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u7ec4\u4ef6 name<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u5f52\u5c5e<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u63a7\u5236\u5668<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u4e0b\u8f7d \/ \u53e6\u5b58<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>download-file-button<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u6838\u5fc3 UI<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>file:DownloadFileController<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u6253\u5370<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>print-button<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">print \u6269\u5c55\u6a21\u5757<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>print:ShowPrintDialogController<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u6253\u5f00\u6587\u4ef6\uff08\u542b\u4e0b\u62c9\u5b50\u9879\uff09<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>open-file-button-list<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u6838\u5fc3 UI<\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u2014<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u5168\u5c4f\u5207\u6362<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>fv--toggle-full-screen-button<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">full-screen \u6269\u5c55\u6a21\u5757<\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u2014<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u53f3\u952e\u83dc\u5355 &#8211; \u6253\u5370<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>fv--contextmenu-item-print<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">print \u6269\u5c55\u6a21\u5757<\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u2014<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8868\u4e2d\u5217\u51fa\u7684\u662f\u7ecf\u6838\u5b9e\u53ef\u7a33\u5b9a\u63a7\u5236\u7684\u5e38\u7528\u9879\uff0c\u5e76\u975e\u5168\u90e8\u7ec4\u4ef6\u3002\u53e6\u9700\u8bf4\u660e\u4e24\u70b9\uff1a\u4e00\u662f\u7ec4\u4ef6\u540d\u5c5e\u4e8e UI \u5c42\u7684\u5b9e\u73b0\u7ec6\u8282\uff0c\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\u53ef\u80fd\u53d1\u751f\u8c03\u6574\uff0c\u82e5\u5347\u7ea7\u540e\u53d1\u73b0\u5931\u6548\uff0c\u8bf7\u6309\u7b2c\u4e03\u8282\u7684\u65b9\u6cd5\u91cd\u65b0\u786e\u8ba4\uff0c\u6216\u4e0e\u798f\u6615\u6280\u672f\u652f\u6301\u6838\u5bf9\uff1b\u4e8c\u662f\u590d\u5408\u6309\u94ae\uff08\u5982&#8221;\u6253\u5f00\u6587\u4ef6&#8221;\uff09\u53ea\u9700\u63a7\u5236\u5176\u5916\u5c42\u7ec4\u4ef6\u5373\u53ef\uff0c\u5185\u90e8\u5b50\u9879\u4f1a\u968f\u4e4b\u9690\u85cf\uff0c\u65e0\u9700\u9010\u4e2a\u5904\u7406\u3002<\/p>\n<h2>\u4e09\u3001\u53ef\u7528 API<\/h2>\n<p>\u4ee5\u4e0b\u63a5\u53e3\u5747\u5728 11.1 JavaScript API \u4e2d\u63d0\u4f9b\uff0c\u662f\u672c\u6587\u65b9\u6848\u7684\u57fa\u7840\uff1a<\/p>\n<table border=\"1\">\n<thead>\n<tr>\n<th style=\"text-align:center;vertical-align:middle\">\u63a5\u53e3<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\"><code>PDFUI.getComponentByName(name)<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u6309\u540d\u79f0\u67e5\u627e\u7ec4\u4ef6\uff0c\u8fd4\u56de Promise<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\"><code>Component.hide()<\/code> \/ <code>Component.show(showParams)<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u9690\u85cf \/ \u663e\u793a\u7ec4\u4ef6<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\"><code>Component.disable()<\/code> \/ <code>Component.enable()<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u7981\u7528\uff08\u7f6e\u7070\u4e0d\u53ef\u70b9\uff09\/ \u542f\u7528<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\"><code>Component.disabled<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u8bfb\u53d6\u5f53\u524d\u7981\u7528\u72b6\u6001<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\"><code>Component.keepState(KeepStateKind.VISIBILITY)<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u9501\u5b9a\u5f53\u524d\u53ef\u89c1\u6027\u72b6\u6001<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\"><code>Component.revokeKeepState(...)<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u89e3\u9664\u9501\u5b9a\uff0c\u4ea4\u8fd8 SDK \u81ea\u52a8\u63a7\u5236<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\"><code>Component.isStateKept(...)<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u67e5\u8be2\u662f\u5426\u5904\u4e8e\u9501\u5b9a\u72b6\u6001<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><code>keepState<\/code> \u7cfb\u5217\u81ea 8.5.2 \u7248\u672c\u8d77\u63d0\u4f9b\uff0c\u662f\u4e13\u95e8\u4e3a\u5e94\u7528\u5c42\u51c6\u5907\u7684\u7ec4\u4ef6\u72b6\u6001\u7ba1\u7406\u63a5\u53e3\uff0cWeb SDK \u5185\u90e8\u4e0d\u4f1a\u8c03\u7528\u5b83\uff0c\u56e0\u6b64\u5e94\u7528\u53ef\u4ee5\u653e\u5fc3\u5730\u7528\u5b83\u63a5\u7ba1\u7ec4\u4ef6\u72b6\u6001\u3002<\/p>\n<h2>\u56db\u3001\u63a8\u8350\u5b9e\u73b0<\/h2>\n<p>\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\u53ef\u76f4\u63a5\u653e\u8fdb <code>complete_webViewer\/index.html<\/code>\uff0c\u653e\u5728 <code>pdfui<\/code> \u5b9e\u4f8b\u521b\u5efa\u4e4b\u540e\uff1a<\/p>\n<pre><code>\/\/ ===== \u6309\u94ae\u7b56\u7565\u914d\u7f6e =====\n\/\/ hide   : \u5b8c\u5168\u4ece\u754c\u9762\u79fb\u9664\n\/\/ disable: \u4fdd\u7559\u663e\u793a\uff0c\u4f46\u7f6e\u7070\u3001\u4e0d\u53ef\u70b9\u51fb\nvar BUTTON_POLICY = {\n    hide:    ['download-file-button'],\n    disable: ['print-button']\n};\n\nfunction lookup(names) {\n    return Promise.all(names.map(function (n) {\n        return pdfui.getComponentByName(n);\n    }));\n}\n\nfunction applyButtonPolicy() {\n    return Promise.all([\n        lookup(BUTTON_POLICY.hide),\n        lookup(BUTTON_POLICY.disable)\n    ]).then(function (groups) {\n        groups[0].forEach(function (comp, i) {\n            if (!comp) {\n                console.warn('[UI] \u7ec4\u4ef6\u672a\u627e\u5230\uff0c\u8bf7\u6838\u5bf9\u540d\u79f0:', BUTTON_POLICY.hide<a href=\"https:\/\/support.fuxinsoft.cn\/?cat=38\" rel=\"tag\">\u798f\u6615PDF SDK \u8f6f\u4ef6\u5f00\u53d1\u5de5\u5177\u5305<\/a> &gt; <a href=\"https:\/\/support.fuxinsoft.cn\/?cat=67\" rel=\"tag\">\u798f\u6615PDF SDK(Web)<\/a>);\n                return;\n            }\n            comp.hide();\n            comp.keepState();        \/\/ \u2605 \u9501\u5b9a\uff0c\u9632\u6b62 SDK \u81ea\u884c\u6062\u590d\u663e\u793a\n        });\n        groups[1].forEach(function (comp, i) {\n            if (!comp) {\n                console.warn('[UI] \u7ec4\u4ef6\u672a\u627e\u5230\uff0c\u8bf7\u6838\u5bf9\u540d\u79f0:', BUTTON_POLICY.disable<a href=\"https:\/\/support.fuxinsoft.cn\/?cat=38\" rel=\"tag\">\u798f\u6615PDF SDK \u8f6f\u4ef6\u5f00\u53d1\u5de5\u5177\u5305<\/a> &gt; <a href=\"https:\/\/support.fuxinsoft.cn\/?cat=67\" rel=\"tag\">\u798f\u6615PDF SDK(Web)<\/a>);\n                return;\n            }\n            comp.disable();\n        });\n    });\n}\n\n\/\/ ===== \u6267\u884c\u65f6\u673a\uff1a\u4e24\u5904\u90fd\u8981 =====\n\/\/ 1) \u7ec4\u4ef6\u6811\u5c31\u7eea\u540e\uff08\u8986\u76d6\u6253\u5f00\u6587\u6863\u524d\u7684\u72b6\u6001\uff09\npdfui.getRootComponent().then(applyButtonPolicy);\n\/\/ 2) \u6bcf\u6b21\u6587\u6863\u6253\u5f00\u6210\u529f\u540e\uff08addon \u7ec4\u4ef6\u52a0\u8f7d\u8f83\u665a\uff0c\u4e14 SDK \u53ef\u80fd\u91cd\u7f6e\u72b6\u6001\uff09\npdfui.addViewerEventListener(Events.openFileSuccess, applyButtonPolicy);<\/code><\/pre>\n<p>\u9700\u8981\u52a8\u6001\u653e\u5f00\u9650\u5236\u65f6\uff1a<\/p>\n<pre><code>pdfui.getComponentByName('download-file-button').then(function (comp) {\n    comp.revokeKeepState();   \/\/ \u5148\u89e3\u9501\n    comp.show();              \/\/ \u518d\u663e\u793a\n});\n\npdfui.getComponentByName('print-button').then(function (comp) {\n    comp.enable();\n});<\/code><\/pre>\n<h2>\u4e94\u3001\u9690\u85cf\u4e0e\u7981\u7528\uff0c\u600e\u4e48\u9009<\/h2>\n<table border=\"1\">\n<thead>\n<tr>\n<th style=\"text-align:center;vertical-align:middle\">\u8bc9\u6c42<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u505a\u6cd5<\/th>\n<th style=\"text-align:center;vertical-align:middle\">\u6548\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u5f7b\u5e95\u4e0d\u51fa\u73b0\uff0c\u7528\u6237\u65e0\u4ece\u611f\u77e5<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>hide() + keepState()<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u6309\u94ae\u4ece DOM \u4e2d\u79fb\u9664<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u4fdd\u7559\u5165\u53e3\u4f46\u5f53\u524d\u4e0d\u53ef\u7528<\/td>\n<td style=\"text-align:center;vertical-align:middle\"><code>disable()<\/code><\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u6309\u94ae\u53ef\u89c1\u3001\u7f6e\u7070\u3001\u70b9\u51fb\u65e0\u54cd\u5e94<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;vertical-align:middle\">\u6309\u7528\u6237\u7b49\u7ea7\u52a8\u6001\u5207\u6362<\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u4e24\u8005\u7ed3\u5408\uff0c\u968f\u72b6\u6001\u5207\u6362<\/td>\n<td style=\"text-align:center;vertical-align:middle\">\u7075\u6d3b\uff0c\u5efa\u8bae\u5c01\u88c5\u6210\u7edf\u4e00\u51fd\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u53ea\u662f\u60f3&#8221;\u4e0d\u663e\u793a\u4e0b\u8f7d&#8221;\uff0c<code>hide() + keepState()<\/code> \u662f\u6700\u5e72\u51c0\u7684\u505a\u6cd5\u3002\u5982\u679c\u4ea7\u54c1\u4e0a\u9700\u8981\u8ba9\u7528\u6237\u77e5\u9053&#8221;\u6709\u8fd9\u4e2a\u529f\u80fd\u4f46\u6ca1\u6743\u9650&#8221;\uff0c\u7528 <code>disable()<\/code> \u66f4\u5408\u9002\u3002<\/p>\n<h2>\u516d\u3001\u51e0\u4e2a\u5fc5\u987b\u6ce8\u610f\u7684\u5751<\/h2>\n<h3>1. <code>hide()<\/code> \u4e4b\u540e\u5fc5\u987b <code>keepState()<\/code><\/h3>\n<p>\u8fd9\u662f\u6700\u5bb9\u6613\u88ab\u5ffd\u7565\u3001\u4e5f\u6700\u5bb9\u6613\u8868\u73b0\u4e3a&#8221;\u65f6\u7075\u65f6\u4e0d\u7075&#8221;\u7684\u4e00\u70b9\u3002UIExtension \u4f1a\u5728\u6587\u6863\u6253\u5f00\u3001\u6743\u9650\u53d8\u66f4\u3001\u89c6\u56fe\u5207\u6362\u7b49\u65f6\u673a\uff0c\u6309\u7167\u5185\u7f6e\u903b\u8f91\u91cd\u65b0\u8ba1\u7b97\u5e76\u663e\u793a\u7ec4\u4ef6\u3002\u53ea\u8c03\u7528 <code>hide()<\/code> \u800c\u4e0d\u9501\u5b9a\uff0c\u6309\u94ae\u5f80\u5f80\u5728\u6362\u4e00\u4efd\u6587\u6863\u540e\u5c31\u81ea\u5df1\u5192\u51fa\u6765\u4e86\u3002<\/p>\n<p><code>keepState()<\/code> \u7684\u4f5c\u7528\u6b63\u662f\u628a\u53ef\u89c1\u6027\u72b6\u6001\u7684\u63a7\u5236\u6743\u4ece SDK \u624b\u4e2d\u63a5\u7ba1\u8fc7\u6765\u3002<\/p>\n<h3>2. \u7981\u7528\u72b6\u6001\u9700\u8981\u5728\u6bcf\u6b21\u6253\u5f00\u6587\u6863\u540e\u91cd\u65b0\u65bd\u52a0<\/h3>\n<p><code>keepState()<\/code> \u76ee\u524d\u53ea\u7ba1\u7406<strong>\u53ef\u89c1\u6027<\/strong>\uff08<code>KeepStateKind.VISIBILITY<\/code>\uff09\uff0c\u4e0d\u8986\u76d6\u7981\u7528\u72b6\u6001\u3002\u56e0\u6b64\u5728\u5207\u6362\u6587\u6863\u540e\uff0c<code>disable()<\/code> \u7684\u6548\u679c\u53ef\u80fd\u4e22\u5931\u3002\u7b2c\u56db\u8282\u793a\u4f8b\u4ee3\u7801\u5728 <code>openFileSuccess<\/code> \u4e2d\u91cd\u590d\u6267\u884c\u7b56\u7565\uff0c\u5c31\u662f\u4e3a\u6b64\u3002<\/p>\n<h3>3. \u6269\u5c55\u6a21\u5757\u63d0\u4f9b\u7684\u6309\u94ae\u8981\u7b49\u6a21\u5757\u52a0\u8f7d\u5b8c<\/h3>\n<p><code>print-button<\/code> \u7531 print \u6269\u5c55\u6a21\u5757\uff08addon\uff09\u63d0\u4f9b\uff0c\u5e76\u975e\u6838\u5fc3 UI \u7684\u4e00\u90e8\u5206\u3002\u793a\u4f8b\u5de5\u7a0b\u4e00\u6b21\u6027\u52a0\u8f7d\u5168\u90e8\u6269\u5c55\u6a21\u5757\uff0c\u8fd9\u7c7b\u7ec4\u4ef6\u7684\u51fa\u73b0\u65f6\u673a\u665a\u4e8e\u6838\u5fc3\u7ec4\u4ef6\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u4ee3\u7801\u4e2d\u9664\u4e86 <code>getRootComponent()<\/code>\uff0c\u8fd8\u8981\u5728 <code>openFileSuccess<\/code> \u91cc\u518d\u8dd1\u4e00\u6b21\u2014\u2014\u5982\u679c\u53ea\u67e5\u4e00\u6b21\uff0c\u5f88\u53ef\u80fd\u62ff\u5230 <code>undefined<\/code>\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u793a\u4f8b\u5de5\u7a0b\u91c7\u7528\u7684\u662f\u6269\u5c55\u6a21\u5757\u6574\u5305\u52a0\u8f7d\u7684\u65b9\u5f0f\uff0c<strong>\u65e0\u6cd5\u5728\u914d\u7f6e\u5c42\u9762\u5355\u72ec\u5254\u9664\u67d0\u4e2a\u6a21\u5757<\/strong>\u3002\u5982\u679c\u786e\u5b9e\u9700\u8981\u5728\u529f\u80fd\u5c42\u9762\u88c1\u6389\u67d0\u9879\u80fd\u529b\uff08\u800c\u4e0d\u53ea\u662f\u754c\u9762\u9690\u85cf\uff09\uff0c\u5efa\u8bae\u8054\u7cfb\u798f\u6615\u6280\u672f\u652f\u6301\u8bc4\u4f30\u5b9a\u5236\u65b9\u6848\u3002<\/p>\n<h3>4. \u524d\u7aef\u9690\u85cf\u4e0d\u7b49\u4e8e\u5b89\u5168\uff08\u91cd\u8981\uff09<\/h3>\n<p>\u754c\u9762\u4e0a\u9690\u85cf\u4e0b\u8f7d\u6309\u94ae\uff0c\u53ea\u662f UI \u5c42\u7684\u906e\u6321\u3002\u4ee5 <code>complete_webViewer<\/code> \u9ed8\u8ba4\u7684 <code>openPDFByHttpRangeRequest<\/code> \u52a0\u8f7d\u65b9\u5f0f\u4e3a\u4f8b\uff0c\u5206\u7247\u8bf7\u6c42\u7684 URL \u5728\u6d4f\u89c8\u5668\u7f51\u7edc\u9762\u677f\u4e2d\u4f9d\u7136\u53ef\u89c1\uff0c\u6709\u6280\u672f\u624b\u6bb5\u53ef\u4ee5\u76f4\u63a5\u8fd8\u539f\u51fa\u539f\u59cb\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5982\u679c\u4e1a\u52a1\u76ee\u6807\u662f\u9632\u6b62\u6587\u4ef6\u5916\u6cc4\uff0c\u5fc5\u987b\u5728\u670d\u52a1\u7aef\u89e3\u51b3<\/strong>\uff1a\u4e0d\u8fd4\u56de\u539f\u59cb\u6587\u4ef6\u6d41\uff0c\u6539\u4e3a\u670d\u52a1\u7aef\u6e32\u67d3\u540e\u4e0b\u53d1\u56fe\u7247\u6216\u81ea\u7ed8\u5185\u5bb9\uff1b\u6216\u8005\u5728\u7f51\u5173\u5c42\u505a\u9274\u6743\u4e0e\u9891\u63a7\u3002\u524d\u7aef\u9690\u85cf\u53ea\u80fd\u9632&#8221;\u8bef\u89e6&#8221;\uff0c\u4e0d\u80fd\u9632&#8221;\u6709\u610f\u83b7\u53d6&#8221;\u3002<\/p>\n<h3>5. \u6309\u6587\u6863\u6743\u9650\u81ea\u52a8\u63a7\u5236<\/h3>\n<p>\u5982\u679c PDF \u672c\u8eab\u5e26\u6709\u6743\u9650\u9650\u5236\uff08\u5982\u7981\u6b62\u6253\u5370\u3001\u7981\u6b62\u590d\u5236\uff09\uff0cSDK \u4f1a\u81ea\u52a8\u628a\u5bf9\u5e94\u6309\u94ae\u7f6e\u7070\uff0c\u8fd9\u4e00\u5c42\u65e0\u9700\u989d\u5916\u4ee3\u7801\u3002<\/p>\n<p>\u9700\u8981\u8986\u76d6\u6743\u9650\u8ba1\u7b97\u903b\u8f91\u65f6\uff0c\u53ef\u5728\u6784\u9020 <code>PDFUI<\/code> \u65f6\u901a\u8fc7 <code>viewerOptions.customs.getDocPermissions<\/code> \u81ea\u5b9a\u4e49\u6743\u9650\u8fd4\u56de\u503c\u2014\u2014<code>complete_webViewer<\/code> \u793a\u4f8b\u5de5\u7a0b\u4e2d\u5df2\u9884\u7559\u4e86\u8fd9\u6bb5\u914d\u7f6e\uff08\u9ed8\u8ba4\u5904\u4e8e\u6ce8\u91ca\u72b6\u6001\uff0c\u53d6\u6d88\u6ce8\u91ca\u5373\u53ef\u542f\u7528\uff09\u3002\u5177\u4f53\u7b7e\u540d\u4e0e\u8fd4\u56de\u503c\u542b\u4e49\u8bf7\u4ee5\u6240\u7528\u7248\u672c\u7684\u5b98\u65b9\u6587\u6863\u4e0e\u793a\u4f8b\u5de5\u7a0b\u4e3a\u51c6\u3002<\/p>\n<h2>\u4e03\u3001\u5982\u4f55\u81ea\u884c\u67e5\u627e\u4efb\u610f\u6309\u94ae\u7684\u7ec4\u4ef6\u540d<\/h2>\n<p>\u4e0a\u8868\u53ea\u8986\u76d6\u4e86\u5e38\u89c1\u7684\u51e0\u4e2a\u3002\u9879\u76ee\u4e2d\u8981\u63a7\u5236\u5176\u4ed6\u6309\u94ae\u65f6\uff0c\u53ef\u7528\u4ee5\u4e0b\u65b9\u6cd5\u5b9a\u4f4d\uff1a<\/p>\n<p><strong>\u65b9\u6cd5\u4e00\uff1a\u6d4f\u89c8\u5668 DevTools \u76f4\u63a5\u67e5\u770b\uff08\u6700\u76f4\u89c2\uff09<\/strong><\/p>\n<p>UIExtension \u6e32\u67d3\u5b8c\u6210\u540e\uff0c\u754c\u9762\u5143\u7d20\u4f1a\u5e26\u6709 <code>name<\/code> \u5c5e\u6027\u3002\u6253\u5f00\u6d4f\u89c8\u5668\u5f00\u53d1\u8005\u5de5\u5177\uff0c\u5728\u63a7\u5236\u53f0\u6267\u884c\uff1a<\/p>\n<pre><code>document.querySelectorAll('button[name]')   \/\/ \u5217\u51fa\u6240\u6709\u5e26 name \u7684\u6309\u94ae<\/code><\/pre>\n<p>\u914d\u5408\u754c\u9762\u4e0a\u7684\u56fe\u6807\u6216\u60ac\u6d6e\u63d0\u793a\u6587\u672c\uff0c\u5373\u53ef\u786e\u8ba4\u6309\u94ae\u4e0e\u7ec4\u4ef6\u540d\u7684\u5bf9\u5e94\u5173\u7cfb\u3002<\/p>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u8fd0\u884c\u65f6\u9a8c\u8bc1<\/strong><\/p>\n<p>\u62ff\u5230\u5019\u9009\u540d\u79f0\u540e\uff0c\u5148\u5728\u63a7\u5236\u53f0\u786e\u8ba4\u7ec4\u4ef6\u786e\u5b9e\u5b58\u5728\uff1a<\/p>\n<pre><code>pdfui.getComponentByName('download-file-button').then(c =&gt; console.log(c));<\/code><\/pre>\n<p>\u8fd4\u56de\u7ec4\u4ef6\u5bf9\u8c61\u8bf4\u660e\u540d\u79f0\u6b63\u786e\uff1b\u8fd4\u56de <code>undefined<\/code> \u8bf4\u660e\u540d\u79f0\u6709\u8bef\uff0c\u6216\u8be5\u7ec4\u4ef6\u5c1a\u672a\u52a0\u8f7d\u5b8c\u6210\uff08\u53c2\u89c1\u7b2c\u516d\u8282\u7b2c 3 \u70b9\uff09\u3002<\/p>\n<p><strong>\u65b9\u6cd5\u4e09\uff1a\u67e5\u9605\u5b98\u65b9\u6587\u6863\u6216\u54a8\u8be2\u798f\u6615\u6280\u672f\u652f\u6301<\/strong><\/p>\n<p>\u7ec4\u4ef6\u540d\u5c5e\u4e8e UI \u5c42\u7684\u5b9e\u73b0\u7ec6\u8282\uff0c\u5e76\u672a\u5728 API \u53c2\u8003\u4e2d\u9010\u4e00\u7a77\u4e3e\u3002\u82e5\u9700\u8981\u63a7\u5236\u7684\u6309\u94ae\u8f83\u591a\u3001\u6216\u6d89\u53ca\u53f3\u952e\u83dc\u5355\u3001\u4fa7\u8fb9\u680f\u7b49\u590d\u5408\u7ec4\u4ef6\uff0c\u5efa\u8bae\u76f4\u63a5\u8054\u7cfb\u798f\u6615\u6280\u672f\u652f\u6301\u83b7\u53d6\u5bf9\u5e94\u7248\u672c\u7684\u7ec4\u4ef6\u6e05\u5355\uff0c\u907f\u514d\u9010\u4e2a\u8bd5\u9519\u3002<\/p>\n<h2>\u516b\u3001\u5c0f\u7ed3<\/h2>\n<p>\u63a7\u5236 UIExtension \u529f\u80fd\u6309\u94ae\u7684\u6838\u5fc3\u662f\u4e09\u6b65\uff1a<strong>\u627e\u51c6\u7ec4\u4ef6\u540d \u2192 \u7528 <code>hide()<\/code>\/<code>disable()<\/code> \u65bd\u52a0\u7b56\u7565 \u2192 \u7528 <code>keepState()<\/code> \u9501\u5b9a\u5e76\u5728\u6bcf\u6b21\u6253\u5f00\u6587\u6863\u540e\u91cd\u65b0\u65bd\u52a0<\/strong>\u3002\u6574\u4e2a\u94fe\u8def\u5168\u90e8\u8d70\u5b98\u65b9\u7ec4\u4ef6 API\uff0c\u4e0d\u4f9d\u8d56\u4efb\u4f55\u754c\u9762\u7ed3\u6784\u7684\u4e34\u65f6\u6539\u52a8\uff0c\u5347\u7ea7 SDK \u65f6\u7684\u517c\u5bb9\u6027\u98ce\u9669\u6700\u4f4e\u3002<\/p>\n<p>\u754c\u9762\u5c42\u9762\u7684\u63a7\u5236\u5230\u6b64\u4e3a\u6b62\uff1b\u6d89\u53ca\u6587\u4ef6\u5b89\u5168\u7684\u8bc9\u6c42\uff0c\u8bf7\u52a1\u5fc5\u56de\u5230\u670d\u52a1\u7aef\u65b9\u6848\u4e0a\u89e3\u51b3\u3002<\/p>\n<p><strong>\u4fe1\u606f\u6765\u6e90<\/strong>\uff1a\u672c\u6587\u63a5\u53e3\u6e05\u5355\u53d6\u81ea Foxit PDF SDK for Web 11.1 JavaScript API \u53c2\u8003\uff1b\u7ec4\u4ef6\u540d\u4f9d\u636e 11.1 \u7248\u672c\u7ec4\u4ef6\u5b9a\u4e49\u6574\u7406\uff1b<code>keepState<\/code> \u7cfb\u5217\u7528\u6cd5\u53c2\u8003\u798f\u6615\u5b98\u65b9\u77e5\u8bc6\u5e93\uff08support.fuxinsoft.cn\uff09\u3002\u63a5\u53e3\u7b7e\u540d\u4e0e\u7ec4\u4ef6\u540d\u7684\u7ec6\u8282\u4ee5\u6240\u7528\u7248\u672c\u7684\u5b98\u65b9\u6587\u6863\u4e3a\u51c6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9002\u7528\u7248\u672c\uff1aFoxit PDF SDK for Web 11.1 \uff5c \u9002\u7528\u793a\u4f8b\uff1aexamples\/UIExten [&hellip;]<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67],"tags":[1105,935,1047,375,1065],"class_list":["post-9421","post","type-post","status-publish","format-standard","hentry","category-websdk","tag-keepstate","tag-uiextension","tag-1047","tag-375","tag-1065"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","_links":{"self":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/9421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9421"}],"version-history":[{"count":6,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/9421\/revisions"}],"predecessor-version":[{"id":9427,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/9421\/revisions\/9427"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}