|
@@ -44,6 +44,13 @@ public class WordToPdfUtil {
|
|
|
// 创建一个Document对象,指定要转换的Word文档路径。
|
|
|
//要转换的word文件
|
|
|
Document doc = new Document(wordPath);
|
|
|
+ // 获取目录样式,例如 "TOC 1"
|
|
|
+ Style tocStyle = doc.getStyles().getByStyleIdentifier(StyleIdentifier.TOC_1);
|
|
|
+
|
|
|
+ // 设置字体加粗
|
|
|
+ tocStyle.getFont().setBold(true);
|
|
|
+ tocStyle.getFont().setSize(12); // 可以设置其他字体属性,如大小
|
|
|
+
|
|
|
doc.updateFields();//更新目录
|
|
|
doc.save(wordPath, SaveFormat.DOCX);
|
|
|
// 将Word文档保存为PDF格式,写入到之前创建的PDF文件中。
|