java.lang.Object
com.aspose.words.OlePackage
public class OlePackage
To learn more, visit the Working with Ole Objects documentation article. Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// OLE objects allow us to open other files in the local file system using another installed application
// in our operating system by double-clicking on the shape that contains the OLE object in the document body.
// In this case, our external file will be a ZIP archive.
byte[] zipFileBytes = DocumentHelper.getBytesFromStream(new FileInputStream(getDatabaseDir() + "cat001.zip"));
InputStream stream = new ByteArrayInputStream(zipFileBytes);
InputStream representingImage = new FileInputStream(getImageDir() + "Logo.jpg");
try {
Shape shape = builder.insertOleObject(stream, "Package", true, representingImage);
OlePackage setOlePackage = shape.getOleFormat().getOlePackage();
setOlePackage.setFileName("Package file name.zip");
setOlePackage.setDisplayName("Package display name.zip");
doc.save(getArtifactsDir() + "Shape.InsertOlePackage.docx");
} finally {
if (stream != null) {
stream.close();
}
}
| Property Getters/Setters Summary | ||
|---|---|---|
java.lang.String | getDisplayName() | |
void | setDisplayName(java.lang.String value) | |
| Gets or sets OLE Package display name. | ||
java.lang.String | getFileName() | |
void | setFileName(java.lang.String value) | |
| Gets or sets OLE Package file name. | ||
| Property Getters/Setters Detail |
|---|
getDisplayName/setDisplayName | |
public java.lang.String getDisplayName() / public void setDisplayName(java.lang.String value) | |
Example:
Shows how insert an OLE object into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// OLE objects allow us to open other files in the local file system using another installed application
// in our operating system by double-clicking on the shape that contains the OLE object in the document body.
// In this case, our external file will be a ZIP archive.
byte[] zipFileBytes = DocumentHelper.getBytesFromStream(new FileInputStream(getDatabaseDir() + "cat001.zip"));
InputStream stream = new ByteArrayInputStream(zipFileBytes);
InputStream representingImage = new FileInputStream(getImageDir() + "Logo.jpg");
try {
Shape shape = builder.insertOleObject(stream, "Package", true, representingImage);
OlePackage setOlePackage = shape.getOleFormat().getOlePackage();
setOlePackage.setFileName("Package file name.zip");
setOlePackage.setDisplayName("Package display name.zip");
doc.save(getArtifactsDir() + "Shape.InsertOlePackage.docx");
} finally {
if (stream != null) {
stream.close();
}
}getFileName/setFileName | |
public java.lang.String getFileName() / public void setFileName(java.lang.String value) | |
Example:
Shows how insert an OLE object into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// OLE objects allow us to open other files in the local file system using another installed application
// in our operating system by double-clicking on the shape that contains the OLE object in the document body.
// In this case, our external file will be a ZIP archive.
byte[] zipFileBytes = DocumentHelper.getBytesFromStream(new FileInputStream(getDatabaseDir() + "cat001.zip"));
InputStream stream = new ByteArrayInputStream(zipFileBytes);
InputStream representingImage = new FileInputStream(getImageDir() + "Logo.jpg");
try {
Shape shape = builder.insertOleObject(stream, "Package", true, representingImage);
OlePackage setOlePackage = shape.getOleFormat().getOlePackage();
setOlePackage.setFileName("Package file name.zip");
setOlePackage.setDisplayName("Package display name.zip");
doc.save(getArtifactsDir() + "Shape.InsertOlePackage.docx");
} finally {
if (stream != null) {
stream.close();
}
}