use of org.apache.poi.hwpf.HWPFDocumentCore in project poi by apache.
the class HWPFLister method main.
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.err.println("Use:");
System.err.println("\tHWPFLister <filename>\n" + "\t\t[--dop]\n" + "\t\t[--textPieces] [--textPiecesText]\n" + "\t\t[--chpx] [--chpxProperties] [--chpxSprms]\n" + "\t\t[--papx] [--papxProperties] [--papxSprms]\n" + "\t\t[--paragraphs] [--paragraphsText]\n" + "\t\t[--bookmarks]\n" + "\t\t[--escher]\n" + "\t\t[--fields]\n" + "\t\t[--pictures]\n" + "\t\t[--officeDrawings]\n" + "\t\t[--styles]\n" + "\t\t[--writereadback]\n");
System.exit(1);
}
boolean outputDop = false;
boolean outputTextPieces = false;
boolean outputTextPiecesText = false;
boolean outputChpx = false;
boolean outputChpxProperties = false;
boolean outputChpxSprms = false;
boolean outputParagraphs = false;
boolean outputParagraphsText = false;
boolean outputPapx = false;
boolean outputPapxSprms = false;
boolean outputPapxProperties = false;
boolean outputBookmarks = false;
boolean outputEscher = false;
boolean outputFields = false;
boolean outputPictures = false;
boolean outputOfficeDrawings = false;
boolean outputStyles = false;
boolean writereadback = false;
for (String arg : Arrays.asList(args).subList(1, args.length)) {
if ("--dop".equals(arg))
outputDop = true;
if ("--textPieces".equals(arg))
outputTextPieces = true;
if ("--textPiecesText".equals(arg))
outputTextPiecesText = true;
if ("--chpx".equals(arg))
outputChpx = true;
if ("--chpxProperties".equals(arg))
outputChpxProperties = true;
if ("--chpxSprms".equals(arg))
outputChpxSprms = true;
if ("--paragraphs".equals(arg))
outputParagraphs = true;
if ("--paragraphsText".equals(arg))
outputParagraphsText = true;
if ("--papx".equals(arg))
outputPapx = true;
if ("--papxProperties".equals(arg))
outputPapxProperties = true;
if ("--papxSprms".equals(arg))
outputPapxSprms = true;
if ("--bookmarks".equals(arg))
outputBookmarks = true;
if ("--escher".equals(arg))
outputEscher = true;
if ("--fields".equals(arg))
outputFields = true;
if ("--pictures".equals(arg))
outputPictures = true;
if ("--officeDrawings".equals(arg))
outputOfficeDrawings = true;
if ("--styles".equals(arg))
outputStyles = true;
if ("--writereadback".equals(arg))
writereadback = true;
}
HWPFDocumentCore doc = loadDoc(new File(args[0]));
if (writereadback)
doc = writeOutAndReadBack(doc);
HWPFDocumentCore original;
{
System.setProperty("org.apache.poi.hwpf.preserveBinTables", Boolean.TRUE.toString());
System.setProperty("org.apache.poi.hwpf.preserveTextTable", Boolean.TRUE.toString());
original = loadDoc(new File(args[0]));
if (writereadback)
original = writeOutAndReadBack(original);
}
HWPFLister listerOriginal = new HWPFLister(original);
HWPFLister listerRebuilded = new HWPFLister(doc);
System.out.println("== OLE streams ==");
listerOriginal.dumpFileSystem();
System.out.println("== FIB (original) ==");
listerOriginal.dumpFIB();
if (outputDop) {
System.out.println("== Document properties ==");
listerOriginal.dumpDop();
}
if (outputTextPieces) {
System.out.println("== Text pieces (original) ==");
listerOriginal.dumpTextPieces(outputTextPiecesText);
}
if (outputChpx) {
System.out.println("== CHPX (original) ==");
listerOriginal.dumpChpx(outputChpxProperties, outputChpxSprms);
System.out.println("== CHPX (rebuilded) ==");
listerRebuilded.dumpChpx(outputChpxProperties, outputChpxSprms);
}
if (outputPapx) {
System.out.println("== PAPX (original) ==");
listerOriginal.dumpPapx(outputPapxProperties, outputPapxSprms);
System.out.println("== PAPX (rebuilded) ==");
listerRebuilded.dumpPapx(outputPapxProperties, outputPapxSprms);
}
if (outputParagraphs) {
System.out.println("== Text paragraphs (original) ==");
listerRebuilded.dumpParagraphs(true);
System.out.println("== DOM paragraphs (rebuilded) ==");
listerRebuilded.dumpParagraphsDom(outputParagraphsText);
}
if (outputBookmarks) {
System.out.println("== BOOKMARKS (rebuilded) ==");
listerRebuilded.dumpBookmarks();
}
if (outputEscher) {
System.out.println("== ESCHER PROPERTIES (rebuilded) ==");
listerRebuilded.dumpEscher();
}
if (outputFields) {
System.out.println("== FIELDS (rebuilded) ==");
listerRebuilded.dumpFields();
}
if (outputOfficeDrawings) {
System.out.println("== OFFICE DRAWINGS (rebuilded) ==");
listerRebuilded.dumpOfficeDrawings();
}
if (outputPictures) {
System.out.println("== PICTURES (rebuilded) ==");
listerRebuilded.dumpPictures();
}
if (outputStyles) {
System.out.println("== STYLES (rebuilded) ==");
listerRebuilded.dumpStyles();
}
}
use of org.apache.poi.hwpf.HWPFDocumentCore in project poi by apache.
the class TestWordToConverterSuite method testText.
@Test
public void testText() throws Exception {
HWPFDocumentCore wordDocument;
try {
wordDocument = AbstractWordUtils.loadDoc(child);
} catch (Exception exc) {
return;
}
WordToTextConverter wordToTextConverter = new WordToTextConverter(XMLHelper.getDocumentBuilderFactory().newDocumentBuilder().newDocument());
wordToTextConverter.processDocument(wordDocument);
StringWriter stringWriter = new StringWriter();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "text");
transformer.transform(new DOMSource(wordToTextConverter.getDocument()), new StreamResult(stringWriter));
// no exceptions
assertNotNull(stringWriter.toString());
}
use of org.apache.poi.hwpf.HWPFDocumentCore in project poi by apache.
the class WordToHtmlConverter method process.
static Document process(File docFile) throws IOException, ParserConfigurationException {
final HWPFDocumentCore wordDocument = AbstractWordUtils.loadDoc(docFile);
WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(XMLHelper.getDocumentBuilderFactory().newDocumentBuilder().newDocument());
wordToHtmlConverter.processDocument(wordDocument);
return wordToHtmlConverter.getDocument();
}
use of org.apache.poi.hwpf.HWPFDocumentCore in project poi by apache.
the class WordToTextConverter method process.
static Document process(File docFile) throws Exception {
final HWPFDocumentCore wordDocument = AbstractWordUtils.loadDoc(docFile);
WordToTextConverter wordToTextConverter = new WordToTextConverter(XMLHelper.getDocumentBuilderFactory().newDocumentBuilder().newDocument());
wordToTextConverter.processDocument(wordDocument);
return wordToTextConverter.getDocument();
}
use of org.apache.poi.hwpf.HWPFDocumentCore in project poi by apache.
the class WordToFoConverter method process.
static Document process(File docFile) throws Exception {
final HWPFDocumentCore hwpfDocument = WordToFoUtils.loadDoc(docFile);
WordToFoConverter wordToFoConverter = new WordToFoConverter(XMLHelper.getDocumentBuilderFactory().newDocumentBuilder().newDocument());
wordToFoConverter.processDocument(hwpfDocument);
return wordToFoConverter.getDocument();
}
Aggregations