Remove watermark from Aspose pdf document

Below attached input document(all_added.pdf) is generated from Aspose. And i applied header footer and watermark text using stamps.But when i am trying to remove watermark from the PDF document both the header text and footer text is also getting removed.

        //HeaderStamp
        TextStamp HeaderStamp = new TextStamp("Header789 Text");
        HeaderStamp.TopMargin = 10;
        HeaderStamp.HorizontalAlignment = HorizontalAlignment.Center;
        HeaderStamp.VerticalAlignment = VerticalAlignment.Top;
        HeaderStamp.TopMargin = 40;
        HeaderStamp.setStampId(1);

        //FooterStamp
        TextStamp FooterStamp = new TextStamp("Footer258 Text");
        FooterStamp.TopMargin = 10;
        FooterStamp.HorizontalAlignment = HorizontalAlignment.Center;
        FooterStamp.VerticalAlignment = VerticalAlignment.Bottom;
        FooterStamp.BottomMargin = 40;
        FooterStamp.setStampId(2);
        
        //WatermarkStamp
        TextStamp WatermarkStamp = new TextStamp("Watermark No need");
        WatermarkStamp.TopMargin = 10;
        WatermarkStamp.TextState.FontSize = 36;
        WatermarkStamp.TextState.Font = FontRepository.FindFont("Arial");
        WatermarkStamp.TextState.ForegroundColor = Color.FromRgb(System.Drawing.Color.FromName("Black"));
        WatermarkStamp.HorizontalAlignment = HorizontalAlignment.Center;
        WatermarkStamp.VerticalAlignment = VerticalAlignment.Center;
        WatermarkStamp.RotateAngle = 45;
        WatermarkStamp.Opacity = 0.5;
        WatermarkStamp.setStampId(3);
        
        Aspose.Pdf.Document all_added_3 = new Aspose.Pdf.Document(@"/Users/sgovindan/Downloads/all_added.pdf");
        
        PdfContentEditor editor3 = new PdfContentEditor(all_added_3);

        // Removing all existing header and footer
        foreach (var page in all_added_3.Pages)
        {
            var result = editor3.GetStamps(page.Number);

            foreach (var stampInfo in result)
            {
                if (stampInfo.StampId == 1  )
                {
                    editor3.DeleteStampById(page.Number, stampInfo.StampId);
                }
                if (stampInfo.StampId == 2)
                {
                    editor3.DeleteStampById(page.Number, stampInfo.StampId);
                }
            }

        }
        
        // Apply different header and footer
        foreach (Page page in all_added_3.Pages)
        {
            page.AddStamp(HeaderStamp);
            page.AddStamp(FooterStamp);
        }

        // Bug Removing watermark from the Pdf Document which removes everything need to create a ticket for this in aspose
       
        foreach (Aspose.Pdf.Page pdfPage in all_added_3.Pages)
        {
            var result = editor3.GetStamps(pdfPage.Number);

            foreach (var stampInfo in result)
            {
                if (stampInfo.StampId == 3)
                {
                    editor3.DeleteStampById(pdfPage.Number, 3);
                }
            }
        }
        all_added_3.Save(@"/Users/sgovindan/Downloads/need_fix.pdf");
        // Bug Removing watermark from the Pdf Document which removes everything
        System.Console.WriteLine("Fix Done");
    }

all_added.pdf (140.2 KB)

@Sandhya_Rani

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-56066

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.