{"id":7140,"date":"2025-11-04T11:54:23","date_gmt":"2025-11-04T03:54:23","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=7140"},"modified":"2025-11-10T14:25:21","modified_gmt":"2025-11-10T06:25:21","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e6%b3%a8%e9%87%8a%e4%b8%ad%e7%9a%84%e5%af%8c%e6%96%87%e6%9c%ac%e6%a0%bc%e5%bc%8f%e8%ae%be%e7%bd%ae%e4%b8%ba%e9%bb%98%e8%ae%a4%e6%a0%bc%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=7140","title":{"rendered":"\u5982\u4f55\u5c06\u6ce8\u91ca\u4e2d\u7684\u5bcc\u6587\u672c\u683c\u5f0f\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u683c\u5f0f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728PDF\u6587\u6863\u5904\u7406\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u7edf\u4e00\u6ce8\u91ca\u7684\u663e\u793a\u6837\u5f0f\u3002\u867d\u7136\u6ce8\u91ca\u53f3\u952e\u83dc\u5355\u4e2d\u63d0\u4f9b\u4e86&#8221;\u8bbe\u7f6e\u5f53\u524d\u5c5e\u6027\u4e3a\u9ed8\u8ba4&#8221;\u529f\u80fd\uff0c\u4f46\u5bf9\u4e8e\u63a5\u53e3\u8bbe\u7f6e\u7684\u5bcc\u6587\u672c\u683c\u5f0f\uff0c\u6b64\u529f\u80fd\u53ef\u80fd\u65e0\u6cd5\u751f\u6548\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u5c06\u5f53\u524d\u5bcc\u6587\u672c\u683c\u5f0f\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u683c\u5f0f\u7684\u5b8c\u6574\u65b9\u6848\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5b9e\u73b0\u6b65\u9aa4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. \u6269\u5c55\u6ce8\u91ca\u53f3\u952e\u83dc\u5355<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728pdfui\u6784\u9020\u51fd\u6570\u7684\u5916\u89c2\u53c2\u6570\u4e2d\uff0c\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a&#8221;\u8bbe\u7f6e\u5f53\u524d\u5bcc\u6587\u672c\u4e3a\u9ed8\u8ba4&#8221;\u7684\u65b0\u83dc\u5355\u9879\u3002\u8fd9\u4e00\u6269\u5c55\u5c06\u589e\u5f3a\u53f3\u952e\u83dc\u5355\u7684\u529f\u80fd\u6027\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u76f4\u89c2\u7684\u683c\u5f0f\u8bbe\u7f6e\u9009\u9879\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>appearance: UIExtension.appearances.AdaptiveAppearance.extend({\n                getDefaultFragments: function () {\n                    \/\/ \u5b9a\u4e49\u9700\u8981\u79fb\u9664\u201c\u5c45\u4e2d\u201d\u9879\u7684\u6ce8\u91ca\u7c7b\u578b\u5217\u8868\n                    const annotTypes = &#091;\n                        'typewriter',  'callout', 'textbox',\n                    ];\n                    \n                    const fragments = &#091;];\n                    annotTypes.forEach(type =&gt; {\n                        \/\/ \u4f7f\u7528\u5b57\u7b26\u4e32\u62fc\u63a5\u800c\u4e0d\u662f\u6a21\u677f\u5b57\u7b26\u4e32\u8bed\u6cd5\n                        fragments.push({\n                            target: 'fv--' + type + '-contextmenu',\n                            action: UIExtension.UIConsts.FRAGMENT_ACTION.APPEND,\n                            template: `\n                                &lt;contextmenu-item name=\"x-user-custom-contextmenu-item\"&gt;\u8bbe\u7f6e\u5f53\u524d\u5bcc\u6587\u672c\u5c5e\u6027\u4e3a\u9ed8\u8ba4&lt;\/contextmenu-item&gt;\n                            `,\n                            config: &#091;{\n                                target: 'x-user-custom-contextmenu-item',\n                                callback: setDefaultRichTextProperty\n                            }]\n                        });\n                    });\n                    return fragments;\n                }\n            }),<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. \u5efa\u7acb\u72b6\u6001\u8ddf\u8e2a\u673a\u5236<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b9a\u4e49\u5168\u5c40\u53d8\u91cf\u6765\u51c6\u786e\u8bb0\u5f55\u4e24\u4e2a\u5173\u952e\u72b6\u6001\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7528\u6237\u662f\u5426\u9009\u62e9\u4e86&#8221;\u8bbe\u7f6e\u5f53\u524d\u5bcc\u6587\u672c\u4e3a\u9ed8\u8ba4&#8221;\u9009\u9879<\/li>\n\n\n\n<li>\u5f53\u524d\u8bbe\u5b9a\u7684\u9ed8\u8ba4\u5bcc\u6587\u672c\u683c\u5f0f\u5185\u5bb9<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u5168\u5c40\u53d8\u91cf\u8bb0\u5f55\u662f\u5426\u8bbe\u7f6e\u5f53\u524d\u5c5e\u6027\u4e3a\u9ed8\u8ba4\uff0c\u5e76\u4e14\u8bb0\u5f55\u5f53\u524d\u5bcc\u6587\u672c\u683c\u5f0f\u3002\n        var isDefaultRichTextProperty = false;\n        var richTextStyle\n        \n        async function setDefaultRichTextProperty() {\n            \/\/ \u83b7\u53d6\u5f53\u524d\u6ce8\u91ca\u7684\u7ec4\u4ef6\u5bf9\u8c61            \n            console.log(this)\n            const currentAnnotComponent = this.component.parent.currentTarget;\n            if (currentAnnotComponent) {\n                \/\/ \u83b7\u53d6\u5e95\u5c42\u7684\u6ce8\u91ca\u5bf9\u8c61\n                const annot = currentAnnotComponent.annot;\n                \/\/ \u83b7\u53d6\u6ce8\u91ca\u4fe1\u606f\n                const annotInfo = annot.getInfo();\n                if(annotInfo.richText.length &gt; 0)\n                {\n                    richTextStyle = annotInfo.richText&#091;0].richTextStyle\n                }\n                \/\/ \u60a8\u53ef\u4ee5\u5728\u6b64\u5904\u4f7f\u7528\u83b7\u53d6\u5230\u7684\u5c5e\u6027\uff0c\u4f8b\u5982\u6253\u5370\u5230\u63a7\u5236\u53f0\u6216\u8fdb\u884c\u5176\u4ed6\u64cd\u4f5c\n                console.log('\u6ce8\u91ca:', annotInfo);\n            }\n            isDefaultRichTextProperty = !isDefaultRichTextProperty;\n            console.log(isDefaultRichTextProperty)\n        }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. \u5728annotationUpdated\u76d1\u542c\u4e8b\u4ef6\u4e2d\uff0c\u52a0\u5165\u4e4b\u6076\u80fd\u5224\u65ad\u903b\u8f91\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u68c0\u6d4b\u7528\u6237\u662f\u5426\u5df2\u6fc0\u6d3b&#8221;\u8bbe\u7f6e\u5f53\u524d\u5bcc\u6587\u672c\u4e3a\u9ed8\u8ba4&#8221;\u9009\u9879<\/li>\n\n\n\n<li>\u5f53\u6ce8\u91ca\u5185\u5bb9\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u81ea\u52a8\u5c06\u5168\u5c40\u53d8\u91cf\u4e2d\u5b58\u50a8\u7684\u9ed8\u8ba4\u5bcc\u6587\u672c\u683c\u5f0f\u5e94\u7528\u5230\u5f53\u524d\u6ce8\u91ca<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>pdfui.eventEmitter.on(PDF.constant.DataEvents.annotationUpdated, (annots, PDFPage, AnnotUpdatedType)  =&gt;\n        {\n            \/\/\u5224\u65ad\u662f\u5426\u662f\u8bb0\u5f55\u5bcc\u6587\u672c\u683c\u5f0f\u7684\u6ce8\u91ca\n            if(isDefaultRichTextProperty == true &amp;&amp; richTextStyle)\n            {\n                annots.forEach(async annot =&gt;{\n                    let info = annot.getInfo()\n                    console.log(info)\n                    console.log(AnnotUpdatedType)\n                    if(AnnotUpdatedType === 'content-updated' &amp;&amp;  info.richText.length === 0 )\n                    {\n                        annot.setContent('');\n                        await annot.addRichText(&#091;{\n                            content: info.content ? info.content : '\\u200C',\n                            richTextStyle: {\n                                font: {\n                                            name: richTextStyle.fontName,\n                                        },\n                                textSize: richTextStyle.textSize,\n                                textAlignment: richTextStyle.textAlignment,\n                                textColor: richTextStyle.textColor,\n                                isBold: richTextStyle.isBold,\n                                isItalic: richTextStyle.isItalic,\n                                isUnderline: richTextStyle.isUnderline,\n                                isStrikethrough: richTextStyle.isStrikethrough,\n                                cornerMarkStyle: richTextStyle.cornerMarkStyle,\n                            }\n                        }]);\n                    }\n                })       \n            }\n        })<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"599\" height=\"534\" src=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/10\/image-21.png\" alt=\"\" class=\"wp-image-7146\" style=\"width:800px;height:auto\" srcset=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/10\/image-21.png 599w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/10\/image-21-300x267.png 300w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u8fd9\u4e00\u6d41\u7a0b\uff0c\u6211\u4eec\u53ef\u4ee5\u6709\u6548\u89e3\u51b3\u63a5\u53e3\u8bbe\u7f6e\u7684\u5bcc\u6587\u672c\u683c\u5f0f\u65e0\u6cd5\u901a\u8fc7\u5e38\u89c4\u65b9\u6cd5\u8bbe\u4e3a\u9ed8\u8ba4\u7684\u95ee\u9898\uff0c\u786e\u4fdd\u6587\u6863\u4e2d\u6240\u6709\u6ce8\u91ca\u4fdd\u6301\u7edf\u4e00\u7684\u5bcc\u6587\u672c\u6837\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728PDF\u6587\u6863\u5904\u7406\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u7edf\u4e00\u6ce8\u91ca\u7684\u663e\u793a\u6837\u5f0f\u3002\u867d\u7136\u6ce8\u91ca\u53f3\u952e\u83dc\u5355\u4e2d\u63d0\u4f9b\u4e86&#8221;\u8bbe\u7f6e\u5f53\u524d\u5c5e\u6027\u4e3a\u9ed8\u8ba4&#038; [&hellip;]<\/p>\n","protected":false},"author":33,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67],"tags":[750,1174,374,1176,1177,1178,1175],"class_list":["post-7140","post","type-post","status-publish","format-standard","hentry","category-websdk","tag-750","tag-1174","tag-374","tag-1176","tag-1177","tag-1178","tag-1175"],"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\/7140","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\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7140"}],"version-history":[{"count":7,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7140\/revisions"}],"predecessor-version":[{"id":7186,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7140\/revisions\/7186"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}