logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
oberon232  
#1 Posted : Friday, March 8, 2019 1:05:40 PM(UTC)
Quote
oberon232

Rank: Newbie

Groups: Registered
Joined: 2/23/2019(UTC)
Posts: 6
United States
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?
Paul Rayman  
#2 Posted : Sunday, March 10, 2019 4:01:44 PM(UTC)
Quote
Paul Rayman

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);
}
Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
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.