public class OlePackage
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.Stringvalue) | |
Gets or sets OLE Package display name. | ||
java.lang.String | getFileName() | |
void | setFileName(java.lang.Stringvalue) | |
Gets or sets OLE Package file name. |
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(); } }
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(); } }