Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include images from ssrs report to html page #35

Open
srider777 opened this issue Oct 22, 2019 · 3 comments
Open

Include images from ssrs report to html page #35

srider777 opened this issue Oct 22, 2019 · 3 comments

Comments

@srider777
Copy link

Any way to include images from ssrs reports into the page html? When rendering ssrs report content as .pdf or Excel file, the report images are included in the file output. When rendering report content as html, only "marker" where the image should be displayed.

@yikaiba
Copy link

yikaiba commented Mar 10, 2020

Any way to include images from ssrs reports into the page html? When rendering ssrs report content as .pdf or Excel file, the report images are included in the file output. When rendering report content as html, only "marker" where the image should be displayed.

Have you found a solution?

@srider777
Copy link
Author

No solution yet....Still trying to figure it out.

@Nirator78
Copy link

Nirator78 commented Jul 26, 2024

Yes I found a solution by using the Stream id retourned by the soap api.

private function getImageForHtmlRendering(stdClass $result, NTLMSoapClient $clientExecution): stdClass
{
    $renderedReport = $result->Result;
    $streamIds = $result->StreamIds->string;

    $imagesInBase64 = [];
    foreach ($streamIds as $streamId) {
        $param = [
            "Format" => RenderingReportExtension::HTML,
            "StreamID" => $streamId,
            "DeviceInfo" => "<DeviceInfo><HTMLFragment>true</HTMLFragment></DeviceInfo>"
        ];
        $imageData = $clientExecution->RenderStream($param);
        $base64Image = base64_encode($imageData->Result);
        $imagesInBase64[$streamId] = "data:image/png;base64," . $base64Image;
    }

    // Replace the src of the images
    foreach ($imagesInBase64 as $streamId => $base64Image) {
        $regex = '/src="[^"]*ImageID=' . preg_quote($streamId, "/") . '"/';
        $replace = 'src="' . $base64Image . '"';
        $renderedReport = preg_replace($regex, $replace, $renderedReport);
    }

    $result->Result = $renderedReport;

    return $result;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants