我正在使用 apache poi CTPageMar 类将页边距设置为用户给定的某个值。问题是我没有找到必须在函数 setLeft、setRight、setTop 和 setBottom 中传递的值的单位。我试过厘米、像素、英寸,但它们似乎都错了。任何想法?
XWPFDocument wordDocument = new XWPFDocument(new FileInputStream(input));
CTSectPr sectPr = wordDocument.getDocument().getBody().addNewSectPr();
CTPageMar pageMar = sectPr.addNewPgMar();
pageMar.setLeft(BigInteger.valueOf(left));
pageMar.setTop(BigInteger.valueOf(top));
pageMar.setRight(BigInteger.valueOf(right));
pageMar.setBottom(BigInteger.valueOf(bottom));
wordDocument.write(new FileOutputStream(output));