From 438f217a776f1630faef67b78bd7c3a52b51ccb6 Mon Sep 17 00:00:00 2001 From: yujh Date: Thu, 7 Nov 2024 14:27:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=89=8B=E5=86=8C=E6=8A=A5?= =?UTF-8?q?=E9=94=99=EF=BC=8ClogoUrl=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pal/pal/output/util/OutputWordUtil.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java index fb5d015a..b8d9b912 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java @@ -46,6 +46,7 @@ import com.sini.com.spire.doc.fields.TextRange; import com.sini.com.spire.doc.formatting.CharacterFormat; import com.sini.com.spire.doc.formatting.ParagraphFormat; import com.sini.com.spire.doc.formatting.RowFormat; +import com.sini.com.spire.doc.interfaces.IParagraph; import com.sini.com.spire.doc.interfaces.ITextRange; import freemarker.template.Configuration; import freemarker.template.Template; @@ -701,19 +702,14 @@ public class OutputWordUtil { System.out.println("HEADERFONT = " + text); cell.getParagraphs().get(0).setText(dataMap.getString("HEADERFONT")); //页眉logo - TableCell cellImg = table.getRows().get(0).getCells().get(1); - //创建 DocPicture 类的对象 - DocPicture picture = new DocPicture(templateDoc); - String logoUrl = dataMap.getString("LOGOURL"); - picture.loadImage(logoUrl); - //设置图片大小 - picture.setWidth(75); - picture.setHeight(90); - //将图片文本环绕方式设置为四周环绕 - picture.setTextWrappingStyle(TextWrappingStyle.Square); - //将图片插入到第二段 - cellImg.getChildObjects().insert(0,picture); + TableCell cellImg = table.getRows().get(0).getCells().get(1); + IParagraph firstParagraph = cellImg.getFirstParagraph(); + //进行替换 + firstParagraph.getChildObjects().removeAt(0); + DocPicture picture = firstParagraph.appendPicture(logoUrl); + picture.setWidth(44); + picture.setHeight(35); } DocumentObject obj = sourceHeader.getChildObjects().get(j).deepClone(); targetHeader.getChildObjects().add(obj);