cancel
Showing results for 
Search instead for 
Did you mean: 

Total Page Count for a document.

Smitha_Challa
Star Contributor
Star Contributor

Am I doing something wrong totally? 

I  want to retrieve the entire document. So this is the code I used

 var documentdata = document.DefaultRenditionOfLatestRevision;

var pageData = defaultProvider.GetDocument(documentdata)

using (var newStream = new MemoryStream())
{

pageData.Stream.CopyTo(newStream);
newStream.Seek(0, System.IO.SeekOrigin.Begin);
newStream.CopyTo(ms);
}
byteData = ms.ToArray();

The above code works BUT it returns the whole document in One page. There is no  page break. Our OnBase shows it at 12 pages. But the Unity API returns it all in one page. 

So I tried a different approach using textProvider.Getpages(documentdata,pageRangeset);

Really there is not a pageRangeset because I need all pages. This approach can work if I can something assign pageRangeSet = "1-TotalPageCount";

How do I get the total Page Count for a document.?  Once I have this we can do have all the pages in PageDataList with a page break.  

 pageRangeSet = textProvider.CreatePageRangeSet(pageRanges)

using pageDataList = textProvider.GetPages(documentdata, pageRangeSet)

So there are two problems: GetDocument(documentdata) returns all 11 pages in 1 page without a pagebreak

GetPages(documentdata,pageRangeSet) can work if I knew the Total pageCount

1 ACCEPTED ANSWER

Daniel_Quill
Elite Collaborator
Elite Collaborator

Hi Smitha,

there are a couple things that will factor in to the cause of the this.  1) What verison of the OnBase are you currently testing this in (API: ??.??.??.??).  You can get the version by looking at the properties of the Hyland.Unity.dll located in the BIN directory of the applicaiton server.  2) What type of document are you working with?  From your post it seems that you are working with TEXT documents.   Prior to v16 TEXT documents always return a page count of '1'.  This issue has been addressed in SCR#156574.

Hope that helps.

View answer in original post

3 REPLIES 3

Daniel_Quill
Elite Collaborator
Elite Collaborator

Hi Smitha,

there are a couple things that will factor in to the cause of the this.  1) What verison of the OnBase are you currently testing this in (API: ??.??.??.??).  You can get the version by looking at the properties of the Hyland.Unity.dll located in the BIN directory of the applicaiton server.  2) What type of document are you working with?  From your post it seems that you are working with TEXT documents.   Prior to v16 TEXT documents always return a page count of '1'.  This issue has been addressed in SCR#156574.

Hope that helps.

File Versoin 15.0.0.26
Most of these are text documents, cold Reports.

Isn't that the way web services tool kit worked. Did it get a PageCount for text reports and not 1.
Is that the reason the older code knows there is a '\f'. There are 11 pages in this text report. The legacy code knows that there is  a page break. But the code with unity doesn't know that page break. This is what I did to get around this problem. We use that '\f' to show the report on 11 pages for our custom report viewer 

I am just trying to make sure this is correct. We didn't have to do this for legacy code. Any suggestions would be appreciated. 

First give it a default page range for GetPages to work. Then when it gets pagedatalist, i loop over all the page data and insert a '\f'

if (String.IsNullOrEmpty(pageRanges))
defaultpageRanges = "1-10000";
if (type == "text/plain")
{

var textProvider = obApp.Core.Retrieval.Text;
var documentdata = document.DefaultRenditionOfLatestRevision;

pageRangeSet = textProvider.CreatePageRangeSet(defaultpageRanges);
byte[] newpagecharacter = System.Text.Encoding.UTF8.GetBytes(new char[] { '\f' });
var newPageStream = new MemoryStream(newpagecharacter);
using (var ms = new MemoryStream())
{

using (var pageDataList = textProvider.GetPages(documentdata, pageRangeSet))
{


for (int i = 0; i < pageDataList.Count; i++)
{
using (var newStream = new MemoryStream())
{
var pageData = pageDataList;
pageData.Stream.CopyTo(newStream);
newStream.Seek(0, System.IO.SeekOrigin.Begin);

newPageStream.Seek(0, System.IO.SeekOrigin.Begin);

newStream.CopyTo(ms);
newPageStream.CopyTo(ms);
}

}
byteData = ms.ToArray();
}

}

}

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.