OLE 객체

OLE 객체로 파일을 삽입하고 해당 데이터를 Aspose.Slides for Python via .NET을 사용하여 업데이트하는 방법을 보여줍니다.

OLE 객체 추가

프레젠테이션에 PDF 파일을 삽입합니다.

def add_ole_object():
    with slides.Presentation() as presentation:
        slide = presentation.slides[0]

        # 삽입할 PDF 데이터를 로드합니다.
        with open("doc.pdf", "rb") as file_stream:
            data_info = slides.dom.ole.OleEmbeddedDataInfo(file_stream.read(), "pdf")

        # 슬라이드에 OLE 객체 프레임을 추가합니다.
        ole_frame = slide.shapes.add_ole_object_frame(20, 20, 50, 50, data_info)

        presentation.save("ole_frame.pptx", slides.export.SaveFormat.PPTX)

OLE 객체 접근

슬라이드에서 첫 번째 OLE 객체 프레임을 가져옵니다.

def access_ole_object():
    with slides.Presentation("ole_frame.pptx") as presentation:
        slide = presentation.slides[0]

        # 슬라이드에서 첫 번째 OLE 객체 프레임을 가져옵니다.
        first_ole = next(shape for shape in slide.shapes if isinstance(shape, slides.OleObjectFrame))

OLE 객체 제거

슬라이드에서 삽입된 OLE 객체를 삭제합니다.

def remove_ole_object():
    with slides.Presentation("ole_frame.pptx") as presentation:
        slide = presentation.slides[0]

        # 첫 번째 도형이 OleObjectFrame 객체라고 가정합니다.
        ole_frame = slide.shapes[0]

        slide.shapes.remove(ole_frame)

        presentation.save("ole_frame_removed.pptx", slides.export.SaveFormat.PPTX)

OLE 객체 데이터 업데이트

기존 OLE 객체에 삽입된 데이터를 교체합니다.

def update_ole_object_data():
    with slides.Presentation("ole_frame.pptx") as presentation:
        slide = presentation.slides[0]

        # 첫 번째 도형이 OleObjectFrame 객체라고 가정합니다.
        ole_frame = slide.shapes[0]

        with open("Picture.png", "rb") as picture_stream:
            new_data = slides.dom.ole.OleEmbeddedDataInfo(picture_stream.read(), "png")

        # 새로운 임베디드 데이터로 OLE 객체를 업데이트합니다.
        ole_frame.set_embedded_data(new_data)

        presentation.save("ole_frame_updated.pptx", slides.export.SaveFormat.PPTX)