Unity3D之日常操作-Aspose.Words.dll-U3D读写word

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

记录日常操作。而且发现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 
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值