レポートサービスレポートのすべてのページに、完全なID情報とグラフィックスを含むPDFファイルを追加したいとします。このレポートは、Dynamics CRMのレポートビューアからレンダリングされます。私は、既存のPDFエクスポートレンダリング拡張を呼び出すレンダリング拡張を作成し、ABCPdfのようなPDFコンポーネントを使用することを検討していました。サービスをクライアントに送信する前にレポートサービスによってレンダリングされたPDFを変更する
私はPDFの背景レンダリングを行う方法を知っていますが、既存のレンダリング拡張を新しい実装から呼び出すことができませんでした。
既存のPDFレンダリング拡張は封印されたクラスであり、別の実装のレンダリングメソッドを使用することは不可能であるようです。
次に、http要求を使用して直接レポートサーバーを呼び出そうとしましたが、偽装の問題が原因で、これを動作させることができません。 「指定したドメイン名とユーザーIDを持つMicrosoft Dynamics CRMユーザーが存在しません」
私は正しい軌道に乗っていると思いますが、セキュリティ資格情報を取得する方法がわかりませんレンダリング拡張。
私はストリームとしてpdfの内容を取得することができます私はそれに背景を追加することができます。
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)
{
}
}
このソリューションについての私のcolleageのブログをvititしてください:[リンク](http://www.broes.nl/2011/02/pdf-watermarkbackground-rendering-extension-for-ssrs-part-1/) – jhoefnagels