Cold_Class
Cold_Class

Reputation: 3484

Count pages/lines in a word file that was edited with docx4j

I found some posts here how to count pages/lines with the apache-poi library. But my code already uses docx4j right now, it would be too much work to completely replace that.

Therefore my question is, how can I get from an object of type WordprocessingMLPackage to an object of type XWPFDocument in order to count the lines and pages of my current document.

private XWPFDocument convertDocx4J(WordprocessingMLPackage wp) {
    XWPFDocument oiDoc = null;

    //TODO...

    return oiDoc;
}

Upvotes: 0

Views: 669

Answers (1)

JasonPlutext
JasonPlutext

Reputation: 15863

Easiest way to go from docx4j's WordprocessingMLPackage to POI would be to use docx4j's API to save as docx, then POI's to load.

But you can get page info from docx4j; see https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/toc/TocGenerator.java#L657

Upvotes: 1

Related Questions