{"id":5338,"date":"2025-05-21T13:47:30","date_gmt":"2025-05-21T05:47:30","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=5338"},"modified":"2025-05-21T17:02:48","modified_gmt":"2025-05-21T09:02:48","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8websdk%e6%b7%bb%e5%8a%a0%e8%87%aa%e5%ae%9a%e4%b9%89%e5%ad%97%e4%bd%93","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=5338","title":{"rendered":"\u5982\u4f55\u5728WebSDK\u6dfb\u52a0\u81ea\u5b9a\u4e49\u5b57\u4f53"},"content":{"rendered":"\n<p>Foxit PDF SDK for Web\uff08\u7b80\u79f0WebSDK\uff09\u9ed8\u8ba4\u4f7f\u7528\u5f00\u6e90\u5b57\u4f53\u5e76\u8bbe\u7f6e\u4e86\u76f8\u5e94\u7684\u5b57\u4f53\u5339\u914d\u89c4\u5219\u3002\u5f53\u6587\u6863\u4e2d\u5305\u542bWebSDK\u672a\u6620\u5c04\u7684\u7279\u5b9a\u5b57\u4f53\u65f6\uff0c\u53ef\u80fd\u5bfc\u81f4\u5185\u5bb9\u663e\u793a\u5f02\u5e38\u6216\u663e\u793a\u6548\u679c\u4e0d\u7b26\u5408\u9884\u671f\u3002\u4e3a\u89e3\u51b3\u6b64\u95ee\u9898\uff0cWebSDK\u63d0\u4f9b\u4e86\u81ea\u5b9a\u4e49\u5b57\u4f53\u6620\u5c04\u63a5\u53e3\uff0c\u5141\u8bb8\u7528\u6237\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\u5b57\u4f53\u66ff\u6362\u548cUI\u5b57\u4f53\u5217\u8868\u4fee\u6539\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u793a\u4f8b\u76ee\u5f55\uff1aexamples\/UIExtension\/custom-font\/<\/code><\/pre>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\"><\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">\u751f\u6210\u5b57\u4f53\u4fe1\u606fcsv\u6587\u4ef6<\/li>\n<\/ul>\n\n\n\n<p>\u9996\u5148\uff0c\u628a\u81ea\u5b9a\u4e49\u7684\u5b57\u4f53\u6587\u4ef6\u653e\u7f6e\u5728\uff1aexternal\/brotli\/\u4e0b<\/p>\n\n\n\n<p>\u5176\u6b21\uff0c\u7528\u4e0b\u5217\u547d\u4ee4\u5728external\/brotli\/fontInfo.csv\u65b0\u589e\u81ea\u5b9a\u4e49\u5b57\u4f53\u4fe1\u606f<\/p>\n\n\n\n<p>SDK \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5b57\u4f53\u4fe1\u606f\u751f\u6210\u5de5\u5177 (\u89c1 SDK \u5305\u4e2d\u7684&nbsp;<code>\/server\/gen-font-info<\/code>&nbsp;\u6587\u4ef6\u5939)\uff0c\u7528\u4e8e\u521b\u5efa\u5b57\u4f53\u4fe1\u606f\u5217\u8868\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u5728&nbsp;<code>gen-font-info<\/code>&nbsp;\u76ee\u5f55\u4e0b\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1anode index.js &lt;input-path&gt; [output-path] [output-override=true]<br>\u4f8b\u5982\uff1anode index.js D:\\WebSDK\\external\\brotli\\CESI_FS_GB18030.ttf D:\\WebSDK\\external\\brotli\\fontInfo.csv false<\/p>\n\n\n\n<p class=\"has-small-font-size\">\u8be6\u7ec6\u8d44\u6599\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u94fe\u63a5\uff1ahttps:\/\/devdocs.fuxinsoft.cn\/development-guide\/pdf-sdk-web\/kb\/font\/generate-a-CSV-file-with-font-information.html<\/p>\n\n\n\n<p>\u6700\u540e\uff0c\u6dfb\u52a0\u5b57\u4f53\u4fe1\u606fcsv\u6587\u4ef6\u8def\u5f84\u5230\u521d\u59cb\u5316<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var readyWorker = preloadJrWorker({\n            workerPath: '..\/..\/..\/lib\/',\n            enginePath: '..\/lib\/jr-engine\/gsdk',\n            fontPath: '..\/external\/brotli',\n            \n            fontInfoPath: '..\/external\/brotli\/fontInfo.csv', \/\/ \u8bbe\u7f6e\u5b57\u4f53\u4fe1\u606f\u6587\u4ef6\u7684\u8def\u5f84\n            \n            licenseSN: licenseSN,\n            licenseKey: licenseKey\n        })<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">\u6dfb\u52a0\u5b57\u4f53\u6620\u5c04\uff0c\u6ce8\u610fpath\u8981\u66ff\u6362\u8bbe\u7f6e\u4e3a\u5b57\u4f53\u5b58\u653e\u7684\u4f4d\u7f6e\u76ee\u5f55<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>        var path = location.href.replace(\/\\\/index.html$\/, '');\/\/\u6ce8\u610f\u9700\u8981\u66ff\u6362\u4e3a\u81ea\u5b9a\u4e49\u5b57\u4f53\u6587\u4ef6\u5b58\u653e\u7684\u4f4d\u7f6e\n        var fontMaps = &#91;\n           {\n                nameMatches: &#91;\/Rage\/, \/Rage Italic\/, \/RageItalic\/],\n                glyphs: &#91;\n                    {\n                        bold: -1,\n                        flags: -1,\n                        url: path + '\/RAGE.TTF'\n                    }\n                ],\n                charsets: &#91;0]\n            },\n            {\n                nameMatches: &#91;\/CESI_FS_GB18030\/,\/CESI\u4eff\u5b8b-GB18030\/],\n                glyphs: &#91;\n                    {\n                        bold: -1,\n                        flags: -1,\n                        url: path + '\/CESI_FS_GB18030.TTF'\n                    }\n                ],\n                charsets: &#91;134]\/\/\u7b80\u4f53\u4e2d\u6587charset\u4e3a134\n            }]\n        var fontMapsInfo = &#91;\n            {\n                \"name\": \"Rage\", \/\/The font face name\n                \"style\": 0, \/\/The font styles\n                \"charset\": 0 \/\/The charset of the font\n            },{\n                 \"name\": \"CESI_FS_GB18030\", \/\/\u5b57\u4f53\u540d\u79f0\n                \"style\": 0, \n                \"charset\": 134 \/\/\u7b80\u4f53\u4e2d\u6587charset\u4e3a134\n            },\n        ]<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>pdfui.getPDFViewer().then(function (viewer) {\n            \/\/ \u81ea\u5b9a\u4e49\u5b57\u4f53\u3002\u8be5\u65b9\u6cd5\u4ec5\u5728\u52a0\u8f7d\u6587\u6863\u4e4b\u524d\u6709\u6548\u3002\n            viewer.setJRFontMap(fontMaps).then(function (_) {\n                pdfui.openPDFByHttpRangeRequest({\n                    range: {\n                        url: path + '\/test.pdf',\/\/\u6253\u5f00\u6587\u4ef6\u66ff\u6362\u4e3a\u9700\u8981\u6253\u5f00\u7684\u6587\u4ef6\n                    }\n                }, { fileName: 'test.pdf' })\/\/\u66ff\u6362\u4e3a\u9700\u8981\u6253\u5f00\u7684\u6587\u4ef6\n                \/\/ \u5c06\u6620\u5c04\u540e\u7684\u5b57\u4f53\u6dfb\u52a0\u5230\u4e0b\u62c9\u5b57\u4f53\u6846\u4e2d\n                viewer.addFontMaps(fontMapsInfo)\n                \/\/ \u73b0\u5728\u53ef\u4ee5\u9009\u62e9\u81ea\u5b9a\u4e49\u5b57\u4f53\u8fdb\u884c\u6587\u672c\u7f16\u8f91\n            })\n        })<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Foxit PDF SDK for Web\uff08\u7b80\u79f0WebSDK\uff09\u9ed8\u8ba4\u4f7f\u7528\u5f00\u6e90\u5b57\u4f53\u5e76\u8bbe\u7f6e\u4e86\u76f8\u5e94\u7684\u5b57\u4f53\u5339\u914d\u89c4\u5219\u3002\u5f53\u6587 [&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":[184,212,587,588,586,583],"class_list":["post-5338","post","type-post","status-publish","format-standard","hentry","category-websdk","tag-csv","tag-javascript","tag-587","tag-588","tag-586","tag-583"],"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\/5338","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=5338"}],"version-history":[{"count":14,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/5338\/revisions"}],"predecessor-version":[{"id":5380,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/5338\/revisions\/5380"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}