# Node.js 通过 Aspose.Slides 的 .NET PowerPoint API

> Aspose.Slides for Node.js via .NET 是一个 Node.js PowerPoint API，可让您在 Node.js 中创建、修改和转换 PowerPoint 演示文稿。

Source: https://products.aspose.com/slides/zh/nodejs-net/
Updated: 2026-08-11



<p><strong>Aspose.Slides for Node.js via .NET</strong> 是一个 Node.js 库，可让您在 Node.js 中创建、修改和转换 PowerPoint 演示文稿。它支持所有演示元素，例如幻灯片、形状、文本、图表、表格、图像等。它还提供许多高级功能，例如合并、克隆、拆分、比较和打印演示文稿。它的工作没有任何依赖性，可以在短时间内处理数千个演示文稿。</p>

<p><strong>Aspose.Slides for Node.js via .NET</strong> 提供以下流行功能：</p>
<ul>
    <li>加载、打开和查看演示文稿。</li>
    <li>编辑演示文稿。</li>
    <li>将演示文稿文件转换为流行的演示文稿格式，例如 PPT、PPTX 和 ODP。</li>
    <li>将演示文稿导出为 PDF、JPG、HTML、GIF、SVG 和许多其他格式。</li>
    <li>渲染和打印演示文稿。</li>
    <li>加密和解密演示文稿；密码保护演示文稿并删除密码。</li>
    <li>操作演示实体，例如主幻灯片、形状、图表、图片框架、音频框架、视频框架、OLE、VBA 宏、动画等。</li>
    <li>还有更多功能。</li>
</ul>

<p>Node.js 是一种流行的、免费的、开源的、跨平台的 JavaScript 运行时环境，允许开发人员在浏览器之外编写命令行工具和服务器端脚本。因此，<strong>Aspose.Slides</strong> 团队很自豪能够向 Node.js 社区提供<strong>Aspose.Slides for Node.js via .NET</strong>。</p>

<div class="container-fluid features-section bg-gray singleproduct">
 <a class="anchor" id="features" name="features">
 </a>
 <div class="row">
  <div class="container">
   <h2 class="pr-ft">高级 Node.js PowerPoint API 功能</h2>
   <p>
   </p>
   <div class="col-lg-4">
    <em class="fa fa-copy ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">从模板创建或克隆现有幻灯片</p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-table ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">通过 API 使用 PowerPoint 表格</p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-shield ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">应用或删除形状上的保护</p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-bar-chart ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">将 Excel 图表作为 OleObject 到幻灯片</p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-image ico-blue fa-2x col-lg-2">
    </em>
    <p类=“col-lg-10”>
     创建形状幻灯片上的形状添加文本
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-align-left ico-blue fa-2x col-lg-2">
    </em>
    <p类=“col-lg-10”>
     处理文本和形状格式
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-database ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">从数据库生成演示文稿</p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-lock ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">保护演示并生成的 PDF</p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-print ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">在物理打印机上打印演示文稿</p>
   </div>
   <div class="col-lg-12">
    <h2 class="h2title">系统要求</h2>
    <ul>
      <li>Aspose.Slides for Node.js via .NET 是基于 Node.js 的服务器端 JavaScript API。它可以在.NET6或更高版本的Windows、Unix/Linux和Mac平台上运行。</li>
    </ul>
   </div>
   <div class="col-lg-12">
    <h2 class="h2title">如何安装</h2>
    <p>使用 <strong>NPM</strong> 从 <a href="https://www.npmjs.com/package/aspose.slides.via.net">NPM 软件包存储库安装用于演示处理的 Node.js 库：</a></p>
    <pre><code>npm install aspose.slides.via.net</code></pre>
   </div>
    <div class="col-lg-12">
        <h2 class="h2title">如何在 Node.js 中创建新的 PowerPoint 演示文稿</h2>
        <p>在下面给出的示例中，我们在演示文稿的第一张幻灯片中添加了一个矩形。</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation, SaveFormat, ShapeType } = asposeSlides;

var pres = new Presentation();
try
{
    var slide = pres.slides.get(0);
    slide.shapes.addAutoShape(ShapeType.Rectangle, 50, 150, 300, 200);

    pres.save("pres.pptx", SaveFormat.Pptx);
}
finally
{
    if (pres != null) pres.dispose();
}
            </code>
        </pre>
    </div>

    <div class="col-lg-12">
        <h2 class="h2title">如何在 Node.js 中添加/删除/克隆幻灯片并编辑形状属性</h2>
        <p>此 Node.js 代码向您展示了如何编辑各种属性和克隆幻灯片：</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation, BackgroundType, FillType, ImageFormat } = asposeSlides;

