{"id":623,"date":"2026-05-13T10:01:47","date_gmt":"2026-05-13T02:01:47","guid":{"rendered":"https:\/\/www.hyw.life\/?p=623"},"modified":"2026-05-13T10:11:01","modified_gmt":"2026-05-13T02:11:01","slug":"c%e4%bd%bf%e7%94%a8aspose-words%e6%8a%8aword%e8%bd%ac%e6%88%90%e5%9b%be%e7%89%87","status":"publish","type":"post","link":"https:\/\/www.hyw.life\/?p=623","title":{"rendered":"C#\u4f7f\u7528Aspose.Words\u628aword\u8f6c\u6210\u56fe\u7247"},"content":{"rendered":"\n<p>Aspose.Words for .NET \u4f7f\u60a8\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u5c06 DOC\/DOCX \u8f6c\u6362\u4e3a\u6240\u9700\u7684\u56fe\u50cf\u683c\u5f0f\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528SaveFormat\u679a\u4e3e\u5c06\u8f93\u51fa\u56fe\u50cf\u683c\u5f0f\u8bbe\u7f6e\u4e3a PNG\u3001JPEG\u3001BMP\u3001GIF \u6216 TIFF \u3002\u4ee5\u4e0b\u662f\u5728 C# \u4e2d\u5c06 DOC\/DOCX \u8f6c\u6362\u4e3a PNG \u56fe\u50cf\u7684\u6b65\u9aa4\u3002<\/p>\n\n\n\n<span id=\"h2-0\" class=\"heading-anchor\" aria-hidden=\"true\"><\/span><h2 class=\"wp-block-heading\">\u57fa\u7840\u4f7f\u7528<\/h2>\n\n\n\n<p>\u4f7f\u7528Document\u00a0\u7c7b\u52a0\u8f7d DOC\/DOCX \u6587\u6863\u3002<br>\u4f7f\u7528ImageSaveOptions\u7c7b\u6307\u5b9a\u8f93\u51fa\u56fe\u50cf\u683c\u5f0f\u3002<br>\u5faa\u73af\u6d4f\u89c8\u6587\u6863\u4e2d\u7684\u9875\u9762\u3002<br>\u4f7f\u7528Document.Save(string, ImageSaveOptions)\u65b9\u6cd5\u5c06 DOC \u4e2d\u7684\u6bcf\u4e2a\u9875\u9762\u8f6c\u6362\u4e3a PNG \u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Document doc = new Document(\"calibre.doc\");\n\n\/\/ set output image format using SaveFormat\nvar options = new ImageSaveOptions(SaveFormat.Png);\n\n\/\/ loop through pages and convert them to PNG images\nfor (int pageNumber = 0; pageNumber &amp;lt; doc.PageCount; pageNumber++)\n{\n\/\/ Save page as PNG\noptions.PageSet = new PageSet(pageNumber);\ndoc.Save(pageNumber + \"_page.png\", options);\n}<\/code><\/pre>\n\n\n\n<span id=\"h2-1\" class=\"heading-anchor\" aria-hidden=\"true\"><\/span><h2 class=\"wp-block-heading\">\u9ad8\u7ea7\u5e94\u7528<\/h2>\n\n\n\n<p>\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u9009\u9879\u63a7\u5236 DOC \u5230 PNG \u7684\u8f6c\u6362\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u6c34\u5e73\u5206\u8fa8\u7387\u3001\u5782\u76f4\u5206\u8fa8\u7387\u3001\u6574\u4f53\u5206\u8fa8\u7387\u3001\u6bd4\u4f8b\u3001 \u50cf\u7d20 \u683c\u5f0f\u3001\u4eae\u5ea6\u3001\u989c\u8272\u6a21\u5f0f\u3001\u5bf9\u6bd4\u5ea6\u548c\u7eb8\u5f20\u989c\u8272\u3002\u4ee5\u4e0b\u662f\u5728 C# \u4e2d\u81ea\u5b9a\u4e49 DOC \u5230 PNG \u8f6c\u6362\u7684\u6b65\u9aa4\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528Document\u7c7b\u52a0\u8f7d DOC \u6587\u4ef6\u3002<br>\u4f7f\u7528ImageSaveOptions\u7c7b\u6307\u5b9a\u8f93\u51fa\u56fe\u50cf\u683c\u5f0f\u3002<br>\u8bbe\u7f6e\u6240\u9700\u7684\u9009\u9879\uff0c\u4f8b\u5982ImageBrightness\u3001ImageContrast\u7b49\u3002<br>\u5faa\u73af\u6d4f\u89c8\u6587\u6863\u4e2d\u7684\u9875\u9762\u3002<br>\u4f7f\u7528Document.Save(string, ImageSaveOptions)\u65b9\u6cd5\u5c06\u6bcf\u4e2a\u9875\u9762\u8f6c\u6362\u4e3a PNG \u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ load document\nDocument doc = new Document(\"calibre.doc\");\n\n\/\/ set output image format using SaveFormat\nvar options = new ImageSaveOptions(SaveFormat.Png);\n\n\/\/ change the image's brightness and contrast\n\/\/ both are on a 0-1 scale and are at 0.5 by default\noptions.ImageBrightness = 0.30f;\noptions.ImageContrast = 0.7f;\noptions.Resolution= 200;\/\/ \u6570\u503c\u8d8a\u5927\uff0c\u56fe\u7247\u6e05\u6670\u5ea6\u8d8a\u9ad8\uff0c\u6587\u4ef6\u8d8a\u5927\n\n\/\/ change the horizontal resolution\n\/\/ the default value for these properties is 96.0, for a resolution of 96dpi\noptions.HorizontalResolution = 72f;\n\n\/\/ loop through pages and convert them to PNG images\nfor (int pageNumber = 0; pageNumber &amp;lt; doc.PageCount; pageNumber++)\n{\n\/\/ Save page as PNG\noptions.PageSet = new PageSet(pageNumber);\ndoc.Save(pageNumber + \"_page.png\", options);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Aspose.Words for .NET \u4f7f\u60a8\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u5c06 DOC\/DOCX \u8f6c\u6362\u4e3a\u6240\u9700\u7684\u56fe\u50cf\u683c\u5f0f\u3002\u60a8\u53ef\u4ee5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":483,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[28,27],"class_list":["post-623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hd","tag-net","tag-c"],"_links":{"self":[{"href":"https:\/\/www.hyw.life\/index.php?rest_route=\/wp\/v2\/posts\/623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyw.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hyw.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyw.life\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyw.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=623"}],"version-history":[{"count":4,"href":"https:\/\/www.hyw.life\/index.php?rest_route=\/wp\/v2\/posts\/623\/revisions"}],"predecessor-version":[{"id":627,"href":"https:\/\/www.hyw.life\/index.php?rest_route=\/wp\/v2\/posts\/623\/revisions\/627"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hyw.life\/index.php?rest_route=\/wp\/v2\/media\/483"}],"wp:attachment":[{"href":"https:\/\/www.hyw.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hyw.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hyw.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}