杨建生 發表於 2025-8-28 10:58:00

PPT处理控件Aspose.Slides教程:在 C# 中将 PPTX 转换为 Markdown

<p><img src="https://image.evget.com/attachment/keditor/image/20250828/095604_1.png"></p>
<p>将您的PowerPoint幻灯片转换为Markdown格式,使其兼容 AI 技术。在这个人工智能驱动的时代,GPT和Claude等大模型能够读取和生成基于 Markdown 的内容。此外,Markdown 还可用于博客文章和文档。因此,作为一名 .NET 开发人员,如果您希望自动化 PPTX 到 MD 的转换,<strong>Aspose.Slides for .NET</strong>就是不错的选择。这款 SDK 提供了一系列功能,支持您使用 C# 以编程方式将 PPTX 转换为 Markdown。它是一款开发者友好的 SDK,可以为您的商业应用提升竞争优势。</p>
<p style="text-align: center"><span style="color: rgba(230, 126, 35, 1)"><strong>Aspose.Slides试用版免费下载,请联系Aspose官方授权代理慧都科技</strong></span></p>
<p style="text-align: center"><span style="color: rgba(230, 126, 35, 1)"><strong><em>加入Aspose技术交流QQ群(1041253375),与更多小伙伴一起探讨提升开发技能。</em></strong></span></p>
<p>&nbsp;</p>
<h2 id="asposeslides-for-net---installation">Aspose.Slides for .NET - 安装</h2>
<p>打开程序包管理器控制台并运行以下命令:</p>
<pre class="prettyprint lang-py highlighter-hljs"><code>Install-Package Aspose.Slides.NET</code></pre>
<p>此外,您可以<strong><u>下载</u></strong><strong><u>&nbsp;文件</u></strong>或通过 NuGet 包管理器安装。</p>
<p style="text-align: center"><span style="color: rgba(230, 126, 35, 1)"><strong>Aspose.Slides试用版免费下载,请联系Aspose官方授权代理慧都科技</strong></span></p>
<p style="text-align: center"><span style="color: rgba(230, 126, 35, 1)"><strong><em>加入Aspose技术交流QQ群(1041253375),与更多小伙伴一起探讨提升开发技能。</em></strong></span></p>
<h2 id="code">如何在 C# 中将 PPTX 转换为 Markdown - 代码片段</h2>
<p>现在您可以使用<strong><u>Aspose.Slides for .NET</u></strong>公开的类和方法。</p>
<p>步骤如下:</p>
<ul>
<li>创建Presentation类的对象并加载源文件。</li>
<li>实例化MarkdownSaveOptions类的实例并将值传递给某些属性。</li>
<li>通过调用Save方法将演示文稿保存为 Markdown 格式。</li>
</ul>
<p>按照下面给出的代码片段,以编程方式在 C# 中将 PPTX 转换为 Markdown:</p>
<pre class="prettyprint lang-js highlighter-hljs"><code>using Aspose.Slides.Export;
using Aspose.Slides;

namespace AsposeSlides
{
    class Graphics
    {
      // Convert PPTX to MD in .NET
      static void Main(string[] args)
      {
            // The path to the documents directory.
            string presentationName = "test.pptx";
            string outPath = "output";
            License lic = new License();
            lic.SetLicense("license.lic");
            // Create an object of the Presentation class and load the source file.
            using (Presentation pres = new Presentation(presentationName))
            {
                // Instantiate an instance of the MarkdownSaveOptions class and pass values to some of the properties.
                MarkdownSaveOptions options = new MarkdownSaveOptions
                {
                  RemoveEmptyLines = true,
                  HandleRepeatedSpaces = HandleRepeatedSpaces.AlternateSpacesToNbsp,
                  SlideNumberFormat = "## Slide {0} -",
                  ShowSlideNumber = true,
                  ExportType = MarkdownExportType.TextOnly,
                  Flavor = Flavor.Default
                };
                // Save presentation in Markdown format by calling the Save method.
                pres.Save(Path.Combine(outPath, "pres-out.md"), SaveFormat.Md, options);
            }
      }
    }
}</code></pre>
<p>上述代码示例生成以下输出:</p>
<p><img src="https://image.evget.com/attachment/keditor/image/20250828/095840_9.png"></p>
<h2 id="wrapping-up">总结</h2>
<p>我们介绍了如何使用<strong><u>Aspose.Slides for .NET</u></strong>在 C# 中将 PPTX 转换为 Markdown&nbsp;。现在,建议你自己尝试生成 PPTX 到 MD 转换器,生成结构良好的 Markdown 文件。</p>
<p style="text-align: center"><span style="color: rgba(230, 126, 35, 1)"><strong>Aspose.Slides试用版免费下载,请联系Aspose官方授权代理慧都科技</strong></span></p>
<p style="text-align: center"><span style="color: rgba(230, 126, 35, 1)"><strong><em>加入Aspose技术交流QQ群(1041253375),与更多小伙伴一起探讨提升开发技能。</em></strong></span></p><br><br>
来源:https://www.cnblogs.com/software-Development/p/19062228
頁: [1]
查看完整版本: PPT处理控件Aspose.Slides教程:在 C# 中将 PPTX 转换为 Markdown