var pres = new Presentation();
try
{
    // Add an empty slide to the presentation
    pres.slides.addEmptySlide(pres.layoutSlides.get(0));

    // Create another presentation and add its clone into the pres
    var pres2 = new Presentation();
    pres.slides.addClone(pres2.slides.get(0));

    // Access and modify properties of the first slide in pres
    var slide = pres.slides.get(0); // Get the first slide
    var slideNumber = slide.slideNumber; // Get slide number
    var hidden = slide.hidden; // Check if the slide is hidden

    // Set the background of the first slide
    slide.background.type = BackgroundType.OwnBackground; // Set background type
    slide.background.fillFormat.fillType = FillType.Solid; // Set fill type to solid
    slide.background.fillFormat.solidFillColor.color = "#AEC025F4"; // Set a solid fill color
}
finally
{
    if (pres != null) pres.dispose();
}
            </code>
        </pre>
    </div>

    <div class="col-lg-12">
        <h2 class="h2title">如何在 Node.js 中将 PowerPoint 转换为 PDF</h2>
        <p>此 Node.js 代码向您展示如何将 PowerPoint 转换为 PDF 文档</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation, SaveFormat } = asposeSlides;

var pres = new Presentation("pres.pptx");
try
{
    pres.save("pres.pdf", SaveFormat.Pdf);
}
finally
{
    if (pres != null) pres.dispose();
}
            </code>
        </pre>
    </div>

    <div class="col-lg-12">
        <h2 class="h2title">如何在 Node.js 中将 PowerPoint 转换为 GIF</h2>
        <p>此 Node.js 代码向您展示如何将 PowerPoint 转换为 GIF 图像</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation, SaveFormat } = asposeSlides;

var pres = new Presentation("pres.pptx");
try
{
    pres.save("pres.gif", SaveFormat.Gif);
}
finally
{
    if (pres != null) pres.dispose();
}
            </code>
        </pre>
    </div>

    <div class="col-lg-12">
        <h2 class="h2title">如何在 Node.js 中将 PowerPoint 转换为 HTML</h2>
        <p>此 Node.js 代码向您展示如何将 PowerPoint 转换为 HTML 文档</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation, SaveFormat } = asposeSlides;

var pres = new Presentation("pres.pptx");
try
{
    pres.save("pres.html", SaveFormat.Html);
}
finally
{
    if (pres != null) pres.dispose();
}
            </code>
        </pre>
    </div>

    <div class="col-lg-12">
        <h2 class="h2title">如何在 Node.js 中将 PowerPoint 转换为 ODP</h2>
        <p>此 Node.js 代码向您展示如何将 PowerPoint 转换为 ODP 文档</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation, SaveFormat } = asposeSlides;

var pres = new Presentation("pres.pptx");
try
{
    pres.save("pres.odp", SaveFormat.Odp);
}
finally
{
    if (pres != null) pres.dispose();
}
            </code>
        </pre>
    </div>

    <div class="col-lg-12">
        <h2 class="h2title">如何在 Node.js 中合并演示文稿</h2>
        <p>此 Node.js 代码向您展示了如何合并演示文稿：</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation, SaveFormat } = asposeSlides;

var pres1 = new Presentation("pres1.pptx");
var pres2 = new Presentation("pres2.pptx");
try
{
    for (var i = 0; i < pres2.slides.length; i++)
    {
        pres1.slides.addClone(pres2.slides.get(i));
    }

    pres1.save("combinedPresentation.pptx", SaveFormat.Pptx);
}
finally
{
    if (pres1 != null) pres1.dispose();
    if (pres2 != null) pres2.dispose();
}
            </code>
        </pre>
    </div>

    <div class="col-lg-12">
        <h2 class="h2title">如何检索 PowerPoint 演示文稿的各种属性 </h2>
        <p>以下示例向您展示如何检索 PowerPoint 演示文稿的各种属性。</p>
        <pre>
            <code class="JavaScript">
const asposeSlides = require('aspose.slides.via.net');

const { Presentation } = asposeSlides;

var pres = new Presentation("pres.pptx");
try
{
    // Retrieve various properties of the presentation
    var countSlides = pres.slides.count; // Total number of slides
    var countMastersSlides = pres.masters.count; // Total number of master slides
    var countLayoutSlides = pres.layoutSlides.count; // Total number of layout slides
    var firstSlideNumber = pres.firstSlideNumber; // Number of the first slide
    var lastView = pres.viewProperties.lastView; // Last view type of the presentation
    var masterThemeName = pres.masterTheme.name; // Name of the master theme
    var sourceFormat = pres.sourceFormat; // Format of the source presentation
    var countVideos = pres.videos.count; // Total number of videos in the presentation
    var countImages = pres.images.count; // Total number of images in the presentation

    // Retrieve objects for further manipulation or information extraction
    var slideObject = pres.slides.get(0); // Object of the first slide
    var mastersSlideObject = pres.masters.get(0); // Object of the first master slide

    // Log the total number of slides to the console
    console.log("countSlides:" + countSlides);
    console.log("countMastersSlides:" + countMastersSlides);
    console.log("countLayoutSlides:" + countLayoutSlides);
    console.log("firstSlideNumber:" + firstSlideNumber);
    console.log("lastView=" + lastView);
    console.log("masterThemeName:" + masterThemeName);
    console.log("sourceFormat:" + sourceFormat);
    console.log("countVideos:" + countVideos);
    console.log("countImages:" + countImages);
}
finally
{
    if (pres != null) pres.dispose();
}
            </code>
        </pre>
    </div>
  </div>
 </div>
</div>
