java删除word空白页
时间: 2023-08-19 13:14:13 浏览: 271
java_jacob_操作word_文档
要使用Java删除Word文档中的空白页,可以使用Aspose.Words for Java提供的API。具体步骤如下:
```java
import com.aspose.words.Document;
public class DeleteBlankPage {
public static void main(String\[\] args) throws Exception {
// 加载Word文档
Document doc = new Document("filename.docx");
// 获取文档的页数
int pageCount = doc.getPageCount();
// 删除最后一页
doc.removePage(pageCount);
// 保存文档
doc.save("filename.docx");
}
}
```
以上代码会加载名为"filename.docx"的Word文档,然后计算文档的页数。接着,它会删除最后一页,并保存修改后的文档。这样就可以删除Word文档中的空白页了。\[2\]
#### 引用[.reference_title]
- *1* [Java POI 删除最后一页空白页](https://blog.csdn.net/qijingpei/article/details/81082014)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Aspose.Words删除word文档最后一页或者空白页](https://blog.csdn.net/Lemostic/article/details/130709714)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Word文档空白页删除方法总结](https://blog.csdn.net/Hugh_Guan/article/details/108772817)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文