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

Question

Question

Toolkit Question on viewing Page text

SDK
asked on May 5, 2014 Show version history

 I'm using LFSO83Lib with Laserfiche.DocumentServices & Laserfiche.RepositoryAccess

 

For a particular tocid, I'd like to loop through each Page of the document and access the Page Text.

 

Can this be done with EntryInfo ei = Entry.GetEntryInfo(tocid, session); ?  I'm not sure how to get from here to the page text.

 

An example in C# would be appreciated.

0 0

Answer

APPROVED ANSWER
replied on May 5, 2014 Show version history

You'll need to obtain a DocumentInfo object (an EntryInfo can be cast to a DocumentInfo if it represents a document). Then you need to obtain the PageInfos corresponding to the pages in the document whose text you want to retrieve. This can be done either by calling GetPageInfo or iterating through GetPageInfos on the DocumentInfo. Each PageInfo has a ReadTextPagePart method which will return a StreamReader containing the page's text.

1 0

Replies

replied on May 7, 2014

Thanks Matthew, can you provide a specific C# example ?

0 0
replied on May 7, 2014

Here is an untested C# snippet:

// Assuming you have an int docid and a Session s
using (DocumentInfo info = new DocumentInfo(docid, s))
{
    // Update properties
    info.Refresh()

    List<string> pageTexts = new List<string>(info.PageCount);

    foreach (PageInfo page in info.GetPageInfos())
    {
        using (StreamReader textReader = page.ReadTextPagePart())
        {
            pageTexts.Add(textReader.ReadToEnd());
        }
    }

    // pageTexts now contains all of the text in the document.
}

Again, this code snippet is untested, so be sure to test it out before copy-pasting it.

0 0
replied on May 7, 2014

Thanks Matthew, I'll give it a shot.

0 0
replied on May 7, 2014

It works fine, thanks again.

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

Sign in to reply to this post.