{"id":7325,"date":"2025-12-08T15:17:11","date_gmt":"2025-12-08T07:17:11","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=7325"},"modified":"2025-12-08T15:17:11","modified_gmt":"2025-12-08T07:17:11","slug":"gsdk%e5%a6%82%e4%bd%95%e7%bc%a9%e6%94%be-pdf-%e9%a1%b5%e9%9d%a2%e5%86%85%e5%ae%b9%e5%b9%b6%e8%b0%83%e6%95%b4%e9%a1%b5%e9%9d%a2%e5%a4%a7%e5%b0%8f%e4%b8%ba-letter-%e8%a7%84%e6%a0%bc%ef%bc%9f%e8%b0%83","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=7325","title":{"rendered":"GSDK\u5982\u4f55\u7f29\u653e PDF \u9875\u9762\u5185\u5bb9\u5e76\u8c03\u6574\u9875\u9762\u5927\u5c0f\u4e3a Letter \u89c4\u683c\uff1f\u8c03\u6574\u8fc7\u7a0b\u4e2d\u5982\u4f55\u907f\u514d\u5185\u5bb9\u504f\u79fb\uff1f"},"content":{"rendered":"\n<p>Letter \u662f\u5317\u7f8e\u5e38\u7528\u9875\u9762\u5c3a\u5bf8\uff088.5\u00d711 \u82f1\u5bf8\uff09\uff0c\u5bf9\u5e94 PDF \u7684 \u201c\u70b9\uff08pt\uff09\u201d \u5355\u4f4d\u4e3a 612\u00d7792pt\uff081pt=1\/72 \u82f1\u5bf8\uff09\u3002\u8c03\u6574\u9875\u9762\u5927\u5c0f\u9700\u5148\u7f29\u653e\u5185\u5bb9\uff0c\u518d\u4fee\u6539\u9875\u9762\u5c3a\u5bf8\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6838\u5fc3\u5c3a\u5bf8\u8bf4\u660e<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Letter \u5c3a\u5bf8\uff1a\u5bbd\u5ea6 612pt\uff0c\u9ad8\u5ea6 792pt\uff1b<\/li>\n\n\n\n<li>A4 \u5c3a\u5bf8\uff08\u5bf9\u6bd4\uff09\uff1a\u5bbd\u5ea6 595pt\uff0c\u9ad8\u5ea6 842pt\uff1b<\/li>\n\n\n\n<li>\u539f\u9875\u9762\u5c3a\u5bf8\u83b7\u53d6\uff1a\u901a\u8fc7<code>page.getWidth()<\/code>\/<code>page.getHeight()<\/code>\u83b7\u53d6\uff08\u5355\u4f4d\uff1apt\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b8c\u6574\u793a\u4f8b\uff08A4\u2192Letter\uff0c\u7b49\u6bd4\u4f8b\u7f29\u653e + \u65e0\u504f\u79fb\uff09<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>            PDFDoc doc = new PDFDoc(\"C:\\\\Users\\\\yang_leng\\\\Desktop\\\\\u8bbe\u7f6e\u9875\u9762\u5927\u5c0f.pdf\");\n            error_code = doc.load(null);\n            if (error_code != e_ErrSuccess) {\n                System.out.println(error_code);\n            }\n            \/\/\u83b7\u53d6letter\u7684\u5bbd\u9ad8\u5927\u5c0f\uff0c\u7528\u4f5c\u8ba1\u7b97\u6bd4\u4f8b\u7cfb\u6570\n            PDFDoc doc1 = new PDFDoc();\n            doc1.insertPage(0,e_SizeLetter);\n            PDFPage page1 = doc1.getPage(0);\n            float width1 = page1.getWidth();\n            float height1 = page1.getHeight();\n\n            \/\/\u5982\u679c\u8003\u8651\u6587\u6863\u9875\u9762\u4e0d\u5b8c\u5168\u662f\u540c\u6837\uff0c\u5219\u9700\u8981\u5206\u522b\u8ba1\u7b97\u7cfb\u6570\n            PDFPage page2 = doc.getPage(0);\n            float width2 = page2.getWidth();\n            float height2 = page2.getHeight();\n\n            \/\/\u8ba1\u7b97\u6bd4\u4f8b\u7cfb\u6570 \u8f6c\u5230Letter\u5927\u5c0f page1\/page2\n            float scal_width = width1 \/ width2;\n            float scal_height = height1 \/ height2;\n\n            int pageCount = doc.getPageCount();\n\n            for (int i = 0; i &lt; pageCount; i++) {\n                PDFPage page = doc.getPage(i);\n                int rotation = page.getRotation(); \/\/rotation = 0;\n\n                page.startParse(e_ParsePageNormal, null, true);\n\n                \/\/6\u4e2a\u53c2\u6570 a b c d e f \uff08\u77e9\u9635\u53d8\u6362\uff09\n                \/\/ ad\u662f\u9875\u9762\u7f29\u653e\u6bd4\u4f8b\u3001bc\u662f\u65cb\u8f6c\u7f29\u653e\u6bd4\u4f8b\u3001ef\u662fPDF\u5de6\u4e0b\u89d2\u5750\u6807\u8f74\u7684\u539f\u70b9\n                Matrix2D matrix2D = new Matrix2D(scal_width, 0f, 0f, scal_height, 0f, 0f);\n                \/\/matrix2D \u9875\u9762\u5185\u5bb9\u7684\u77e9\u9635\u53d8\u6362\n                \/\/\u53ef\u526a\u8f91\u7684\u5185\u5bb9\u662f\u5426\u53d8\u6362\n                \/\/\u6ce8\u91ca\u662f\u5426\u53d8\u6362\n                page.transform(matrix2D, true, true);\n                float height = page.getHeight();\n                float width = page.getWidth();\n                System.out.println(\"width:\"+width);\n                System.out.println(\"height:\"+height);\n                \/\/rotation=0\u4e3a\u524d\u63d0\uff0c\u6b64\u65f6\u4ee5\u9875\u9762\u5de6\u4e0b\u89d2\u4e3a\u8fdc\u70b9\n                \/\/setSize\u662f\u914d\u5408\u5185\u5bb9\u7f29\u5c0f\u65f6\uff0c\u9875\u9762\u540c\u6b65\u7f29\u5c0f\n                page.setSize(width * scal_width, height * scal_height);\n                System.out.println(\"new width:\"+width * scal_width);\n                System.out.println(\"new height:\"+height * scal_height);\n            }\n            doc.saveAs(\"C:\\\\Users\\\\yang_leng\\\\Desktop\\\\\"+\"\u8bbe\u7f6e\u9875\u9762\u5927\u5c0f_toLetter.pdf\",e_SaveFlagNormal);\n            doc1.saveAs(\"C:\\\\Users\\\\yang_leng\\\\Desktop\\\\\"+\"Letter.pdf\",e_SaveFlagNormal);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Letter \u662f\u5317\u7f8e\u5e38\u7528\u9875\u9762\u5c3a\u5bf8\uff088.5\u00d711 \u82f1\u5bf8\uff09\uff0c\u5bf9\u5e94 PDF \u7684 \u201c\u70b9\uff08pt\uff09\u201d \u5355\u4f4d\u4e3a 612\u00d779 [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77],"tags":[],"class_list":["post-7325","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\/7325","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\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7325"}],"version-history":[{"count":1,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7325\/revisions"}],"predecessor-version":[{"id":7326,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7325\/revisions\/7326"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}