by vinaykadiyam » Mon Aug 18, 2014 10:14 pm
Hi Jason,
Thanks for the reply.
1. I have gone through Docx_ole_Doc sample. But in that .doc is attached as either a link or an embed. But I want to merge the contents of the .doc file to generated .docx file. Is this possible? if answer is yes, How can I do that?
2. When can we expect insertion of xslx into docx?
3. Yes you are right, when we click on a icon it is shrinking (Please find attached generated doc).
private void addOleObjectToPackage(
WordprocessingMLPackage mlPackageWriteOnly2, byte[] bytes,
String fileType, String filePath, String caption) {
EmbeddingType embeddingType = null;
try {
embeddingType = EmbeddingType.valueOf(fileType);
} catch (IllegalArgumentException iae) {
embeddingType = EmbeddingType.TXT;
}
int index = -1;
byte[] imageBytes = null;
// 1. Fetch Rule Binary file from DB
ClipboardPage binaryImageFile = null;
StringMap keys = new HashStringMap();
String mime = null;
if ("vdx".equalsIgnoreCase(fileType)) {
keys.putString("pxObjClass", "Rule-File-Binary");
keys.putString("pyApplicationName", "webwb");
keys.putString("pyFileName", "openvisiolarge");
keys.putString("pyFileType", "png");
mime = "image/png";
} else if ("doc".equalsIgnoreCase(fileType)) {
keys.putString("pxObjClass", "Rule-File-Binary");
keys.putString("pyApplicationName", "webwb");
keys.putString("pyFileName", "pyWordDoc");
keys.putString("pyFileType", "png");
mime = "image/png";
} else if ("xslx".equalsIgnoreCase(fileType)
|| "xslx".equalsIgnoreCase(fileType)) {
keys.putString("pxObjClass", "Rule-File-Binary");
keys.putString("pyApplicationName", "webwb");
keys.putString("pyFileName", "pyExcelDoc");
keys.putString("pyFileType", "png");
mime = "image/png";
} else if ("pdf".equalsIgnoreCase(fileType)) {
keys.putString("pxObjClass", "Rule-File-Binary");
keys.putString("pyApplicationName", "webwb");
keys.putString("pyFileName", "pyCreatePDFAPIIcon");
keys.putString("pyFileType", "png");
mime = "image/png";
} else {
keys.putString("pxObjClass", "Rule-File-Binary");
keys.putString("pyApplicationName", "webwb");
keys.putString("pyFileName", "pzPreview");
keys.putString("pyFileType", "png");
mime = "image/png";
}
try {
binaryImageFile = localTools.getDatabase().open(keys, true);
} catch (DatabaseException dbEx) {
oLog.error("Error opening file: ", dbEx);
}
// TODO Change it to point to correct icon based upon the file type
String strFileData = binaryImageFile.getString("pyFileSource");
imageBytes = Base64Util.decodeToByteArray(strFileData);
// TODO change it to point to temp location of the server
// String fileLoc =
String command = filePath + caption + "." + fileType; // a temp file
// For link only
// String targetURL = "file:///" + command;
if ("pdf".equals(fileType)) {
com.plutext.ole.pdf.PdfOleHelperDocx pdfOleHelper = new com.plutext.ole.pdf.PdfOleHelperDocx(
mlPackageWriteOnly2);
try {
pdfOleHelper.embedUsingIcon(bytes, -1, caption);
} catch (com.plutext.ole.OLEException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if ("odf".equals(fileType)) {
com.plutext.ole.odf.OdfOleHelperDocx odfOleHelper = new com.plutext.ole.odf.OdfOleHelperDocx(
mlPackageWriteOnly2);
try {
odfOleHelper.embedUsingIcon(embeddingType, bytes, -1, caption);
} catch (com.plutext.ole.OLEException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
com.plutext.ole.OleHelperDocx OleHelperDocx = new com.plutext.ole.OleHelperDocx(
mlPackageWriteOnly2);
try {
OleHelperDocx.embed(index, embeddingType, caption, filePath,
command, bytes, imageBytes, mime,
"width:32pt;height:32pt");
} catch (com.plutext.ole.OLEException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Regards,
Vinay
- Attachments
-
- GeneratedDocWithPlutext.docx
- (26.51 KiB) Downloaded 479 times