Add document to Presentation via OLE

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Merger MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-merger -- dnx GroupDocs.Merger.Mcp --yes
Folders, licensing and more →

What is an OLE object?

OLE stands for “Object Linking and Embedding”, a Microsoft technology that lets one document carry content produced by another application. For example, an Excel spreadsheet or a PowerPoint presentation can be embedded into a document edited in a word processor. All the related data then stays in one document, which is easy to share.

How to add an OLE object to a presentation

GroupDocs.Merger for Python via .NET embeds a document into a slide of a presentation in three steps:

  1. Create an OlePresentationOptions with the path to the file to embed and the number of the slide to put it on.
  2. Create a Merger with the path to the presentation, and call merger.import_document() with the options.
  3. Call merger.save() with the path of the result.

The following example embeds a PDF file into a PowerPoint presentation:

from groupdocs.merger import Merger
from groupdocs.merger.domain.options import OlePresentationOptions

def add_document_to_presentation_via_ole():
    # Embed the PDF file on slide 2, near the slide's top left corner
    page_number = 2
    ole_options = OlePresentationOptions("./embedded.pdf", page_number)
    ole_options.x = 10
    ole_options.y = 10

    with Merger("./input.ppt") as merger:
        merger.import_document(ole_options)
        merger.save("./output.ppt")

if __name__ == "__main__":
    add_document_to_presentation_via_ole()

input.ppt is a sample file used in this example. Click here to download it.

embedded.pdf is a sample file used in this example. Click here to download it.

Explanation

  • OlePresentationOptions("./embedded.pdf", page_number): the file to embed and the slide to put it on, counting from 1.
  • x and y: the position of the object’s frame on the slide; width and height set its size.

API reference

See also