fix:一人一档导出

This commit is contained in:
geh
2025-04-14 19:47:49 +08:00
parent 24390f1ea0
commit 4d7e4d1806
13 changed files with 1483 additions and 299 deletions
+37 -1
View File
@@ -8,6 +8,8 @@ using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Aspose.Words.Drawing;
using Shape = Aspose.Words.Drawing.Shape;
namespace BLL
{
@@ -29,6 +31,40 @@ namespace BLL
{
wordDoc = new Document(path);
}
/// <summary>
/// 添加图片
/// </summary>
/// <param name="filename">文件路径+文件名</param>
/// <param name="field">文本域名</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public void AddImage(string filename, string field, double width, double height, double left, double top)
{
DocumentBuilder builder = new DocumentBuilder(wordDoc);
Shape shape = new Shape(wordDoc, ShapeType.Image);
if (!string.IsNullOrEmpty(filename))
{
shape.ImageData.SetImage(filename);
shape.Width = width;//设置宽和高
shape.Height = height;
shape.Left = left;
shape.Top = top;
shape.WrapType = WrapType.None;
shape.BehindText = true;
builder.MoveToMergeField(field);
builder.InsertNode(shape);
}
else
{
//没有图片用空替换占位域值
builder.MoveToMergeField(field);
builder.Write("");
}
}
/// <summary>
/// 书签赋值用法
@@ -269,7 +305,7 @@ namespace BLL
/// </summary>
/// <param name="Html">html代码</param>
/// <param name="path">保存路径</param>
public static void HtmlIntoWord(string Html,string path)
public void HtmlIntoWord(string Html,string path)
{
StringBuilder sb = new StringBuilder();