Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3878350
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:36:10+00:00 2026-05-19T22:36:10+00:00

I would like to add a PDF file containing corperate identity information and graphics

  • 0

I would like to add a PDF file containing corperate identity information and graphics on every page of a reporting services report. This report is rendered from the report viewer of Dynamics CRM. I was looking into writing a rendering extensions which calls the existing PDF export rendering extension and by using a PDF component like ABCPdf.

I know howto get the PDF background rendering done but I was unable to call the an existing rendering extension from a new implementation.

The existing PDF rendering extension is a sealed class and it appeared to be impossible to use its render method from another implementation.

Then I tried to call the report server directly using a http request and I cannot get this to work because of an impersonation issue. I get the following error message: “No Microsoft Dynamics CRM user exists with the specified domain name and user ID”

I think I am on the right track but I have no idea howto get the security credentials right from the context of an rendering extension.

If I only can get the contents of the pdf as a stream I will be able to add a background to it.

public class PdfWithBackgroundRenderer : IRenderingExtension
    { 


        public void GetRenderingResource(Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStreamCallback, System.Collections.Specialized.NameValueCollection deviceInfo)
        {

        }

        public bool Render(Report report, System.Collections.Specialized.NameValueCollection reportServerParameters, System.Collections.Specialized.NameValueCollection deviceInfo, System.Collections.Specialized.NameValueCollection clientCapabilities, ref System.Collections.Hashtable renderProperties, Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream)
        {
            //http://localhost/Reserved.ReportViewerWebControl.axd?ReportSession=3i414gm5fcpwm355u1ek0e3g&ControlID=417ac5edf4914b7a8e22cf8d4c7a3a8d&Culture=1043&UICulture=1033&ReportStack=1&OpType=Export&FileName=%7bF64F053A-5C28-E011-A676-000C2981D884%7d&ContentDisposition=OnlyHtmlInline&Format=PDF
            string Url = "http://localhost/Reserved.ReportViewerWebControl.axd";
            Url += "?ExecutionID=" + reportServerParameters["SessionID"];
            Url += "&ControlID=" + Guid.Empty;
            Url += "&Culture=1043";
            Url += "&UICulture=1033";
            Url += "&ReportStack=1";
            Url += "&OpType=Export";
            Url += "&FileName=" + report.Name;
            Url += "&ContentDisposition=OnlyHtmlInline";
            Url += "&Format=PDF";            

            Stream outputStream = createAndRegisterStream(report.Name, "pdf", Encoding.UTF8, "application/pdf", true, Microsoft.ReportingServices.Interfaces.StreamOper.CreateAndRegister);
            StreamWriter writer = new StreamWriter(outputStream);            
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
            request.Credentials = System.Net.CredentialCache.DefaultCredentials;            

            request.Timeout = 20000;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            StreamReader reader = new StreamReader(response.GetResponseStream());
            writer.Write(reader.ReadToEnd());      
            writer.Flush();

            return false;
        }

        public bool RenderStream(string streamName, Report report, System.Collections.Specialized.NameValueCollection reportServerParameters, System.Collections.Specialized.NameValueCollection deviceInfo, System.Collections.Specialized.NameValueCollection clientCapabilities, ref System.Collections.Hashtable renderProperties, Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream)
        {
            return false;
        }

        public string LocalizedName
        {
            get { return "PDF Renderer with background"; }
        }

        public void SetConfiguration(string configuration)
        {

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:36:10+00:00Added an answer on May 19, 2026 at 10:36 pm

    There is a way, and it takes only a couple of lines.
    The idea is to call an existing rendering extension’s render method from a new rendering extension. This will give you the rendering result as a stream which you can modify.

    I could not find a solution online but found some forum answers claiming that this could not be accomplished.

    The hard part is to get your head around the delegate function that is used. Once you understand what is happening the solution becomes a simple one.

    This code is tested with Reporting Services 2008. This method is very useful if you want to modify rendering results created by existing SSRS rendering extsions. You can do string replacements, change the CSV output according to your needs or as in our case sign or update a PDF document.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.ReportingServices.OnDemandReportRendering;
    using Microsoft.ReportingServices.Rendering.ImageRenderer;
    using System.Globalization;
    using System.IO;
    using System.Net;
    
    namespace ReportRendering.PDF
    {
    
        public class PdfWithBackgroundRenderer : IRenderingExtension
        {
            //Add the existing rendering extension to the new class
            //In this case PDfRenderer from the ImageRenderer namespace
            private PDFRenderer pdfRenderer;
    
            //Stream to which the intermediate report will be rendered
            private Stream intermediateStream;
            private string _name;
            private string _extension;
            private Encoding _encoding;
            private string _mimeType;
            private bool _willSeek;
            private Microsoft.ReportingServices.Interfaces.StreamOper _operation;
    
            //Inititate the existing renderer in the constructor
            public PdfWithBackgroundRenderer()
                : base()
            {
                pdfRenderer = new PDFRenderer();
            }
    
    
            public void GetRenderingResource(Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStreamCallback, 
                System.Collections.Specialized.NameValueCollection deviceInfo)
            {
    
            }
    
            //New implementation of the CreateAndRegisterStream method
            public Stream IntermediateCreateAndRegisterStream(string name, string extension, Encoding encoding, string mimeType, bool willSeek, Microsoft.ReportingServices.Interfaces.StreamOper operation)
            {
                _name = name;
                _encoding = encoding;
                _extension = extension;
                _mimeType = mimeType;
                _operation = operation;
                _willSeek = willSeek;
                intermediateStream = new MemoryStream();
                return intermediateStream;
            }
    
            public bool Render(Report report, 
                System.Collections.Specialized.NameValueCollection reportServerParameters, 
                System.Collections.Specialized.NameValueCollection deviceInfo, 
                System.Collections.Specialized.NameValueCollection clientCapabilities, 
                ref System.Collections.Hashtable renderProperties, 
                Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream)
            {
    
                //Call the render method of the intermediate rendering extension
                pdfRenderer.Render(report, reportServerParameters, deviceInfo, clientCapabilities, ref renderProperties, new Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream(IntermediateCreateAndRegisterStream));
    
                //Register stream for new rendering extension
                Stream outputStream = createAndRegisterStream(_name, _extension, _encoding, _mimeType, _willSeek, _operation);
    
    
                intermediateStream.Position = 0;
    
                //put stream update code here
    
                //Copy the stream to the outout stream
                byte[] buffer = new byte[32768];
    
                while (true) { 
                    int read = intermediateStream.Read(buffer, 0, buffer.Length); 
                    if (read <= 0) break; 
                    outputStream.Write(buffer, 0, read); 
                }
    
                intermediateStream.Close();
    
                return false;
            }
    
            public bool RenderStream(string streamName, Report report, System.Collections.Specialized.NameValueCollection reportServerParameters, System.Collections.Specialized.NameValueCollection deviceInfo, System.Collections.Specialized.NameValueCollection clientCapabilities, ref System.Collections.Hashtable renderProperties, Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream)
            {
                return false;
            }
    
            public string LocalizedName
            {
                get { return "PDF Renderer with background"; }
            }
    
            public void SetConfiguration(string configuration)
            {
                pdfRenderer.SetConfiguration(configuration);
            }
    
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to do something like add a nice-to-Excel-functions Name property to the
I would like to add the following MIME type to a site run by
I would like to add a DataGridViewTextBoxCell cell to a DataGridViewCell control, but as
I would like to add AES encryption to a software product, but am concerned
I would like to add graphing to my User Controls in ASP.NET MVC. I
I would like to add a typing speed indicator just below the textarea we
I would like to add a BuildListener to my headless build process, which is
I would like to add some icons to my treeview. Is there a way
I would like to add a method to a built-in type (e.g. Double), so
I would like to add OpenId support to an app. It runs on ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.