如何在Java中打印出DOCX文件? [英] How to print out a DOCX file in java?

查看:89
本文介绍了如何在Java中打印出DOCX文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一些Java代码,允许我打印png,pdf,jpg等,但是我卡在docx文件以及可能的其他文件类型上,

i have created some java code that allows me to print png,pdf,jpg etc but i am stuck on docx files and possibly other file types,

当前我正在使用以下代码:

currently i am using the code below :

 if (extension.equals("txt")) {
            psInFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
        } else if (extension.equals("png")) {
            psInFormat = DocFlavor.INPUT_STREAM.PNG;
        } else if (extension.equals("gif")) {
            psInFormat = DocFlavor.INPUT_STREAM.GIF;
        } else if (extension.equals("jpg")) {
            psInFormat = DocFlavor.INPUT_STREAM.JPEG;
        } else if (extension.equals("pdf")) {
            psInFormat = DocFlavor.INPUT_STREAM.PDF;
        }

要确定文件类型是哪种类型,以为该doc类型创建正确的输入流的ps,我可以修改此代码以包含doc文件吗?

to determine what the file type is to create the ps of the right input stream for that doc type, could i mod this code to include doc files ?

推荐答案

无法直接使用DocFlavor做到这一点

There's no way to do this directly with DocFlavor

看看POI项目

http://poi.apache.org/hwpf/index.html

这篇关于如何在Java中打印出DOCX文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