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


边栏推荐
- Flutter Widget 如何启用和屏蔽点击事件
- C语言实现!20000用4秒计算
- The meaning and trigger conditions of gc
- 华硕和微星多款产品将升级英特尔Arc A380和A310显卡
- 7. SAP ABAP OData 服务如何支持 $orderby (排序)操作
- Guangyu Mingdao was selected into the list of pilot demonstration projects for the development of digital economy industry in Chongqing in 2022
- 机器学习 | MATLAB实现支持向量机回归RegressionSVM参数设定
- 在线GC日志分析工具——GCeasy
- Google Earth Engine——给影像添加一个属性对于单景的时间序列并返回影像
- C#/VB.NET convert PPT or PPTX to image
猜你喜欢
7. SAP ABAP OData 服务如何支持 $orderby (排序)操作
什么是步进电机?40张图带你了解!
Promise learning (4) The ultimate solution for asynchronous programming async + await: write asynchronous code in a synchronous way
2022年中盘点 | 产品打底,科技背书,广汽集团阔步向前
gc的意义和触发条件
Android 安全与防护策略
WPF 截图控件之绘制箭头(五)「仿微信」
小程序毕设作品之微信美食菜谱小程序毕业设计成品(4)开题报告
Promise learning (2) An article takes you to quickly understand the common APIs in Promise
STM32 Personal Notes - Watchdog
随机推荐
千万级乘客排队系统重构&压测方案——总结篇
世界第4疯狂的科学家,在103岁生日那天去世了
Introduction to data warehouse layering (real-time data warehouse architecture)
xss漏洞学习
Promise learning (2) An article takes you to quickly understand the common APIs in Promise
招聘随想2022
MFC implementation road map navigation system
LeakCanary如何监听Service、Root View销毁时机?
Solve vscode input! Unable to quickly generate skeletons (three methods for the new version of vscode to quickly generate skeletons)
EasyRecovery热门免费数据检测修复软件
Pve delete virtual machine "for a collection"
一篇文章,带你详细了解华为认证体系证书(2)
Jenkins安装插件遇到的问题
如何设计一个分布式 ID 发号器?
阿里腾讯面试一二
线上问题排查常用命令,总结太全了,建议收藏!!
Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器
For small applications, which database is better to use?
URL.createObjectURL、URL.revokeObjectURL、Uint8Array、Blob使用详解
Qt supports HEIC/HEIF format images