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

Free Support Forum - aspose.com

Different way to delete images from PDF using Apsose.PDF for .NET

Hi, Support:
Here report bug for pdf.dll v20.7 again:
By using :
For cc = 7 To 1 Step -1
On Error Resume Next
Pdf.Pages(1).Resources.Images.Delete(cc)
Dim ns = Err.Description & " " & Err.Number
Pdf.Save(OutFile)
Next
when cc=6 , the outfile will be corrupted. Why?

By using :
For cc = 7 To 1 Step -1
On Error Resume Next
Pdf.Pages(1).Resources.Images.Delete(cc)
Dim ns = Err.Description & " " & Err.Number

            Next 

Pdf.Save(OutFile)
the outfile will be ok, and 7 images have been deleted. Why?

By using :
For cc = 1 To 7
On Error Resume Next
Pdf.Pages(1).Resources.Images.Delete(cc)
Dim ns = Err.Description & " " & Err.Number
Pdf.Save(OutFile)
Next
when cc=2 , the outfile will be corrupted. Why?

By using :
For cc = 1 To 7
On Error Resume Next
Pdf.Pages(1).Resources.Images.Delete(cc)
Dim ns = Err.Description & " " & Err.Number

            Next 

Pdf.Save(OutFile)
the outfile will be ok, but on 4 not 7 images have been deleted. Why?

        ImgCount1 = Pdf.Pages(1).Resources.Images.Count
        Pdf.Pages(p).Accept(abs)
       ImgCoun2= abs.ImagePlacements.Count

ImgCount1 is 7 not 9, and ImgCoun2 is only 0, why ImgCount1 is not equal to ImgCoun2 ?
why ImgCount1 is not equal to 9 ,and ImgCount2 is not equal to 9?

Why the pdf.dll has so many bugs?
Test.pdf (269.0 KB)

@ducaisoft

We tested the scenario in our environment and noticed following:

Case 1 (Success)

Document Pdf = new Document(dataDir + "Test.pdf");
            for (int cc = 7; cc >= 1; cc += -1)
            {
                Pdf.Pages[1].Resources.Images.Delete(cc);
                Pdf.ProcessParagraphs();
            }
            Pdf.Save(dataDir + "case1.pdf");

Case 2 (Exception)

var Pdf = new Document(dataDir + "Test.pdf");

            for (int cc = 1; cc <= 7; cc++)
            {
                Pdf.Pages[1].Resources.Images.Delete(cc);
                Pdf.ProcessParagraphs();
            }
            Pdf.Save(dataDir + "case2.pdf");

For the sake of investigation, we have logged a ticket as PDFNET-48617 in our issue tracking system. We will further look into its details and keep you posted with its rectification status. Please be patient and spare us some time.

We tested the scenario in our environment and noticed that image count was same in both cases i.e. 7. There are 2 image stamps inside PDF Page 1 and added images are 7. Could you please try to test the scenario again by using valid license.

does the function and performance of evaluation version is different and poor to the valid ones?
and would you please provide me a temp valid version for me testing? there are so many bugs for evaluation version pdf.dll v20.7.
And I do not know why they will be so different!

@ducaisoft

The trial version of the API has restriction of processing only 4 elements of any collection in the API e.g. Pages, Images, Annotations, etc. You may please get 30-days free temporary license in order to evaluate the API in its full capacity without any limitation.