如何以编程方式对power point图像进行分组

2024-05-23 19:09:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用pdf miner模块从pdf中提取图像。我想将图形图像提取为单个图像,但实际上模块并没有返回整个图形图像,而是返回分离的图像。我已将pdf转换为ppt。然后将图形图像手动分组为单个图像,然后再次转换为pdf。目前,pdf-miner将图形图像提取为单幅图像

我们可以手动对电源点图像进行分组。有什么方法可以通过编程实现吗


Tags: 模块方法图像pdf编程手动ppt电源
1条回答
网友
1楼 · 发布于 2024-05-23 19:09:36

为了做到这一点,你需要能够提供一些条件,将识别你的形状独特;它们可能是幻灯片上唯一的图片形状,也可能是空白幻灯片上唯一的形状,或者是在您第一次计算幻灯片上的形状数之后添加的任何形状。一旦你有了一个条件,你就可以应用它来构建一个符合条件的形状数组,然后对它们进行分组:

Sub GroupCertainShapes()

    Dim x As Long
    Dim sTemp As String
    Dim aShapeList() As String
    Dim lShapeCount As Long

    With ActivePresentation.Slides(1)
        ' iterate through all shapes on the slide
        ' to get a count of shapes that meet our condition
        For x = 1 To .Shapes.Count
            ' Does the shape meet our condition? count it.
            If .Shapes(x).Type = msoAutoShape Then
                lShapeCount = lShapeCount + 1
            End If
        Next

        ' now we know how many elements to include in our array,
        ' so redim it:
        ReDim aShapeList(1 To lShapeCount)

        ' Reset the shape counter
        lShapeCount = 0

        ' Now add the shapes that meet our condition
        ' to the array:
        For x = 1 To .Shapes.Count
            ' apply some criterion for including the shape or not
            If .Shapes(x).Type = msoAutoShape Then
                lShapeCount = lShapeCount + 1
                aShapeList(lShapeCount) = .Shapes(x).Name
            End If
        Next

        ' and finally form a group from the shapes in the array:
        If UBound(aShapeList) > 0 Then
            .Shapes.Range(aShapeList).Group
        End If

    End With
End Sub

相关问题 更多 >