SSRS Soap Interface - Getting Images using RenderStream to display
i have php code calls render2 method render ssrs report. i'll pass streamid renderstream method images report (in example below, there's 1 image on report - company logo).
the image gets written images directory file. img tag in resulting html looks fine (<img src="images/11d3f3fc-0e57-4373-b43e-02adc3a86c52"/>). however, images not display when resulting html displayed. if add file extension (.jpg) file , resulting html (just using static copy of resulting html), image displays fine.
when try encoding or mimetype elements renderstreamresponse, aren't there - result element.
what can add either extension added img tag , mimetype returned, or extensionless img tag display properly?
$deviceinfo = "<deviceinfo><toolbar>false</toolbar><streamroot>images/</streamroot></deviceinfo>"; $parameters = array ( "format" => "html4.0", "deviceinfo" => $deviceinfo, "paginationmode" => "estimate" ); $stdobject = $client->render2($parameters); $objectvars = get_object_vars ($stdobject); $resulthtml = $objectvars["result"]; $streamid = $objectvars["streamids"]; $streamids = get_object_vars($streamid); $parameters = array ( "format" => "html4.0", "streamid" => $streamids["string"], "deviceinfo" => $deviceinfo ); // use renderstream objects: $stdobject = $client->renderstream($parameters); $objectvars = get_object_vars ($stdobject); $result_png = $objectvars["result"]; if (!$handle = fopen("images/" . $streamids["string"], 'wb')) { echo "cannot open file writing output"; exit; } if (fwrite($handle, $result_png) === false) { echo "cannot write file"; exit; } fclose($handle); echo $resulthtml;
hi bhnat,
the streamroot in device information settings path used prefixing value of src attribute of img element in html report returned report server. default, report server provides path.
in case, have set value "images/". so, src attribute of img element in format:
images/<streamid>
to fix issue, can use page render image. example, setting streamroot be:
$streamroot = "getimage.php?report=" & reportpath & "&streamid="
$deviceinfo = "<deviceinfo><toolbar>false</toolbar><streamroot>" &$streamroot & "</streamroot></deviceinfo>";
now, in getimage.php, using code render image. below similar code snippet implemented in vb.net:
dim reportpath string = server.urldecode(request("report"))
dim streamid string = request("streamid")
dim rs reportingservice = session("rs")
dim encodingimage string
dim mimetypeimage string
dim image byte()
image = rs.renderstream(reportpath, "html4.0", streamid, nothing, nothing, session("reportparametervalues"), encodingimage, mimetypeimage)
response.clear()
response.contenttype = mimetypeimage
response.appendheader("content-length", image.length.tostring())
response.binarywrite(image)
response.flush()
response.close()
here similar project(in vb.net) provided marian dumitrascu, may have @ this:
http://www.codeproject.com/kb/reporting-services/sqlrsviewer.aspx
for getting mime type issue, seems known issue, have submitted feedback here:
https://connect.microsoft.com/sqlserver/feedback/details/572068/renderstream-doesnt-return-the-mime-type-in-sql-server-reporting-services-2008-or-sql-server-reporting-services-2008-r2#details
if have more questions, please feel free ask.
thanks,
jin chen
jin chen - msft
SQL Server > SQL Server Reporting Services, Power View
Comments
Post a Comment