Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:37:18+00:00 2026-06-11T01:37:18+00:00

Thanks to a previous answer , I’m now able to read my password-protected Word

  • 0

Thanks to a previous answer, I’m now able to read my password-protected Word 2010 documents. (I have to translate them one by one from .doc to .docx. They go back to 1994, but that’s okay.)

I wrote a simple Java class to get started:

package model.docx4j;

import model.JournalEntry;
import model.JournalEntryFactory;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.OpcPackage;
import org.docx4j.openpackaging.parts.Parts;

import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.util.LinkedList;
import java.util.List;

/**
 * JournalEntryFactoryImpl using docx4j
 * @author Michael
 * @link
 * @since 9/8/12 12:44 PM
 */
public class JournalEntryFactoryImpl implements JournalEntryFactory {
    @Override
    public List<JournalEntry> getEntries(InputStream inputStream, String password) throws IOException, GeneralSecurityException {
        List<JournalEntry> journalEntries = new LinkedList<JournalEntry>();
        if (inputStream != null) {
            try {
                OpcPackage opcPackage = OpcPackage.load(inputStream, password);
                Parts parts = opcPackage.getParts();
            } catch (Docx4JException e) {
                LOGGER.error("Could not load document into docx4j", e);
                throw new IOException(e);
            }
        }
        return journalEntries;
    }
}

And a JUnit test to drive it:

package model.docx4j;

import model.JournalEntry;
import model.JournalEntryFactory;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.OpcPackage;
import org.docx4j.openpackaging.parts.Parts;

import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.util.LinkedList;
import java.util.List;

/**
 * JournalEntryFactoryImpl using docx4j
 * @author Michael
 * @link
 * @since 9/8/12 12:44 PM
 */
public class JournalEntryFactoryImpl implements JournalEntryFactory {
    @Override
    public List<JournalEntry> getEntries(InputStream inputStream, String password) throws IOException, GeneralSecurityException {
        List<JournalEntry> journalEntries = new LinkedList<JournalEntry>();
        if (inputStream != null) {
            try {
                OpcPackage opcPackage = OpcPackage.load(inputStream, password);
                Parts parts = opcPackage.getParts();
            } catch (Docx4JException e) {
                LOGGER.error("Could not load document into docx4j", e);
                throw new IOException(e);
            }
        }
        return journalEntries;
    }
}

I put a breakpoint into the test to see what docx4j was doing once it read my document. I see a list of 8 parts, but I walked through the tree without finding the content.

Each document consists of a page with a date and content, but I can’t find pages. Where do they live?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:37:20+00:00Added an answer on June 11, 2026 at 1:37 am

    The main document content lives in the “main document part”, which is often named “/word/document.xml”.

    The usual way to get it with docx4j is:

    WordprocessingMLPackage wordMLPackage = (WordprocessingMLPackage)opcPackage;
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
    

    but you’d expect your approach to work as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have fit a regression using lme4 thanks to a previous answer . Now
I have come across html2canvas thanks to a previous question of mine. What I
Thanks to the epic work of Dennis Williamson, I am now able to calculate
I have the following code adapted from a previous question/answer: var str = $('title').text();
In a previous question I have found an answer for a hacked - but
Thanks to a previous answer, I can test if a file exists using if
Thanks to Insin for answering a previous question related to this one. His answer
This post is linked to my previous one . I was able thanks to
Thanks for your answers to my previous question about GUI in java . I
Thanks for previous replies, I tried to check the data connection through code, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.