{"id":3238,"date":"2024-11-08T14:44:36","date_gmt":"2024-11-08T06:44:36","guid":{"rendered":"https:\/\/support.foxitsoftware.cn\/?p=3238"},"modified":"2025-11-26T15:58:13","modified_gmt":"2025-11-26T07:58:13","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e5%8d%95%e4%b8%aa%e6%96%87%e6%9c%ac%e5%af%b9%e8%b1%a1%e6%8b%86%e5%88%86%e6%88%90%e5%a4%9a%e4%b8%aa%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=3238","title":{"rendered":"\u5982\u4f55\u5c06\u5355\u4e2a\u6587\u672c\u5bf9\u8c61\u62c6\u5206\u6210\u591a\u4e2a\uff1f"},"content":{"rendered":"\n<p>\u4ec0\u4e48\u662fPDF\u4e2d\u7684\u6587\u672c\u5bf9\u8c61\uff1f<\/p>\n\n\n\n<p>PDF\u4e2d\u7684\u4e00\u884c\u6587\u672c\uff0c\u901a\u5e38\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u6587\u672c\u5bf9\u8c61\u7ec4\u6210\u3002\u4e00\u4e2a\u6587\u672c\u5bf9\u8c61\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\uff0c\u6240\u6709\u5b57\u7b26\u5171\u7528\u540c\u4e00\u4e2a\u5b57\u4f53\u548c\u6587\u672c\u5c5e\u6027\uff08\u6587\u672c\u5c5e\u6027\u5305\u542b\uff1a\u5b57\u53f7\u3001\u989c\u8272\u3001\u900f\u660e\u5ea6\u3001\u8bcd\u95f4\u8ddd\u7b49\uff09\uff0c\u4e0d\u80fd\u6362\u884c\u3002\u4e0b\u56fe\u6240\u793a\u5c31\u662f\u7528\u798f\u6615PDF\u9ad8\u7ea7\u7f16\u8f91\u5668\uff08\u7f16\u8f91-&gt;\u7f16\u8f91\u5bf9\u8c61-&gt;\u6587\u672c\u5bf9\u8c61\uff09\u9009\u4e2d\u7684\u4e00\u4e2a\u6587\u672c\u5bf9\u8c61\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"905\" height=\"274\" src=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image.png\" alt=\"\" class=\"wp-image-3239\" srcset=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image.png 905w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-300x91.png 300w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-768x233.png 768w\" sizes=\"(max-width: 905px) 100vw, 905px\" \/><\/figure>\n\n\n\n<p>\u6240\u4ee5\u5728\u4f7f\u7528SDK\u7f16\u8f91PDF\u4e2d\u7684\u6587\u672c\u65f6\uff0c\u9664\u4e86SDK\u672c\u8eab\u63d0\u4f9b\u7684\u641c\u7d22\u66ff\u6362\u3001\u6bb5\u843d\u7f16\u8f91\u7b49\u76f8\u5bf9\u9ad8\u7ea7\u7684\u63a5\u53e3\u5916\uff0c\u901a\u5e38\u662f\u9700\u8981\u76f4\u63a5\u64cd\u4f5c\u6587\u672c\u5bf9\u8c61\u7684\u3002<\/p>\n\n\n\n<p>\u62c6\u5206\u6587\u672c\u5bf9\u8c61\u7684\u573a\u666f\uff1a<\/p>\n\n\n\n<p>\u4f8b\u5982\u4e00\u4e2a\u6587\u672c\u5bf9\u8c61\u6bd4\u8f83\u957f\uff0c\u5e0c\u671b\u5c06\u6587\u672c\u5bf9\u8c61\u4e2d\u95f4\uff0c\u5c06\u6307\u5b9a\u533a\u57df\u7684\u51e0\u4e2a\u5b57\u7b26\u8fdb\u884c\u5220\u9664\u7528\u8272\u5757\u586b\u5145\uff0c\u6216\u8005\u5e0c\u671b\u53ea\u79fb\u52a8\u6587\u672c\u5bf9\u8c61\u4e2d\u7684\u90e8\u5206\u6587\u672c\u3002\u6b64\u65f6\u5c31\u9700\u8981\u5c06\u6587\u672c\u62c6\u5206\u6210\u4e09\u6bb5\uff0c\u53ea\u5904\u7406\u4e2d\u95f4\u7684\u4e00\u6bb5\uff0c\u4fdd\u8bc1\u524d\u540e\u4e24\u7aef\u7684\u5269\u4f59\u6587\u672c\u4f4d\u7f6e\uff0c\u548c\u6587\u672c\u5c5e\u6027\u4e0d\u53d1\u751f\u6539\u53d8\u3002<\/p>\n\n\n\n<p>\u5b9e\u73b0\u65b9\u5f0f<\/p>\n\n\n\n<p>\u798f\u6615SDK\u63d0\u4f9b\u5bf9\u8c61\u56fe\u5f62\u3001\u56fe\u7247\u3001\u6587\u672c\u5bf9\u8c61\u514b\u9686\u7684\u63a5\u53e3\uff0c\u5e76\u4e14\u5bf9\u4e8e\u6587\u672c\u5bf9\u8c61\uff0c\u8fd8\u63d0\u4f9b\u83b7\u63a5\u53e3\u53d6\u6bcf\u4e2a\u5b57\u7b26\u7684\u5bbd\u9ad8\u3001\u4f4d\u7f6e\u7b49\u7ec6\u8282\u4fe1\u606f\uff0c\u901a\u8fc7\u8fd9\u4e9b\u4fe1\u606f\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6587\u672c\u5bf9\u8c61\u7684\u62c6\u5206\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\u7528\u6237\u9ad8\u4eae\u4e86\u8fd9\u4e2a\u6587\u672c\u5bf9\u8c61\u7684\u4e2d\u95f4\u90e8\u5206<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"860\" height=\"274\" src=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-1.png\" alt=\"\" class=\"wp-image-3240\" srcset=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-1.png 860w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-1-300x96.png 300w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-1-768x245.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/figure>\n\n\n\n<p>\u62c6\u5206\u540e\u7684\u6548\u679c\u5e94\u8be5\u662f\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"821\" height=\"254\" src=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-2.png\" alt=\"\" class=\"wp-image-3241\" srcset=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-2.png 821w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-2-300x93.png 300w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2024\/11\/image-2-768x238.png 768w\" sizes=\"(max-width: 821px) 100vw, 821px\" \/><\/figure>\n\n\n\n<p>\u5b9e\u73b0\u8be5\u6548\u679c\u7684C#\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n        static void SplitTextObject()\n        {\n            PDFDoc doc = new PDFDoc(\"D:\\\\Downloads\\\\AboutFoxit.pdf\");\n            doc.Load(null);\n            PDFPage page = doc.GetPage(0); \n            page.StartParse(0, null, true);\n            \/\/\u5148\u5728PDF\u4e0a\u7528\u4e00\u4e2a\u77e9\u5f62\u6ce8\u91ca\uff0c\u6216\u8005\u9ad8\u4eae\u6ce8\u91ca\u6846\u9009\u51fa\u8981\u5355\u72ec\u62c6\u5206\u51fa\u7684\u6587\u672c\n            Annot annot = page.GetAnnot(0);\n            RectF selectRect = annot.GetRect();\n            GraphicsObjectArray objArray = page.GetGraphicsObjectsAtRectangle(annot.GetRect(),GraphicsObject.Type.e_TypeText);\n            \/\/objArraySelected \u7528\u4e8e\u5b58\u653e\u88ab\u77e9\u5f62\u533a\u57df\u6846\u9009\u4e2d\u7684\u6587\u672c\u5bf9\u8c61 \n            GraphicsObjectArray objArraySelected = new GraphicsObjectArray();\n            int textObjCount = objArray.GetSize();\n            for (int i = 0; i &lt; textObjCount; i++)\n            {\n                TextObject textObj = objArray.GetAt(i).GetTextObject();\n                RectF rect = textObj.GetRect();\n                RectF rectObj = textObj.GetRect();\n                rect.Intersect(selectRect);\/\/Rect\u76f8\u4ea4\n                \/\/\u5982\u679c\u77e9\u5f62\u533a\u57df\u4e0d\u5305\u542b\uff0c\u5219\u76f8\u4ea4\u533a\u57df\u5bbd\u5ea6\u4e3a0      \n                if (rect.Width() &lt;= 0)\n                    continue;\n                \/\/\u5982\u679c\u5b8c\u5168\u5305\u542b\uff0c\u5219\u76f8\u4ea4\u533a\u57df\u7684\u5bbd\u548c\u6587\u672c\u5bf9\u8c61\u7684\u5bbd\u662f\u4e00\u81f4\u7684          \n                if (rect.Width() == rectObj.Width())\n                    objArraySelected.Add(textObj);\n                else\n                {\n                    String str = textObj.GetText();\n                    int charS = -1;\n                    int charE = -1;\n                    for (int charIndex = 0; charIndex &lt; str.Length ; charIndex++)\n                    {\n                        PointF charPos = textObj.GetCharPos(charIndex);\n                        float charWidth = textObj.GetCharWidthByIndex(charIndex);\n                        if (charPos.x&gt;= selectRect.left &amp; charS == -1)\n                        {\n                            charS = charIndex;\n                            charE = charIndex;\n                            continue;\n                        }\n                        else if (charPos.x &gt;= selectRect.right)\n                        {\n                            charE = charIndex;\n                            break;\n                        }\n                    }\n                    getSelectTextObject(textObj, charS, charE, page, objArraySelected);\n                    i--;\n                    textObjCount--;\n                }\n            }\n            page.GenerateContent();\n            doc.SaveAs(\"D:\\\\Downloads\\\\result.pdf\", 0);\n        }\n    <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-body-font-family has-medium-font-size\"><code>\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fPDF\u4e2d\u7684\u6587\u672c\u5bf9\u8c61\uff1f PDF\u4e2d\u7684\u4e00\u884c\u6587\u672c\uff0c\u901a\u5e38\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u6587\u672c\u5bf9\u8c61\u7ec4\u6210\u3002\u4e00\u4e2a\u6587\u672c\u5bf9\u8c61\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57 [&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":[1204,449],"class_list":["post-3238","post","type-post","status-publish","format-standard","hentry","category-gsdk","tag-1204","tag-449"],"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\/3238","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=3238"}],"version-history":[{"count":4,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/3238\/revisions"}],"predecessor-version":[{"id":7246,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/3238\/revisions\/7246"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}