当前位置:网站首页>C#/VB.NET 将PPT或PPTX转换为图像
C#/VB.NET 将PPT或PPTX转换为图像
2022-08-01 10:52:00 【InfoQ】
C#/VB.NET 将PPT或PPTX转换为图像
安装 Spire.Presentation for .NET
将PPT或PPTX转换为PNG
using Spire.Presentation;
using System;
using System.Drawing;
using System.Drawing.Imaging;
namespace ConvertPowerPointToPng
{
class Program
{
static void Main(string[] args)
{
//初始化Presentation实例
Presentation presentation = new Presentation();
//加载一个PowerPoint文档
presentation.LoadFromFile("模板.pptx");
//遍历PowerPoint文档中的幻灯片并保存为PNG图片
for (int i = 0; i < presentation.Slides.Count; i++)
{
Image image = presentation.Slides[i].SaveAsImage();
String fileName = String.Format("图片{0}.png", i);
image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
}
}
}
}
Imports Spire.Presentation
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Namespace ConvertPowerPointToPng
Class Program
Shared Sub Main(ByVal args() As String)
'初始化Presentation实例
Dim presentation As Presentation = New Presentation()
'加载一个PowerPoint文档
presentation.LoadFromFile("模板.pptx")
'遍历PowerPoint文档中的幻灯片并保存为PNG图片
Dim i As Integer
For i = 0 To presentation.Slides.Count- 1 Step i + 1
Dim image As Image = presentation.Slides(i).SaveAsImage()
Dim fileName As String = String.Format("图片{0}.png",i)
image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png)
Next
End Sub
End Class
End Namespace


将PPT或PPTX转换为SVG
using System.Collections.Generic;
using System.IO;
namespace PPTtoSVG
{
class Program
{
static void Main(string[] args)
{
//初始化Presentation实例
Presentation presentation = new Presentation();
//加载一个PowerPoint文档
presentation.LoadFromFile("模板.pptx");
//将PowerPoint转换为SVG图像并以字节形式存储在列队中
Queue<byte[]> svgBytes = presentation.SaveToSVG();
//获取列队中字节数组生成SVG文件
int len = svgBytes.Count;
for (int i = 0; i < len; i++)
{
FileStream fs = new FileStream(string.Format("图片-{0}.svg", i), FileMode.Create);
byte[] bytes = svgBytes.Dequeue();
fs.Write(bytes, 0, bytes.Length);
presentation.Dispose();
}
}
}
}
Imports System.Collections.Generic
Imports System.IO
Namespace PPTtoSVG
Class Program
Shared Sub Main(ByVal args() As String)
'初始化Presentation实例
Dim presentation As Presentation = New Presentation()
'加载一个PowerPoint文档
presentation.LoadFromFile("模板.pptx")
'将PowerPoint转换为SVG图像并以字节形式存储在列队中
Dim svgBytes()> As Queue<byte = presentation.SaveToSVG()
'获取列队中字节数组生成SVG文件
Dim len As Integer = svgBytes.Count
Dim i As Integer
For i = 0 To len- 1 Step i + 1
Dim fs As FileStream = New FileStream(String.Format("图片-{0}.svg",i),FileMode.Create)
Dim bytes() As Byte = svgBytes.Dequeue()
fs.Write(bytes, 0, bytes.Length)
presentation.Dispose()
Next
End Sub
End Class
End Namespace

边栏推荐
- 2022年7月31日--使用C#迈出第一步--使用 C# 创建具有约定、空格和注释的易读代码
- EasyRecovery热门免费数据检测修复软件
- 2022年中盘点 | 产品打底,科技背书,广汽集团阔步向前
- 基于ModelArts的物体检测YOLOv3实践【玩转华为云】
- [Cloud Residency Co-Creation] Huawei Cloud Global Scheduling Technology and Practice of Distributed Technology
- Flutter Widget 如何启用和屏蔽点击事件
- Golang内存分析工具gctrace和pprof实战
- Qt supports HEIC/HEIF format images
- ACL 2022 | 文本生成的相关前沿进展
- pve 删除虚拟机「建议收藏」
猜你喜欢

微信公众号授权登录后报redirect_uri参数错误的问题

CTFshow,命令执行:web37

CTO strongly banning the use of the Calendar, that in what?

LeakCanary如何监听Service、Root View销毁时机?
retired paddling

Why Metropolis–Hastings Works

Promise学习(三)Promise的几个关键性问题 -- 状态改变、执行顺序与机制、多任务串联、异常穿透、中断promise链

Qt supports HEIC/HEIF format images

CTFshow,命令执行:web32

【likeshop】回收租凭系统100%开源无加密 商城+回收+租赁
随机推荐
Flutter Widget 如何启用和屏蔽点击事件
shell--第九章练习
2022年7月31日--使用C#迈出第一步--使用C#中的数组和foreach语句来存储和循环访问数据序列
.NET性能优化-使用SourceGenerator-Logger记录日志
广域铭岛入选2022年重庆市数字经济产业发展试点示范项目名单
Guangyu Mingdao was selected into the list of pilot demonstration projects for the development of digital economy industry in Chongqing in 2022
Small application project works WeChat gourmet recipes applet graduation design of finished product (1) the development profile
记一次 .NET 某智慧物流WCS系统CPU爆高分析
昇思大模型体验平台初体验——以小模型LeNet为例
pve 删除虚拟机「建议收藏」
Promise learning (2) An article takes you to quickly understand the common APIs in Promise
PowerPC技术与市场杂谈
一文说明白ECDSA spec256k1 spec256r1 EdDSA ed25519千丝万缕的关系
利用正则表达式的回溯实现绕过
Android 安全与防护策略
爱可可AI前沿推介(8.1)
RK3399 platform development series on introduction to (kernel) 1.52, printk function analysis - the function call will be closed
Qt supports HEIC/HEIF format images
关于#SQL#的问题,如何解决?
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions