为有中文需求的客户提供多渠道中文技术支持.

Thu Apr 27, 2023 9:40 am

现在的需求是给页面增加页脚 页脚由两部分文字+页码组成。 第一部分文字需要居左,第二部分是页码 居中显示 第三部分文字居右显示 ,如果使用Paragraph进行设置。

asdasdasdasdas
 
Posts: 4
Joined: Thu Apr 27, 2023 9:35 am

Fri Apr 28, 2023 6:29 am

您好,

感谢您的咨询。
针对您的需求,请参考以下代码:
Code: Select all
Document doc = new Document();
Section section = doc.addSection();
Paragraph paragraph = section.getHeadersFooters().getFooter().addParagraph();
// 需要根据您的文本宽度进行手动调整
paragraph.appendText("left\t\t\t\t\t\t");
paragraph.appendField("页码", FieldType.Field_Page);
paragraph.appendText("\t\t\t\t\t\tright");
paragraph.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
doc.saveToFile("test.docx", FileFormat.Docx_2013);


如果我提供的代码没有满足您的需求或者您还有其他问题,欢迎您随时咨询。

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to 中文技术支持

cron