How to remove header and footer from pdf using regex

hey guys,
I want to remove header and footer from pdf and save that output to pdf file format.
is it possible to remove footer and header from it ?

Hello @check_account!

It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.

First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.

You can check out some of our resources directly, see below:

  1. Always search first. It is the best way to quickly find your answer. Check out the image icon for that.
    Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.

  2. Topic that contains most common solutions with example project files can be found here.

  3. Read our official documentation where you can find a lot of information and instructions about each of our products:

  4. Watch the videos on our official YouTube channel for more visual tutorials.

  5. Meet us and our users on our Community Slack and ask your question there.

Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.

Thank you for helping us build our UiPath Community!

Cheers from your friendly
Forum_Staff

Hi @check_account ,

Could you show us an example of what do you mean by Header and footer in Word.

You could provide screenshots so that we can understand it clearly.

yeah sure!


as you can see header in that pdf page and here footer is page number.Is there any way to remove
header and footer from pdf pages?

Hi
Dont know if this helps but trying to solve this using Spire.pdf library .Pasting code which might be helpful.
Dim brush As PdfBrush = PdfBrushes.Black
Dim pen As New PdfPen(brush, 0.75f)
Dim font As New PdfTrueTypeFont(New System.Drawing.Font(“Arial”, 10f,System.Drawing.FontStyle.Italic), True)
Dim rightAlign As New PdfStringFormat(PdfTextAlignment.Right)
Dim leftAlign As New PdfStringFormat(PdfTextAlignment.Left)
rightAlign.MeasureTrailingSpaces = True
rightAlign.MeasureTrailingSpaces = True
Dim space As Single = font.Height * 1
Dim x As Single = 0
Dim y As Single = 0
Dim width As Single=0
Using pdf As New PdfDocument()
pdf.LoadFromFile(“input file”)
Dim margin As PdfMargins = pdf.PageSettings.Margins
Dim newPage As PdfPageBase
Dim newPdf As New PdfDocument()
For Each page As PdfPageBase In pdf.Pages
newPage = newPdf.Pages.Add(page.Size,New PdfMargins(0))
newPage.Canvas.SetTransparency(0.5f)
x = margin.Left
width = page.Canvas.ClientSize.Width - margin.Left - margin.Right
y = margin.Top
'newPage.Canvas.DrawLine(pen, x, y+45, x + width, y+45)
Console.WriteLine(“x”+x.ToString+“y”+y.ToString)
'y = y+10 - font.Height
newPage.Canvas.DrawString(" ", font, brush, x, y, rightAlign)
newPage.Canvas.SetTransparency(1)
page.CreateTemplate().Draw(newPage.Canvas, New System.Drawing.PointF(0, 0))
Next page
newPdf.SaveToFile(“output file”)
newPdf.Close()
End Using

Something like this might help you.Do let me know whether u found any solution or this might help

HI @check_account .Just tried doing this with Spire pdf ,had to add a layer .hope this helps.
Dim brush As PdfBrush = PdfBrushes.White
Dim pen As New PdfPen(brush, 1f)
Using pdf As New PdfDocument()
pdf.LoadFromFile(“input pdf file”)
Dim margin As PdfMargins = pdf.PageSettings.Margins
Dim layer As Spire.Pdf.Graphics.Layer.PdfLayer=pdf.Layers.AddLayer(“immi”)
Dim pca As PdfCanvas
For Each page As PdfPageBase In pdf.Pages
pca=layer.CreateGraphics(page.Canvas)
pca.DrawRectangle(pen,brush,margin.Left,margin.Top-10,pca.ClientSize.Width - margin.Left - margin.Right,60)
Next page
pdf.SaveToFile(“Remover Header.pdf”,FileFormat.PDF)
End Using