How to remove header/footer(except for page-number),stamp/watermark/bookmark/url/hyperlink?

Hi,Support:
Would you provide me a full demo showing how to remove header/footer(except for page-number),Iamgestamp/image-or-text-watermark/bookmark/url-text/hyperlink based on VB.net?
And as for Hyperlink, what is the method to remove it or flattern/disable it?
Thanks for your help.

@ducaisoft

Please note that there are not separate header/footer entities in PDF format. Header/footer can only defined at the time of PDF generation and once PDF is generated, they become part of the PDF just like the rest of the page content.

In order remove the hyperlinks from a PDF, you can use below sample code snippet:

Dim doc As New Document("input.pdf")

' Get the first link annotation from the first page of the document
Dim linkAnnot As LinkAnnotation = DirectCast(doc.Pages(1).Annotations(1), LinkAnnotation)

If TypeOf linkAnnot.Action Is GoToURIAction Then
    ' Modify the link: change link URI
    Dim goToAction As GoToURIAction = DirectCast(linkAnnot.Action, GoToURIAction)

    ' Specify the URI for the link object
    goToAction.URI = ""

    ' Save the document with the updated link

    ' Search the text under the annotation
    Dim ta As New TextFragmentAbsorber()
    Dim rect As Aspose.Pdf.Rectangle = linkAnnot.Rect
    rect.LLX -= 10
    rect.LLY -= 10
    rect.URX += 10
    rect.URY += 10
    ta.TextSearchOptions = New TextSearchOptions(rect)
    ta.Visit(doc.Pages(1))

    ' Change color and text.
    For Each tf As TextFragment In ta.TextFragments
        tf.TextState.ForegroundColor = Aspose.Pdf.Color.Red
        tf.Text = "Click Here"
    Next
End If

doc.Save("output.pdf")

Thanks.

And how about removing header/footer,stamp,watermark,bookmark?
And how to detect whether there exist header/footer?

@ducaisoft

Regretfully, there is no way to find out whether header/footer exists in a PDF or not. Because there is no separate definition of header/footer in PDF format (as we shared earlier).

You can however remove stamp, watermark and bookmark from a PDF. Please check below information:

Remove Watermark from PDF

// Load the PDF file
Document document = new Document(System.IO.Path.Combine(_dataDir, "sample_Watermark.pdf"));
var WatermarkAnnotations = document.Pages[1].Annotations
        .Where(a => a.AnnotationType == AnnotationType.Watermark)
        .Cast<WatermarkAnnotation>();

foreach (var ca in WatermarkAnnotations)
{
   document.Pages[1].Annotations.Delete(ca);
}
document.Save(System.IO.Path.Combine(_dataDir, "sample_Watermark_del.pdf"));

Remove stamps from PDF

PdfContentEditor contentEditor = new PdfContentEditor();<o:p></o:p>
contentEditor.BindPdf(“file.pdf”);
contentEditor.DeleteStampByIds(1, new int[] { 100, 101 });
contentEditor.Save(“outfile.pdf”);