Hi,
I am trying to remove the header and footer from a PDF. I am using ParagraphAbsorber
to read the file. Is there an attribute that can be used to detect the header and footer?
Or does there any suggestion to remove header/footer?
Sample-5-7.pdf (905.8 KB)
@Rachel_Lee
Since the document you attached has header and footer marked up, I suggest you try the following code:
var pdfDocument = new Document(dataDir + "Sample-5-7.pdf");
foreach (Page page in pdfDocument.Pages)
{
var deletedArtifacts = new List<Artifact>();
foreach (Artifact artifact in page.Artifacts)
{
if (artifact.Type == Artifact.ArtifactType.Pagination)
switch (artifact.Subtype)
{
case Artifact.ArtifactSubtype.Header:
case Artifact.ArtifactSubtype.Footer:
deletedArtifacts.Add(artifact);
break;
}
}
foreach (Artifact artifact in deletedArtifacts)
page.Artifacts.Delete(artifact);
}
pdfDocument.Save(dataDir + "Sample-5-7_out.pdf");