用于演示的 Node.js PowerPoint API
使用 Node.js 创建、阅读、修改和转换 PowerPoint 和 OpenOffice 演示文稿,无需任何外部软件。
Download Free TrialAspose.Slides for Node.js via .NET 是一个 Node.js 库,可让您在 Node.js 中创建、修改和转换 PowerPoint 演示文稿。它支持所有演示元素,例如幻灯片、形状、文本、图表、表格、图像等。它还提供许多高级功能,例如合并、克隆、拆分、比较和打印演示文稿。它的工作没有任何依赖性,可以在短时间内处理数千个演示文稿。
Aspose.Slides for Node.js via .NET 提供以下流行功能:
- 加载、打开和查看演示文稿。
 - 编辑演示文稿。
 - 将演示文稿文件转换为流行的演示文稿格式,例如 PPT、PPTX 和 ODP。
 - 将演示文稿导出为 PDF、JPG、HTML、GIF、SVG 和许多其他格式。
 - 渲染和打印演示文稿。
 - 加密和解密演示文稿;密码保护演示文稿并删除密码。
 - 操作演示实体,例如主幻灯片、形状、图表、图片框架、音频框架、视频框架、OLE、VBA 宏、动画等。
 - 还有更多功能。
 
Node.js 是一种流行的、免费的、开源的、跨平台的 JavaScript 运行时环境,允许开发人员在浏览器之外编写命令行工具和服务器端脚本。因此,Aspose.Slides 团队很自豪能够向 Node.js 社区提供Aspose.Slides for Node.js via .NET。
高级 Node.js PowerPoint API 功能
从模板创建或克隆现有幻灯片
通过 API 使用 PowerPoint 表格
应用或删除形状上的保护
将 Excel 图表作为 OleObject 到幻灯片
创建形状幻灯片上的形状添加文本
处理文本和形状格式
从数据库生成演示文稿
保护演示并生成的 PDF
在物理打印机上打印演示文稿
系统要求
- Aspose.Slides for Node.js via .NET 是基于 Node.js 的服务器端 JavaScript API。它可以在.NET6或更高版本的Windows、Unix/Linux和Mac平台上运行。
 
如何在 Node.js 中创建新的 PowerPoint 演示文稿
在下面给出的示例中,我们在演示文稿的第一张幻灯片中添加了一个矩形。
            	
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();
}
            
        如何在 Node.js 中添加/删除/克隆幻灯片并编辑形状属性
此 Node.js 代码向您展示了如何编辑各种属性和克隆幻灯片:
            
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();
}
            
        如何在 Node.js 中将 PowerPoint 转换为 PDF
此 Node.js 代码向您展示如何将 PowerPoint 转换为 PDF 文档
            
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();
}
            
        如何在 Node.js 中将 PowerPoint 转换为 GIF
此 Node.js 代码向您展示如何将 PowerPoint 转换为 GIF 图像
            
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();
}
            
        如何在 Node.js 中将 PowerPoint 转换为 HTML
此 Node.js 代码向您展示如何将 PowerPoint 转换为 HTML 文档
            
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();
}
            
        如何在 Node.js 中将 PowerPoint 转换为 ODP
此 Node.js 代码向您展示如何将 PowerPoint 转换为 ODP 文档
            
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();
}
            
        如何在 Node.js 中合并演示文稿
此 Node.js 代码向您展示了如何合并演示文稿:
            
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();
}
            
        如何检索 PowerPoint 演示文稿的各种属性
以下示例向您展示如何检索 PowerPoint 演示文稿的各种属性。
            
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();
}