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;
}
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 ?
There's no way to do this directly with DocFlavor
Take a look to the POI Project
A better answer than POI is to use docx4j
http://www.docx4java.org/trac/docx4j
The reason for this is because it has all of the API necessary for getting to the different parts of the docx package.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.