You are viewing limited content. For full access, please sign in.

Question

Question

How to clear document text using SDK

asked on June 14 Show version history

I am trying to clear all the document text from a document using the SDK.  Here is my code...

for (int pageNumber = 1; pageNumber <= document.PageCount; pageNumber++)
{
    var page = document.GetPageInfo(pageNumber);
    if (page.HasText)
     page.ClearPagePart(PagePart.Text);
}

I get no errors when i run this code and all the document text is empty but the "Text Pages" field still has a value of "Some".  I would expect it to have a value of "None".

What am I doing wrong?

0 0

Replies

replied on June 14

Do you have a document.Save() call after the loop?

replied on June 14

Initially, I thought it was because you were not removing the location data as well, but I tested and found the same behavior.

        private void ClearText(int iDocID)
        {
            try
            {
                using (DocumentInfo CurrentDoc = Document.GetDocumentInfo(iDocID, LFSession))
                {
                    CurrentDoc.Lock(LockType.Exclusive);
                    for (int pageNumber = 1; pageNumber <= CurrentDoc.PageCount; pageNumber++)
                    {
                        PageInfo page = CurrentDoc.GetPageInfo(pageNumber);
                        if (page.HasText)
                        {
                            page.ClearPagePart(PagePart.Locations);
                            page.ClearPagePart(PagePart.Text);
                            page.Save();
                        }
                    }
                    CurrentDoc.Unlock();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

 

0 0
replied on June 19

I did a bit more research and discovered it is setting the value to "Some".  I have some documents that have a value of "All" and after I run the ClearPagePart method on all pages the value is changed to "Some".  Is there something I can do to force the value to be "None".

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.