{"id":7318,"date":"2025-12-08T15:06:56","date_gmt":"2025-12-08T07:06:56","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=7318"},"modified":"2025-12-08T15:07:08","modified_gmt":"2025-12-08T07:07:08","slug":"gsdk%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9-pdf-%e6%89%93%e5%bc%80%e6%97%b6%e7%9a%84%e5%88%9d%e5%a7%8b%e9%a1%b5%e9%9d%a2%e5%b8%83%e5%b1%80%ef%bc%88%e5%a6%82%e5%8f%8c%e9%a1%b5%e6%98%be%e7%a4%ba%ef%bc%89","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=7318","title":{"rendered":"GSDK\u5982\u4f55\u4fee\u6539 PDF \u6253\u5f00\u65f6\u7684\u521d\u59cb\u9875\u9762\u5e03\u5c40\uff08\u5982\u53cc\u9875\u663e\u793a\uff09\uff1f\u9664\u4e86\u5e03\u5c40\uff0c\u8fd8\u80fd\u8bbe\u7f6e\u54ea\u4e9b\u521d\u59cb\u89c6\u56fe\u53c2\u6570\uff1f"},"content":{"rendered":"\n<p>PDF \u7684\u521d\u59cb\u89c6\u56fe\u7531\u6587\u6863\u76ee\u5f55\u5b57\u5178\uff08Catalog\uff09\u7684\u5c5e\u6027\u63a7\u5236\uff0c\u5176\u4e2d<code>PageLayout<\/code>\u5b9a\u4e49\u9875\u9762\u5e03\u5c40\uff0c<code>OpenAction<\/code>\u5b9a\u4e49\u521d\u59cb\u9875\u7801 \/ \u7f29\u653e\u6bd4\u4f8b\uff0c<code>PageMode<\/code>\u5b9a\u4e49\u662f\u5426\u663e\u793a\u4e66\u7b7e \/ \u7f29\u7565\u56fe\u7b49\uff0c\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>PageLayout \u53ef\u9009\u503c\u53ca\u6548\u679c<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u5c5e\u6027\u503c<\/th><th>\u542b\u4e49<\/th><th>\u9002\u7528\u573a\u666f<\/th><\/tr><\/thead><tbody><tr><td>SinglePage<\/td><td>\u5355\u9875\u663e\u793a\uff08\u9ed8\u8ba4\uff09<\/td><td>\u56fe\u6587\u5bc6\u96c6\u7684\u6587\u6863<\/td><\/tr><tr><td>OneColumn<\/td><td>\u5355\u5217\u8fde\u7eed\u663e\u793a<\/td><td>\u957f\u6587\u672c\u6587\u6863<\/td><\/tr><tr><td>TwoColumnLeft<\/td><td>\u53cc\u5217\u5de6\u5bf9\u9f50\uff08\u5947\u6570\u9875\u5de6\uff09<\/td><td>\u4e66\u7c4d\u7c7b\u6587\u6863\uff08\u4ece\u5de6\u7ffb\u9875\uff09<\/td><\/tr><tr><td>TwoColumnRight<\/td><td>\u53cc\u5217\u53f3\u5bf9\u9f50\uff08\u5947\u6570\u9875\u53f3\uff09<\/td><td>\u897f\u5f0f\u4e66\u7c4d<\/td><\/tr><tr><td>TwoPageLeft<\/td><td>\u53cc\u9875\u5de6\u5bf9\u9f50\uff08\u4e24\u9875\u4e3a\u4e00\u7ec4\uff09<\/td><td>\u753b\u518c \/ \u6742\u5fd7<\/td><\/tr><tr><td>TwoPageRight<\/td><td>\u53cc\u9875\u53f3\u5bf9\u9f50\uff08\u4e24\u9875\u4e3a\u4e00\u7ec4\uff09<\/td><td>\u6807\u51c6\u56fe\u4e66\u6392\u7248<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5b8c\u6574\u793a\u4f8b\uff08\u8bbe\u7f6e\u53cc\u9875\u53f3\u5bf9\u9f50 + \u521d\u59cb\u7f29\u653e 100%\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import com.foxit.sdk.PDFDoc;\nimport com.foxit.sdk.PDFDictionary;\nimport com.foxit.sdk.PDFObject;\nimport com.foxit.sdk.Action;\nimport com.foxit.sdk.GotoAction;\nimport com.foxit.sdk.common.ErrorCode;\n\npublic class PDFInitialViewDemo {\n    public static void main(String&#091;] args) {\n        \/\/ \u521d\u59cb\u5316SDK\uff08\u7701\u7565\uff09\n        PDFDoc doc = new PDFDoc(\"test.pdf\");\n        if (doc.load(null) != ErrorCode.e_ErrSuccess) {\n            System.out.println(\"\u6587\u6863\u52a0\u8f7d\u5931\u8d25\");\n            return;\n        }\n\n        \/\/ 1. \u83b7\u53d6\u6587\u6863\u76ee\u5f55\u5b57\u5178\n        PDFDictionary catalog = doc.getCatalog();\n        if (catalog == null) return;\n\n        \/\/ 2. \u8bbe\u7f6e\u9875\u9762\u5e03\u5c40\u4e3a\u201c\u53cc\u9875\u53f3\u5bf9\u9f50\u201d\n        PDFObject layoutObj = PDFObject.createFromString(\"TwoPageRight\");\n        catalog.setAt(\"PageLayout\", layoutObj);\n\n        \/\/ 3. \u6269\u5c55\uff1a\u8bbe\u7f6e\u521d\u59cb\u9875\u7801\u4e3a\u7b2c1\u9875\uff0c\u7f29\u653e\u6bd4\u4f8b100%\n        GotoAction gotoAction = new GotoAction();\n        \/\/ \u8bbe\u7f6e\u76ee\u6807\u9875\u9762\uff08\u7d22\u5f15\u4ece0\u5f00\u59cb\uff0c\u5bf9\u5e94\u7b2c1\u9875\uff09\n        gotoAction.setDestPage(doc.getPage(0));\n        \/\/ \u8bbe\u7f6e\u7f29\u653e\u6a21\u5f0f\u4e3a100%\uff08e_ZoomFixed\uff1a\u56fa\u5b9a\u7f29\u653e\u6bd4\u4f8b\uff09\n        gotoAction.setZoomMode(GotoAction.e_ZoomFixed, 1.0f);\n        Action openAction = gotoAction;\n        catalog.setAt(\"OpenAction\", openAction.getDict());\n\n        \/\/ 4. \u6269\u5c55\uff1a\u8bbe\u7f6e\u6253\u5f00\u65f6\u663e\u793a\u4e66\u7b7e\u9762\u677f\n        PDFObject pageModeObj = PDFObject.createFromString(\"UseOutlines\");\n        catalog.setAt(\"PageMode\", pageModeObj);\n\n        \/\/ \u4fdd\u5b58\u4fee\u6539\n        doc.save(PDFDoc.e_SaveFlagNoIncremental, null);\n        doc.close();\n        Library.release();\n    }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u6ce8\u610f\u4e8b\u9879<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u517c\u5bb9\u6027\uff1a\u90e8\u5206\u8f7b\u91cf\u7ea7 PDF \u9605\u8bfb\u5668\uff08\u5982\u79fb\u52a8\u7aef\uff09\u53ef\u80fd\u4e0d\u652f\u6301<code>TwoPageLeft\/Right<\/code>\u7b49\u5e03\u5c40\uff0c\u9700\u6d4b\u8bd5\u9a8c\u8bc1\uff1b<\/li>\n\n\n\n<li>\u751f\u6548\u6761\u4ef6\uff1a\u4fee\u6539\u540e\u9700\u91cd\u65b0\u6253\u5f00 PDF \u624d\u80fd\u770b\u5230\u521d\u59cb\u89c6\u56fe\u53d8\u5316\uff1b<\/li>\n\n\n\n<li>PageMode \u53ef\u9009\u503c\uff1a<code>UseNone<\/code>\uff08\u4ec5\u663e\u793a\u9875\u9762\uff09\u3001<code>UseOutlines<\/code>\uff08\u663e\u793a\u4e66\u7b7e\uff09\u3001<code>UseThumbs<\/code>\uff08\u663e\u793a\u7f29\u7565\u56fe\uff09\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>PDF \u7684\u521d\u59cb\u89c6\u56fe\u7531\u6587\u6863\u76ee\u5f55\u5b57\u5178\uff08Catalog\uff09\u7684\u5c5e\u6027\u63a7\u5236\uff0c\u5176\u4e2dPageLayout\u5b9a\u4e49\u9875\u9762\u5e03\u5c40\uff0cOpenA [&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":[651],"class_list":["post-7318","post","type-post","status-publish","format-standard","hentry","category-gsdk","tag-651"],"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\/7318","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=7318"}],"version-history":[{"count":2,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7318\/revisions"}],"predecessor-version":[{"id":7320,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7318\/revisions\/7320"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}