Hi POI user,

I use XWPFDocument to convert it to pdf and it works great. XWPFDocument
constructor waits :

 * InputStream
 * OPCPackage

In my case I have already loaded docx in a custom ZipArchive  (which
contains each zip entry in a Map) and I would like to use it instead of
transforming my custom MyZipArchive  to InputStream (I use byte array for
that) to call XWPFDocument (InputStream).

So I would like to do :

-----------------------------------------------------
MyZipArchive zipArchive = ...
XWPFDocument  document = new XWPFDocument (zipArchive )
-----------------------------------------------------

instead of doing :

-----------------------------------------------------
MyZipArchive zipArchive = ...
InputStream in = zipArchive .toInputStream(); // use byte array for that
XWPFDocument  document = new XWPFDocument (in )
-----------------------------------------------------

So I have tried to extends OPCPackage by creating MyZipPackage (like you
have done with your ZipPackage). But I cannot do that because of this code:

-----------------------------------------------------

OPCPackage(PackageAccess access) {
  if (getClass() != ZipPackage.class) {

    throw new IllegalArgumentException("PackageBase may not be subclassed");
  }
  init();
  this.packageAccess = access;
}

-----------------------------------------------------

I tell me why we cannot creates my own MyZipPackage?

Many thank's for your help.

Regards Angelo

Reply via email to