com.aspose.words

Class OlePackage

  • java.lang.Object
    • com.aspose.words.OlePackage
public class OlePackage 
extends java.lang.Object

Allows to access OLE Package properties.
OLE package is a legacy and "undocumented" way to store embedded object if OLE handler is unknown. Early Windows versions such as Windows 3.1, 95 and 98 had Packager.exe application which could be used to embed any type of data into document. Now this application is excluded from Windows but MS Word and other applications still use it to embed data if OLE handler is missing or unknown.

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);
try /*JAVA: was using*/
{
    Shape shape = builder.insertOleObject(stream, "Package", true, null);

    OlePackage setOlePackage = shape.getOleFormat().getOlePackage();
    setOlePackage.setFileName("Cat FileName.zip");
    setOlePackage.setDisplayName("Cat DisplayName.zip");

    doc.save(getMyDir() + "\\Artifacts\\Shape.InsertOlePackage.docx");
} finally
{
    if (stream != null) stream.close();
}

Property Getters/Setters Summary
java.lang.StringgetDisplayName()
void
setDisplayName(java.lang.Stringvalue)
           Gets or sets OLE Package display name.
java.lang.StringgetFileName()
void
setFileName(java.lang.Stringvalue)
           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)
        
        Gets or sets OLE Package display name.

        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);
        try /*JAVA: was using*/
        {
            Shape shape = builder.insertOleObject(stream, "Package", true, null);
        
            OlePackage setOlePackage = shape.getOleFormat().getOlePackage();
            setOlePackage.setFileName("Cat FileName.zip");
            setOlePackage.setDisplayName("Cat DisplayName.zip");
        
            doc.save(getMyDir() + "\\Artifacts\\Shape.InsertOlePackage.docx");
        } finally
        {
            if (stream != null) stream.close();
        }
      • getFileName/setFileName

        public java.lang.String getFileName() / public void setFileName(java.lang.String value)
        
        Gets or sets OLE Package file name.

        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);
        try /*JAVA: was using*/
        {
            Shape shape = builder.insertOleObject(stream, "Package", true, null);
        
            OlePackage setOlePackage = shape.getOleFormat().getOlePackage();
            setOlePackage.setFileName("Cat FileName.zip");
            setOlePackage.setDisplayName("Cat DisplayName.zip");
        
            doc.save(getMyDir() + "\\Artifacts\\Shape.InsertOlePackage.docx");
        } finally
        {
            if (stream != null) stream.close();
        }