导出手册报错,logoUrl优化

This commit is contained in:
yujh 2024-11-07 14:27:43 +08:00
parent 78afcec93b
commit 438f217a77

View File

@ -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);