We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to delete image from pdf?

Hi,Support:

I use editor.DeleteImage(p,Index) to delete image, but fail, how to set the value for index or how to use the parameter or Index() for editor.DeleteImage?
Thanks for your help!

@ducaisoft

The index parameter represents an array of integers – the indexes of the images to be deleted. In case you are facing any issue while using it, would you please share your sample PDF with us. We will test the scenario in our environment and address it accordingly.

This means the index of images to be deleted are 1,3,6,8, then the index() parameter should be
Dim DelArray() as integer
Redim DelArray(3)
DelArray(0)=1
DelArray(1)=3
DelArray(2)=6
DelArray(3)=8

and then call editor.DeleteImage(p,DelArray) , or call editor.DeleteImage(p,DelArray()) , or calll editor.DeleteImage(p,DelArray(1,3,6,8)) , Or call editor.DeleteImage(p,DelArray(0,1,2,3)) ? which is the ringht one?
I’ll try them.

@ducaisoft

The complete method would be as following:

    Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
    Dim contentEditor As PdfContentEditor = New PdfContentEditor()
    contentEditor.BindPdf(dataDir & "DeleteImages-Page.pdf")
    Dim imageIndex As Integer() = New Integer() {1}
    contentEditor.DeleteImage(2, imageIndex)
    contentEditor.Save(dataDir & "DeleteImages-Page_out.pdf")