【新增】 EMU与PT之间的单位转换

This commit is contained in:
dlaren
2025-09-02 09:23:53 +08:00
parent 4906764628
commit 3707608860
2 changed files with 19 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import org.docx4j.dml.*;
import org.docx4j.jaxb.XPathBinderAssociationIsPartialException;
import org.pptx4j.pml.*;
import pc.exam.pp.module.judgement.utils.wps_pptx.pptx4j.utils.PtToCmConverter;
import pc.exam.pp.module.judgement.utils.wps_pptx.pptx4j.utils.PtToEmuConverter;
import pc.exam.pp.module.judgement.utils.wps_pptx.pptx4j.utils.Transition;
import java.math.BigInteger;
@@ -945,8 +946,10 @@ public class ShapePage {
CTTextBody textBody = sp.getTxBody();
// 遍历所有段落
for (CTTextParagraph paragraph : textBody.getP()) {
if (paragraph.getPPr().getSpcBef() != null) {
return String.valueOf(paragraph.getPPr().getSpcBef().getSpcPts().getVal());
if (paragraph.getPPr().getMarL() != null) {
// EMU转磅
double pt = PtToEmuConverter.emuToPt(paragraph.getPPr().getMarL());
return pt + "";
}
}
}

View File

@@ -0,0 +1,14 @@
package pc.exam.pp.module.judgement.utils.wps_pptx.pptx4j.utils;
public class PtToEmuConverter {
// 基础转换常数
public static final double EMU = 12700;
public static double ptToEmu(double pt) {
return pt * EMU;
}
public static double emuToPt(double emu) {
return emu / EMU;
}
}