public class OlePackage
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
byte[] zipFileBytes = Files.readAllBytes(Paths.get(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("Cat FileName.zip");
setOlePackage.setDisplayName("Cat DisplayName.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 ole object as ole package and set it file name and display name.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); byte[] zipFileBytes = Files.readAllBytes(Paths.get(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("Cat FileName.zip"); setOlePackage.setDisplayName("Cat DisplayName.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 ole object as ole package and set it file name and display name.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); byte[] zipFileBytes = Files.readAllBytes(Paths.get(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("Cat FileName.zip"); setOlePackage.setDisplayName("Cat DisplayName.zip"); doc.save(getArtifactsDir() + "Shape.InsertOlePackage.docx"); } finally { if (stream != null) { stream.close(); } }