{"id":4192,"date":"2025-01-26T14:02:38","date_gmt":"2025-01-26T06:02:38","guid":{"rendered":"https:\/\/support.foxitsoftware.cn\/?p=4192"},"modified":"2025-01-26T14:02:39","modified_gmt":"2025-01-26T06:02:39","slug":"%e6%80%8e%e4%b9%88%e5%88%a4%e6%96%ad%e5%9b%be%e7%89%87%e5%af%b9%e8%b1%a1%e7%9a%84%e6%97%8b%e8%bd%ac%e8%a7%92%e5%ba%a6%e5%92%8c%e7%bf%bb%e8%bd%ac%e6%83%85%e5%86%b5%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=4192","title":{"rendered":"\u600e\u4e48\u5224\u65ad\u56fe\u7247\u5bf9\u8c61\u7684\u65cb\u8f6c\u89d2\u5ea6\u548c\u7ffb\u8f6c\u60c5\u51b5\uff1f"},"content":{"rendered":"\n<p><strong>\u4f7f\u7528\u573a\u666f\uff1a<\/strong>\u518d\u5bfc\u51faPDF\u4e2d\u7684\u56fe\u7247\u65f6\uff0c\u901a\u5e38\u4f1a\u7528\u5230ImageObject.CloneBitmap()\u7684\u63a5\u53e3\u3002\u5982\u679c\u51fa\u73b0\u5bfc\u51fa\u7684\u56fe\u7247\u53d1\u751f\u4e86\u65cb\u8f6c\uff0c\u7ffb\u8f6c\u7b49\u60c5\u51b5\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u8be5\u56fe\u7247\u5bf9\u8c61imageObject\u7684\u53d8\u6362\u77e9\u9635Matrix\u4e2d\u6709\u65cb\u8f6c\u3001\u7ffb\u8f6c\u4e0a\u7684\u5904\u7406\uff0c\u5bfc\u81f4PDF\u663e\u793a\u6548\u679c\uff0c\u548c\u5b9e\u9645\u5bfc\u51fa\u7684\u56fe\u7247\u4e0d\u592a\u4e00\u81f4\u3002<\/p>\n\n\n\n<p><strong>\u53d8\u6362\u77e9\u9635matrix\u4ecb\u7ecd\uff1a<\/strong><\/p>\n\n\n\n<p>Matrix2D={a,b,c,d,e,f}\u662f\u4e00\u4e2a\u5305\u542b6\u4e2a\u5143\u7d20\u7684\u6570\u7ec4\uff0c\u7528\u6765\u63a7\u5236\u5bf9\u8c61\u7684\u7f29\u653e\u3001\u5e73\u79fb\u3001\u65cb\u8f6c\u3001\u626d\u66f2\u3002 \u5728PDF\u4e2d\uff0c\u56fe\u5f62\u3001\u56fe\u7247\u3001\u6587\u672c\u3001\u6e10\u53d8\u7b49\u51e0\u4f55\u5bf9\u8c61\uff0c\u5982\u679c\u8981\u505a\u51e0\u4f55\u53d8\u6362\u90fd\u4f1a\u7528\u5230matrix\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662fPDF\u6807\u51c6\u4e2d\u5bf9\u5982\u4f55\u8ba1\u7b97matrix\u7684\u63cf\u8ff0\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"687\" height=\"717\" src=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-7.png\" alt=\"\" class=\"wp-image-4194\" srcset=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-7.png 687w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-7-287x300.png 287w\" sizes=\"(max-width: 687px) 100vw, 687px\" \/><\/figure>\n\n\n\n<p>\u6570\u7ec4[a,b,c,d,e,f]\u4ee5\u77e9\u9635\u7684\u65b9\u5f0f\u5448\u73b0\uff0c\u5e76\u7528\u4e8e\u8ba1\u7b97\u7684\u65cb\u8f6c\u548c\u62c9\u4f38\u7684\u8ba1\u7b97\u65b9\u5f0f<strong>1.\u53d8\u6362\u8ba1\u7b97\u7684\u8fc7\u7a0b\uff08\u5c06\u9ed8\u8ba4\u7684matrix\uff0c\u8fdb\u884c\u65cb\u8f6c\u3001\u7f29\u653e\u3001\u7ffb\u8f6c\uff09\uff1a<\/strong><strong><\/strong><\/p>\n\n\n\n<p><strong>\u7f29\u653e\u53d8\u6362\uff1a<\/strong>Sx\u548cSy\u5206\u522b\u8868\u793a\u6a2a\u7eb5\u7f29\u653e\u6bd4\u4f8b\uff0c\u5982\u679c\u662f\u8d1f\u7684\uff0c\u5219\u4f1a\u7ffb\u8f6c(Sx&lt;0\u6c34\u5e73\u7ffb\u8f6c\uff0cSy&lt;0\u5782\u76f4\u7ffb\u8f6c)\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"592\" height=\"88\" src=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-9.png\" alt=\"\" class=\"wp-image-4196\" style=\"width:618px;height:auto\" srcset=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-9.png 592w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-9-300x45.png 300w\" sizes=\"(max-width: 592px) 100vw, 592px\" \/><\/figure>\n\n\n\n<p><strong>\u65cb\u8f6c\u53d8\u6362\uff1a<\/strong>Rc=Cos\u03b8&nbsp;,Rs=Sin\u03b8 \u03b8\u8868\u793a\u9006\u65f6\u9488\u65cb\u8f6c\u89d2\u5ea6<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"690\" height=\"101\" src=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-10.png\" alt=\"\" class=\"wp-image-4197\" srcset=\"https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-10.png 690w, https:\/\/support.fuxinsoft.cn\/wp-content\/uploads\/2025\/01\/image-10-300x44.png 300w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/figure>\n\n\n\n<p>\u6ce8\u610f\uff1a\u5148\u65cb\u8f6c\u540e\u7ffb\u8f6c  \u548c\u5148\u7ffb\u8f6c\u540e\u65cb\u8f6c\u7684\u7ed3\u679c\u662f\u4e0d\u540c\u7684\uff0c\u987a\u5e8f\u4e0d\u53ef\u4ee5\u53d8\u3002<\/p>\n\n\n\n<p><strong>\u8ba1\u7b97\u65cb\u8f6c\u548c\u7ffb\u8f6c\u60c5\u51b5\u7684\u4ee3\u7801(C#\uff09\u793a\u4f8b\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-body-font-family has-medium-font-size\"><code>using System;\nusing foxit.common;\nusing foxit.common.fxcrt;\nusing foxit.pdf;\nusing ErrorCode = foxit.common.ErrorCode;\nusing foxit.pdf.graphics;\nusing Bitmap = foxit.common.Bitmap;\n\nusing System.Drawing;\nusing System.Drawing.Drawing2D;\nusing System.Web;\nusing Image = foxit.common.Image;\nusing System.IO;\n\nnamespace pdf2imageCS\n{\n\n\n  \n    class pdf2image\n    {\n\n        public static void Page2Bitmap(PDFPage page,int dpi_x, int dpi_y,String savePath)\n        {\n            {\n                page.StartParse(0, null, true);\n                \/\/\u89c4\u8303\u5316\u9875\u9762\uff0c\u53d6\u6d88\u9875\u9762\u65cb\u8f6c\u548cpageBox\u5e26\u6765\u7684\u5f71\u54cd\n                page.Normalize();\n                page.StartParse(0, null, true);\n                RectF rectf=new RectF(0,0, page.GetWidth(), page.GetHeight());\n                float pro_x =(float) dpi_x \/ 72;\n                float pro_y = (float)dpi_y \/ 72;\n                Matrix2D matrix = page.GetDisplayMatrix(-1 * (int)(rectf.left), -(int)(page.GetHeight() - rectf.top), (int)(page.GetWidth() * pro_x), (int)(page.GetHeight() * pro_y), Rotation.e_Rotation0);\/\/page.GetDisplayMatrix(0,0, width, height, page.GetRotation());\n                rectf.left = rectf.left * pro_x;\n                rectf.right = (rectf.right * pro_x);\n                rectf.bottom = (rectf.bottom * pro_y);\n                rectf.top = rectf.top * pro_y;\n\n                using (Bitmap bitmap = new Bitmap((int)rectf.Width(), (int)rectf.Height(), Bitmap.DIBFormat.e_DIBArgb, IntPtr.Zero, 0))\n                {\n                    using (Renderer render = new Renderer(bitmap, false))\n                    {\n                        \/\/\u5f00\u59cb\u6e32\u67d3\n                        render.StartRender(page, matrix, null);\n                        {\n                            using (Image image = new Image())\n                            {\n                                image.AddFrame(bitmap);\n                                image.SetDPIs(dpi_x, dpi_y);\n                                \/\/\u4fdd\u5b58\u56fe\u7247\n                                image.SaveAs(savePath+\" test_\" + page.GetIndex() + \".jpg\");\n                            }\n                        }\n                    }\n                }\n                rectf.Dispose();\n                matrix.Dispose();\n            }\n\n        }\n\n        static void Main(string&#91;] args)\n        {\n            ErrorCode error_code = Library.Initialize(sn, key);\n            if (error_code != ErrorCode.e_ErrSuccess)\n            {\n                Console.WriteLine(\"Library Initialize Error: {0}\\n\", error_code);\n                return;\n            }\n            String savePath = @\"D:\\DownLoad\\output\\\";\n            \/\/\u8f6c\u6210\u6307\u5b9a\u5206\u8fa8\u7387\u7684\u56fe\u7247\n            using (PDFDoc doc = new PDFDoc(@\"D:\\DownLoad\\output\\AboutFoxit.pdf\"))\n            {\n                doc.Load(null);\n                for (int i = 0; i &lt; doc.GetPageCount(); i++)\n                {\n                    using (PDFPage page = new PDFPage(doc.GetPage(i)))\n                    {\n\n                        Page2Bitmap(page, 72, 72, savePath);\n                    }\n                }\n            }\n            \n            \/\/\u56fe\u7247\u63d2\u5165PDF\uff0c\u9875\u9762\u5927\u5c0f\u9002\u5e94\u56fe\u7247\u5c3a\u5bf8\n            using (Image image = new Image(savePath + \"test_1.jpg\"))\n            using (PDFDoc doc = new PDFDoc())\n            {\n                int w = image.GetWidth(), h = image.GetHeight();\n                using (PDFPage page = doc.InsertPage(0, w, h))\n                {\n                    page.AddImage(image, 0, new foxit.common.fxcrt.PointF(0, 0), w, h, true);\n                }\n            }\n\n            \/\/PDF\u5bfc\u51fatxt\n            using (var doc = new PDFDoc(@\"D:\\DownLoad\\output\\AboutFoxit.pdf\"))\n            {\n                doc.Load(null);\n\n                using (var writer = new StreamWriter(savePath + \"pdf2text.txt\", false, System.Text.Encoding.Unicode))\n                {\n                    int pageCount = doc.GetPageCount();\n                    for (int i = 0; i &lt; pageCount; i++)\n                    {\n                        using (var page = doc.GetPage(i))\n                        {\n                            page.StartParse((int)PDFPage.ParseFlags.e_ParsePageNormal, null, false);\n                            using (var text_select = new TextPage(page, (int)TextPage.TextParseFlags.e_ParseTextUseStreamOrder))\n                            {\n\n                                String chars = text_select.GetText(TextPage.TextOrderFlag.e_TextDisplayOrder);\n                                writer.Write(chars);\n\n                            }\n                        }\n                    }\n                    writer.Close();\n                }\n            }\n            Library.Release();\n        }\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u573a\u666f\uff1a\u518d\u5bfc\u51faPDF\u4e2d\u7684\u56fe\u7247\u65f6\uff0c\u901a\u5e38\u4f1a\u7528\u5230ImageObject.CloneBitmap()\u7684\u63a5\u53e3\u3002\u5982\u679c\u51fa\u73b0 [&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":[239,237,241,175,240,242,238],"class_list":["post-4192","post","type-post","status-publish","format-standard","hentry","category-gsdk","tag-matrix","tag-237","tag-241","tag-175","tag-240","tag-242","tag-238"],"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\/4192","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=4192"}],"version-history":[{"count":7,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/4192\/revisions"}],"predecessor-version":[{"id":4389,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/4192\/revisions\/4389"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}