Rank: Newbie
Groups: Registered
Joined: 2/23/2019(UTC) Posts: 6  Location: FL Thanks: 1 times
|
I have a page that I've marked with text. I know the position on the page and what the text says. Now I want to remove that text, not just hide it but remove it from the page. Is there a way to do this?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
you can enumerate page.PageObjects collection, locate and remove the TextObject. Next you should re-generate page content by calling page.GenerateContent() method. Code:using (var doc = PdfDocument.Load(@"d:\test.pdf"))
{
var page = doc.Pages[0];
for(int i=page.PageObjects.Count-1; i>=0; i--)
{
if (!(page.PageObjects[i] is PdfTextObject))
continue;
var obj = page.PageObjects[i] as PdfTextObject;
if (obj.TextUnicode == "some text")
{
page.PageObjects.RemoveAt(i);
break;
}
}
page.GenerateContent();
doc.Save(@"d:\test_modified.pdf", SaveFlags.NoIncremental);
}
|
|
|
|
|
|
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close