当前位置:网站首页>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


边栏推荐
- activiti工作流的分页查询避坑
- Flutter Widget 如何启用和屏蔽点击事件
- July 31, 2022 -- Take your first steps with C# -- Use C# to create readable code with conventions, spaces, and comments
- jmeter
- 爱可可AI前沿推介(8.1)
- cisco交换机基本配置命令(华为交换机保存命令是什么)
- Promise learning (4) The ultimate solution for asynchronous programming async + await: write asynchronous code in a synchronous way
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(4)开题报告
- 一篇文章,带你详细了解华为认证体系证书(2)
- PowerPC技术与市场杂谈
猜你喜欢
CTFshow,命令执行:web37
小程序毕设作品之微信美食菜谱小程序毕业设计成品(2)小程序功能
冰冰学习笔记:gcc、gdb等工具的使用
【钛晨报】国家统计局:7月制造业PMI为49%;玖富旗下理财产品涉嫌欺诈,涉及390亿元;国内航线机票燃油附加费8月5日0时起下调
Qt supports HEIC/HEIF format images
Promise learning (1) What is Promise?how to use?How to solve callback hell?
进制与转换、关键字
Promise学习(一)Promise是什么?怎么用?回调地狱怎么解决?
AI篮球裁判火了,走步算得特别准,就问哈登慌不慌
Promise学习(三)Promise的几个关键性问题 -- 状态改变、执行顺序与机制、多任务串联、异常穿透、中断promise链
随机推荐
冰冰学习笔记:gcc、gdb等工具的使用
IntellJ IDEA如何显示换行符(line endings)
WTM:ASP.NET Core快速开发利器!
已解决(pip安装库报错)Consider using the-- user option or check the permissions.
力扣解法汇总1374-生成每种字符都是奇数个的字符串
C语言程序设计50例(三)(经典收藏)
redis6 跟着b站尚硅谷学习
广域铭岛入选2022年重庆市数字经济产业发展试点示范项目名单
Generate certificates using KeyStore
jmeter
浏览器快捷键大全
Endorsed in 2022 years inventory | product base, science and technology, guangzhou automobile group striding forward
Promise learning (1) What is Promise?how to use?How to solve callback hell?
C语言实现!20000用4秒计算
编码解码(btoa、encodeURIComponent、encodeURI、escape)
千万级乘客排队系统重构&压测方案——总结篇
CTFshow,命令执行:web32
机器学习 | MATLAB实现支持向量机回归RegressionSVM参数设定
Cross-domain network resource file download
解决vscode输入! 无法快捷生成骨架(新版vscode快速生成骨架的三种方法)