https://issues.apache.org/bugzilla/show_bug.cgi?id=51780
Bug #: 51780
Summary: Feature Request: How to convert a dotx file to docx
via poi?
Product: POI
Version: 3.8-dev
Platform: PC
Status: NEW
Severity: normal
Priority: P2
Component: POI Overall
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
Created attachment 27465
--> https://issues.apache.org/bugzilla/attachment.cgi?id=27465
With this patch I am able to change the mimetype.
I can't found a solution with the unmodified poi code for the following
problem.
It should be possible to convert the following templates:
".dotx" to ".docx"
".dotm" to ".docm"
".xltx" to "xlsx"
".xltm" to ".xlsm"
".potx" to ".pptx"
".potm" to ".pptm"
I am able to do this after installing the attached patch.
Usage:
OPCPackage pack = new ZipPackage(stream, PackageAccess.READ_WRITE);
if (pack != null) {
pack.getParts();
ArrayList<PackagePart> list = pack.getPartsByContentType(oldContentType);
for (PackagePart packagePart : list) {
if (packagePart.getContentType().equals(oldContentType)) {
PackagePartName partName = packagePart.getPartName();
pack.getContenTypeManager().addContentType(partName, newContentType);
}
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(1024);
pack.save(outputStream);
//TODO save as file with the new file extention
}
Please include this patch for the next version or implement an other nicer way
to change the contenttype.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]