{"id":5832,"date":"2025-06-24T14:28:40","date_gmt":"2025-06-24T06:28:40","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=5832"},"modified":"2025-06-27T13:06:52","modified_gmt":"2025-06-27T05:06:52","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e6%9d%83%e9%99%90%e5%8f%97%e9%99%90%e7%9a%84pdf%e6%96%87%e6%a1%a3%e4%b8%ad%e5%ae%9e%e7%8e%b0%e6%b0%b4%e5%8d%b0%e6%8f%92%e5%85%a5%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=5832","title":{"rendered":"\u5982\u4f55\u5728\u6743\u9650\u53d7\u9650\u7684PDF\u6587\u6863\u4e2d\u5b9e\u73b0\u6c34\u5370\u63d2\u5165\uff1f"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"5832\" class=\"elementor elementor-5832\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-32896b7 e-flex e-con-boxed e-con e-parent\" data-id=\"32896b7\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-861b2ab elementor-widget elementor-widget-text-editor\" data-id=\"861b2ab\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p class=\"ds-markdown-paragraph\">WebSDK\u76ee\u524d\u63d0\u4f9b\u4e24\u79cd\u6c34\u5370\u5b9e\u73b0\u65b9\u6848\uff1a\u6e32\u67d3\u5c42\u6c34\u5370\uff08View-layer Watermark\uff09\u548c\u6587\u6863\u5c42\u6c34\u5370\uff08Document-layer Watermark\uff09\u3002<\/p><p class=\"ds-markdown-paragraph\">\u6e32\u67d3\u5c42\u6c34\u5370\u91c7\u7528\u524d\u7aef\u6e32\u67d3\u6280\u672f\u5b9e\u73b0\uff0c\u4ec5\u4f5c\u7528\u4e8e\u89c6\u56fe\u5c42\u663e\u793a\uff0c\u4e0d\u4f1a\u4fee\u6539\u539f\u59cb\u6587\u6863\u5185\u5bb9\u3002\u8be5\u65b9\u6848\u9002\u7528\u4e8e\u6587\u6863\u9605\u8bfb\u573a\u666f\u7684\u6c34\u5370\u5c55\u793a\u9700\u6c42\uff0c\u5177\u6709\u975e\u4fb5\u5165\u5f0f\u7279\u70b9\u3002\u7cfb\u7edf\u652f\u6301\u7075\u6d3b\u914d\u7f6e\u6c34\u5370\u4f4d\u7f6e\uff0c\u53ef\u5b9e\u73b0\u5355\u4f4d\u7f6e\u6216\u591a\u4f4d\u7f6e\u540c\u65f6\u53e0\u52a0\u7684\u6c34\u5370\u6548\u679c\u3002<\/p><p>\u6587\u6863\u5c42\u6c34\u5370\u901a\u8fc7\u76f4\u63a5\u4fee\u6539PDF\u6587\u6863\u5143\u6570\u636e\u5b9e\u73b0\uff0c\u5c06\u6c34\u5370\u4fe1\u606f\u6c38\u4e45\u5199\u5165\u6307\u5b9a\u9875\u9762\u3002\u8be5\u65b9\u6848\u9002\u7528\u4e8e\u6587\u6863\u5206\u53d1\u63a7\u5236\u573a\u666f\uff0c\u4e0b\u8f7d\u540e\u7684\u6587\u6863\u4ecd\u4fdd\u7559\u6c34\u5370\u4fe1\u606f\u3002\u6c34\u5370\u6570\u636e\u4f1a\u6301\u4e45\u5316\u5b58\u50a8\u5728PDF\u6587\u4ef6\u7ed3\u6784\u4e2d\u3002<\/p><hr \/><p class=\"ds-markdown-paragraph\">\u5728\u6807\u51c6PDF\u6587\u6863\u5904\u7406\u573a\u666f\u4e2d\uff0cWebSDK\u652f\u6301\u540c\u65f6\u6216\u5355\u72ec\u4f7f\u7528\u4e24\u79cd\u6c34\u5370\u65b9\u6848\u3002\u7cfb\u7edf\u63d0\u4f9b\u5b8c\u6574\u7684API\u63a5\u53e3\u7528\u4e8e\u63d2\u5165\u81ea\u5b9a\u4e49\u6587\u6863\u6c34\u5370\uff08\u6280\u672f\u6587\u6863\u53c2\u89c1\uff1a<a href=\"https:\/\/support.fuxinsoft.cn\/?p\/4918\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/support.fuxinsoft.cn\/?p\/4918<\/a>\uff09\u3002\u4f46\u9700\u6ce8\u610f\uff0c\u5f53PDF\u6587\u6863\u7ecf\u8fc7\u6570\u5b57\u7b7e\u540d\u6216\u52a0\u5bc6\u5904\u7406\u5bfc\u81f4\u7f16\u8f91\u6743\u9650\u53d7\u9650\u65f6\uff0c\u6587\u6863\u5c42\u6c34\u5370\u63a5\u53e3\u5c06\u65e0\u6cd5\u6b63\u5e38\u6267\u884c\u3002\u6b64\u65f6\u5efa\u8bae\u91c7\u7528\u6e32\u67d3\u5c42\u6c34\u5370\u65b9\u6848\uff0c\u8be5\u6280\u672f\u901a\u8fc7PDF\u6e32\u67d3\u5f15\u64ce\u5728\u89c6\u56fe\u5c42\u53e0\u52a0\u6c34\u5370\u5143\u7d20\uff0c\u4e0d\u6d89\u53caPDF\u6587\u6863\u5bf9\u8c61\u7684\u76f4\u63a5\u4fee\u6539\uff0c\u56e0\u6b64\u4e0d\u53d7\u6587\u6863\u52a0\u5bc6\u72b6\u6001\u7684\u9650\u5236\u3002<\/p><p>\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-86d46f7 e-con-full e-flex e-con e-parent\" data-id=\"86d46f7\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-5d1244c elementor-widget elementor-widget-code-highlight\" data-id=\"5d1244c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>function getFormatDateWithSep(date, separator) {\r\n    const year = date.getFullYear();\r\n    const month = (date.getMonth() + 1).toString().padStart(2, '0');\r\n    const day = date.getDate().toString().padStart(2, '0');\r\n    return `${year}${separator}${month}${separator}${day}`;\r\n}\r\n\r\n\/\/ \u6e32\u67d3\u6c34\u5370 \u4e4b \u4e5d\u5bab\u683c\u6c34\u5370\r\nfunction addRenderWaterMark() {\r\n    \/\/ \u5b9a\u4e49\u6c34\u5370\u914d\u7f6e\u7684\u901a\u7528\u90e8\u5206\r\n    const commonConfig = {\r\n        type: \"text\",\r\n        content: `212999\/\u674e\u767d\\n${getFormatDateWithSep(new Date(), '\/')}`,\r\n        pageStart: 0,\r\n        pageEnd: 5,\r\n        watermarkSettings: {\r\n            offsetX: 0,\r\n            offsetY: 0,\r\n            scaleX: 1,\r\n            scaleY: 1,\r\n            rotation: 45,\r\n            opacity: 80\r\n        },\r\n        watermarkTextProperties: {\r\n            font: \"SimSun\",\r\n            fontSize: 50,\r\n            color: \"#ff0000\",\r\n            fontStyle: \"normal\",\r\n            lineSpace: 20,\r\n            alignment: \"center\"\r\n        }\r\n    };\r\n\r\n    \/\/ \u5b9a\u4e49\u4e5d\u5bab\u683c\u7684\u4f4d\u7f6e\r\n    const positions = [\r\n        \"TopLeft\",\r\n        \"TopCenter\",\r\n        \"TopRight\",\r\n        \"CenterLeft\",\r\n        \"Center\",\r\n        \"CenterRight\",\r\n        \"BottomLeft\",\r\n        \"BottomCenter\",\r\n        \"BottomRight\"\r\n    ];\r\n\r\n    \/\/ \u751f\u6210\u4e5d\u5bab\u683c\u6c34\u5370\u914d\u7f6e\u6570\u7ec4\r\n    const watermarkConfigs = positions.map(position =&gt; {\r\n        return {\r\n            ...commonConfig,\r\n            watermarkSettings: {\r\n                ...commonConfig.watermarkSettings,\r\n                position\r\n            }\r\n        };\r\n    });\r\n\r\n    pdfui.getPDFDocRender().then((docRender) =&gt; {\r\n        \/\/ \u8bbe\u7f6e\u6c34\u5370\u914d\u7f6e\r\n        docRender.setWatermarkConfig(watermarkConfigs);\r\n    });\r\n\r\n    \/\/ \u91cd\u7ed8 PDF\u89c6\u56fe\r\n    pdfui.redraw(true);\r\n}\r\n\r\n\/\/\u8981\u5728\u6587\u6863\u6253\u5f00\u6210\u529f\u6216\u6e32\u67d3\u6210\u529f\u7684\u76d1\u542c\u4e8b\u4ef6\u56de\u8c03\u51fd\u6570\u4e2d\u53bb\u6267\u884c \u63d2\u5165\u6e32\u67d3\u6c34\u5370\u7684\u64cd\u4f5c\r\npdfui.addViewerEventListener(Events.openFileSuccess, function () {\r\n    openFileError = null\r\n    loadingComponentPromise.then(function (component) {\r\n        component.close();\r\n    });\r\n    console.log(\"openFileSuccess\");\r\n    addRenderWaterMark();\r\n});<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>WebSDK\u76ee\u524d\u63d0\u4f9b\u4e24\u79cd\u6c34\u5370\u5b9e\u73b0\u65b9\u6848\uff1a\u6e32\u67d3\u5c42\u6c34\u5370\uff08View-layer Watermark\uff09\u548c\u6587\u6863\u5c42\u6c34\u5370\uff08Do [&hellip;]<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67],"tags":[756,755,754,316,191,752,619,753,751],"class_list":["post-5832","post","type-post","status-publish","format-standard","hentry","category-websdk","tag-pdfviewer","tag-755","tag-754","tag-316","tag-191","tag-752","tag-619","tag-753","tag-751"],"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\/5832","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=5832"}],"version-history":[{"count":16,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/5832\/revisions"}],"predecessor-version":[{"id":5851,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/5832\/revisions\/5851"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}