|
|
@@ -444,6 +444,9 @@ public class PrintServiceImpl implements PrintService {
|
|
|
for (Element textElement : textElements) {
|
|
|
// 获取font节点
|
|
|
Element fontElement = (Element) textElement.selectSingleNode("*[name()='font']");
|
|
|
+ if (fontElement == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
// 将字体MSYahei改为Microsoft YaHei UI
|
|
|
Attribute fontName = fontElement.attribute("fontName");
|
|
|
if (Objects.equals(fontName.getText(), "MSYahei")) {
|
|
|
@@ -456,11 +459,25 @@ public class PrintServiceImpl implements PrintService {
|
|
|
// 如果textElement节点指定isStretchWithOverflow为true(可换行),则调整行距
|
|
|
Attribute isStretchWithOverflow = parent.attribute("isStretchWithOverflow");
|
|
|
if (isStretchWithOverflow != null && Objects.equals(isStretchWithOverflow.getText(), "true")) {
|
|
|
- // 添加节点paragraph,调整行距为固定值12磅
|
|
|
- Element paragraphElement = new DefaultElement("paragraph", textElement.getNamespace());
|
|
|
- paragraphElement.addAttribute("lineSpacing", "Fixed");
|
|
|
- paragraphElement.addAttribute("lineSpacingSize", "12.0");
|
|
|
- textElement.add(paragraphElement);
|
|
|
+ // 修改paragraph节点
|
|
|
+ Element paragraphElement = (Element) textElement.selectSingleNode("*[name()='paragraph']");
|
|
|
+ if (paragraphElement == null) {
|
|
|
+ paragraphElement = new DefaultElement("paragraph", textElement.getNamespace());
|
|
|
+ textElement.add(paragraphElement);
|
|
|
+ }
|
|
|
+ // 调整行距为固定值12磅
|
|
|
+ Attribute lineSpacing = paragraphElement.attribute("lineSpacing");
|
|
|
+ if (lineSpacing != null) {
|
|
|
+ lineSpacing.setText("Fixed");
|
|
|
+ } else {
|
|
|
+ paragraphElement.addAttribute("lineSpacing", "Fixed");
|
|
|
+ }
|
|
|
+ Attribute lineSpacingSize = paragraphElement.attribute("lineSpacingSize");
|
|
|
+ if (lineSpacingSize != null) {
|
|
|
+ lineSpacingSize.setText("12.0");
|
|
|
+ } else {
|
|
|
+ paragraphElement.addAttribute("lineSpacingSize", "12.0");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|