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

Free Support Forum - aspose.com

Aspose.PDF image deleting

page.Resources.Images.Delete();

Why Delete method that using index deletes image and make document smaller
But Delete method that using image name deletes image and not change the size of document(or even make it bigger)

@chub

Thanks for your inquiry.

Could you kindly provide a sample PDF along with complete sample code snippet which can replicate the issue that you are concerned about. We will further investigate the scenario and share our feedback with you.

Adding image code -

        Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("input.pdf");            
        //Create image stamp
        ImageStamp imageStamp = new ImageStamp("image.png");
        imageStamp.Background = false;
        imageStamp.XIndent = 0;
        imageStamp.YIndent = 0;
        imageStamp.Height = 300;
        imageStamp.Width = 300;
        imageStamp.Rotate = Rotation.on270;
        imageStamp.Opacity = 0.5;
        // Add stamp to particular page
        pdfDocument.Pages[1].AddStamp(imageStamp);

        //Save output document
        pdfDocument.Save("test.pdf");

Deleting image using image name -

        Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("test.pdf");
        pdfDocument.Pages[1].Resources.Images.Delete("Im0");
        //Save output document
        pdfDocument.Save("test_del_by_name.pdf");

Deleting image using image index -

        Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("test.pdf");
        pdfDocument.Pages[1].Resources.Images.Delete(1);
        //Save output document
        pdfDocument.Save("test_del_by_index.pdf");

I will send zip file with all pdf files and you can check it visual and check it size value
Del.zip (3.5 MB)

@chub

We have generated an investigation ticket as PDFNET-47419 in our issue tracking system in order to collect relevant details. We will surely provide our feedback in details as soon as the ticket is resolved. Please spare us little time.

1 Like

The issues you have found earlier (filed as PDFNET-47419) have been fixed in Aspose.PDF for .NET 20.1.