{"id":1683,"date":"2024-06-17T14:25:03","date_gmt":"2024-06-17T06:25:03","guid":{"rendered":"https:\/\/support.foxitsoftware.cn\/?p=1683"},"modified":"2024-09-13T15:51:19","modified_gmt":"2024-09-13T07:51:19","slug":"%e3%80%90foxit-pdf-sdk%e3%80%91%e4%bd%bf%e7%94%a8sdk%e7%9a%84%e5%b5%8c%e5%85%a5%e5%ad%97%e4%bd%93%e5%8a%9f%e8%83%bd%ef%bc%8c%e5%af%bc%e8%87%b4%e6%96%87%e4%bb%b6%e4%bd%93%e7%a7%af%e5%8f%98%e5%a4%a7","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=1683","title":{"rendered":"\u4f7f\u7528SDK\u7684\u5d4c\u5165\u5b57\u4f53\u529f\u80fd\uff0c\u5bfc\u81f4\u6587\u4ef6\u4f53\u79ef\u53d8\u5927\uff0c\u4e14\u5d4c\u5165\u591a\u4e2a\u5b57\u4f53\u65f6\u8017\u65f6\u8f83\u957f\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"\n<p><strong>\u95ee\u9898\u539f\u56e0\uff1a<\/strong>\u572810.0\u4e4b\u524d\u7684\u7248\u672c\u4e2d\uff0c\u5d4c\u5165\u5b57\u4f53Font::Embed ()\u63a5\u53e3\uff0c\u662f\u5d4c\u5165\u6574\u4e2a\u5b57\u4f53\u6587\u4ef6\uff0c\u5305\u542b\u6240\u6709\u5b57\u7b26\u3002\u6240\u4ee5\u4f1a\u5bfc\u81f4\u5d4c\u5165\u65f6\u8017\u65f6\u957f\uff0c\u548c\u6587\u4ef6\u4f53\u79ef\u589e\u5927\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<p><strong>\u89e3\u51b3\u529e\u6cd5\uff1a<\/strong>\u572810.0\u53ca\u4ee5\u4e0a\u7684\u7248\u672c\u4e2d\uff0cFont\u7c7b\u578b\u589e\u52a0\u4e86Font::AddUnicodes ()\u63a5\u53e3\uff0c\u652f\u6301\u6309\u7528\u6237\u6307\u5b9a\u5b57\u7b26\u6570\u7ec4\u5d4c\u5165\u5b57\u4f53\uff0cC++\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-body-font-family\"><code> PDFDoc doc;\n    doc.Load(NULL);\n    PDFPage page= doc.InsertPage(0,PDFPage::e_SizeA4);\n    page.StartParse(0, NULL, true);\n    POSITION position = page.GetLastGraphicsObjectPosition(GraphicsObject::e_TypeText);\nTextObject* text_object = TextObject::Create();\n    Font font = Font(L\"Noto Sans CJK HK\", Font::e_StylesSmallCap, Font::e_CharsetANSI, 0);\n    \/\/\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3afalse\u65f6\uff0c\u8fd4\u56de\u7684\u5d4c\u5165\u5b57\u4f53\uff0c\u5c06\u53ea\u5d4c\u5165\u6307\u5b9a\u5b57\u7b26(\u9ed8\u8ba4\u4e3atrue)\n    Font font_Embed = font.Embed(doc, false);\n    TextState state;\n    WString  wstr = L\"foxitsoftware\";\n    UInt32Array wstr_Unicode;\n    \/\/\u8bbe\u7f6e\u8981\u5d4c\u5165\u7684\u5b57\u7b26\n    for (int i = 0; i &lt; wstr.GetLength(); i++)\n    {\n        wstr_Unicode.Add(static_cast&lt;uint32_t&gt;(wstr&#91;i]));\n    }\nUInt32Array wstr_Unicod_Embed = font_Embed.AddUnicodes(doc, wstr_Unicode);\n\/\/\u68c0\u67e5\u6307\u5b9a\u7684\u5b57\u7b26\u662f\u5426\u5168\u90e8\u6210\u529f\u5d4c\u5165    \nif (wstr_Unicode.GetSize() == wstr_Unicod_Embed.GetSize())\n{  \n        state.font = font_Embed;\n    }\n    state.font_size = 48;\n    state.textmode = TextState::e_ModeFillStrokeClip;\n\n    text_object-&gt;SetTextState(page, state, true, 750);\n    text_object-&gt;SetText(wstr);\n\n    text_object-&gt;SetFillColor(0xFFAAAAAA);\n    text_object-&gt;SetStrokeColor(0xFFF68C21);\n    page.InsertGraphicsObject(position, text_object);\n\n    RectF rect = text_object-&gt;GetRect();\n    float offset_x = (page.GetWidth() - (rect.right - rect.left)) \/ 2;\n    float offset_y = page.GetHeight() * 0.8f - (rect.top - rect.bottom) \/ 2;\n    text_object-&gt;Transform(Matrix(1, 0, 0, 1, offset_x, offset_y), false);\n    page.GenerateContent()\n    doc.SaveAs(L\"D:\/test.pdf\", 0);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u539f\u56e0\uff1a\u572810.0\u4e4b\u524d\u7684\u7248\u672c\u4e2d\uff0c\u5d4c\u5165\u5b57\u4f53Font::Embed ()\u63a5\u53e3\uff0c\u662f\u5d4c\u5165\u6574\u4e2a\u5b57\u4f53\u6587\u4ef6\uff0c\u5305\u542b\u6240\u6709\u5b57\u7b26\u3002 [&hellip;]<\/p>\n","protected":false},"author":31,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77],"tags":[],"class_list":["post-1683","post","type-post","status-publish","format-standard","hentry","category-gsdk"],"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\/1683","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\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1683"}],"version-history":[{"count":3,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/1683\/revisions"}],"predecessor-version":[{"id":3684,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/1683\/revisions\/3684"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}