记录日常操作。而且发现Aspose.Words.dll 关于U3D 的帖子不是太多,再此分享下,也算记录下防止自己日后忘记。
直接展示用法和代码
dll:
Aspose.Words.dll 解析word的核心
I18N.dll、I18N.CJK.dll、I18N.West.dll 这三个为辅助,否则打包后会报错。
ReplaceAndInsertImage 类 引用其他帖子,不过我又加了改进,新增了重载及宽高
public class ReplaceAndInsertImage : IReplacingCallback
{
public enum ImageType
{
File,
Byte,
Stream
}
public ImageType type;
/// <summary>
/// 需要插入的图片路径
/// </summary>
public string url {
get; set; }
public byte[] Byt {
get; set; }
public Stream Strea {
get; set; }
public double W {
get; set; }
public double H {
get; set; }
public ReplaceAndInsertImage( string url,double w=20d,double h = 20d, ImageType imageType=ImageType.File)
{
this.W = w;
this.H = h;
this.url = url;
this.type = imageType;
}
public ReplaceAndInsertImage( byte[] byt, double w = 20d, double h = 20d, ImageType imageType=ImageType.Byte)
{
this.W = w;
this.H = h;
this.Byt = byt;
this.type = imageType;
}
public ReplaceAndInsertImage(Stream stre, double w = 20d, double h = 20d, ImageType imageType=ImageType.Stream)
{
this.W = w;
this.H = h;
this. Strea = stre;
this.type = imageType;
}
public ReplaceAction Replacing(ReplacingArgs e)
{
//获取当前节点
var node = e.MatchNode;
//获取当前文档
Document doc = node.Document

该博客详细介绍了如何在Unity3D环境中使用Aspose.Words.dll库来操作Word文档,包括内容替换、图片插入以及Word转图片的方法。通过示例代码展示了如何实现文字替换、不同方式插入图片(文件路径、字节数组、文件流)以及Word文档转换为PNG图片的完整流程。适用于Windows平台。
最低0.47元/天 解锁文章
1046

被折叠的 条评论
为什么被折叠?



