Groups | Blog | Home
all groups > sql server reporting services > october 2005 >

sql server reporting services : Using Render - need page count


JPA
10/6/2005 12:48:13 PM
I'd like to use the render webservice method to render HTML for a report.
Using DeviceInfo, I can jump from page to page (section to section). I
can't figure out how to get the maximum number of sections. What am I
Oleg Yevteyev
10/6/2005 2:06:00 PM
I wasn't able to find any API to get the amount of pages also. The only way
I could achieve it - was to
pass device info like that
<DeviceInfo><Section>1</Section><Toolbar>True</Toolbar></DeviceInfo>
grab the sessionID like
session_id=rs.SessionHeaderValue.SessionId;
but in mean time parse the content of the HTML returned, looking for "var
rep = new Report" string and get page count like

SessionHeader sh = new SessionHeader();
rs.SessionHeaderValue = sh;
byte[] bytes=null;
try
{
bytes=rs.Render(reportPath, format, historyID, devInfo, parameters,
credentials,
showHideToggle, out encoding, out mimeType, out reportHistoryParameters, out
warnings,
out streamIDs);
}
catch (SoapException e)
{
throw e;
}
string response=new
string(System.Text.Encoding.GetEncoding(1252).GetChars(bytes));
string val=string.Empty;
int pos=response.IndexOf("var rep = new Report(");
if(pos>0)
{
pos+=21;
}
int pos2=response.IndexOf(',',pos);
val=response.Substring(pos,pos2-pos);
session_id=rs.SessionHeaderValue.SessionId;
PageCount=int.Parse(val.Trim());

That gives you a session_id you can refer later to avoid requiring your data
and the maximum amount of pages .

I'd love to see, if someone has found a more simple, API based solution to
get a page count.


[quoted text, click to view]

Live_Love_Laugh
11/29/2005 12:39:11 PM
Try this:

string[] streamIDs = null;

//initialize report path and other variables accordingly

firstPage = rs.Render(reportPath, "IMAGE", null,
"<DeviceInfo><OutputFormat>emf</DeviceInfo></OutputFormat>",
reportParameters , null, null, out encoding, out mimeType,
out reportHistoryParameters, out warnings, out streamIDs);

int TotalPages = streamIDs.Length + 1;

Thanks,
Live_Love_Laugh

[quoted text, click to view]
AddThis Social Bookmark Button