Search code examples
javapythonnode.jspowerpointpdfminer

How to group the power point images programatically


I'm trying to extract the images from pdf using pdf miner module.I want to extract the graph image as single image but actually module is not returning the whole graph image instead its returning the separated images.I have converted the pdf to ppt.Then manually grouped the graphic image as single image then again converted to pdf. Now pdf miner is extracting the graph image as single image.

Manually we can group the power point images.Is there any way to do that programmatically


Solution

  • In order to do this, you need to be able to supply some condition that will identify your shapes uniquely; they might be the only picture shapes on a slide, the only shapes on an otherwise blank slide, or any shapes added after you've first gotten a count of the number of shapes on the slide. Once you have a condition you can apply this can build an array of the shapes that meet the condition then group them:

    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