protected override void Render(Microsoft.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection deviceInfo, Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream) { PaginationSettings paginationSettings = new PaginationSettings(report, deviceInfo); paginationSettings.UseEmSquare = true; paginationSettings.MeasureTextDpi = 1000; paginationSettings.UseGenericDefault = false; if (paginationSettings.DynamicImageDpiX == 96) { paginationSettings.DynamicImageDpiX = 300; } if (paginationSettings.DynamicImageDpiY == 96) { paginationSettings.DynamicImageDpiY = 300; } BufferedStream bufferedStream; using (Microsoft.ReportingServices.Rendering.HPBProcessing.HPBProcessing hPBProcessing = new Microsoft.ReportingServices.Rendering.HPBProcessing.HPBProcessing(report, paginationSettings, createAndRegisterStream, ref renderProperties)) { hPBProcessing.SetContext(hPBProcessing.PaginationSettings.StartPage, hPBProcessing.PaginationSettings.EndPage); using (Renderer renderer = new Renderer(physicalPagination: true)) { bufferedStream = new BufferedStream(createAndRegisterStream(report.Name, "pdf", null, "application/pdf", willSeek: false, StreamOper.CreateAndRegister)); using (PDFWriter pDFWriter = new PDFWriter(renderer, bufferedStream, disposeRenderer: false, createAndRegisterStream, hPBProcessing.PaginationSettings.DpiX, hPBProcessing.PaginationSettings.DpiY)) { pDFWriter.HumanReadablePDF = m_humanReadablePDF; pDFWriter.PrintOnOpen = m_printOnOpen; pDFWriter.Test = m_test; pDFWriter.EmbedFonts = m_embedFonts; if (report.HasDocumentMap) { DocumentMap documentMap = null; try { documentMap = report.DocumentMap; if (documentMap != null) { if (documentMap.MoveNext()) { DocumentMapNode current = documentMap.Current; HandleDocumentMap(documentMap, pDFWriter.DocumentMapRootLabel = new PDFLabel(current.Id, current.Label), 1); } if (pDFWriter.DocumentMapRootLabel.Children == null || pDFWriter.DocumentMapRootLabel.Children.Count == 0) { pDFWriter.DocumentMapRootLabel = null; } else { pDFWriter.DocumentMapLabelPoints = new Dictionary <string, PDFPagePoint>(); } } } finally { documentMap?.Dispose(); } } int num = hPBProcessing.PaginationSettings.StartPage; pDFWriter.BeginReport(hPBProcessing.PaginationSettings.MeasureTextDpi, hPBProcessing.PaginationSettings.MeasureTextDpi); while (true) { hPBProcessing.GetNextPage(out RPLReport rplReport); if (rplReport == null) { break; } renderer.ProcessPage(rplReport, num, hPBProcessing.SharedFontCache, hPBProcessing.GlyphCache); rplReport.Release(); rplReport = null; num++; } pDFWriter.EndReport(); } } } bufferedStream.Flush(); }
protected override void Render(Microsoft.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection deviceInfo, Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream) { PaginationSettings paginationSettings = new PaginationSettings(report, deviceInfo); string text = paginationSettings.OutputFormat.ToString().ToUpperInvariant(); bool flag = true; if (text == "TIFF") { text = "TIF"; flag = false; } else if (text == "EMFPLUS") { text = "EMF"; } if (text == "EMF") { paginationSettings.DynamicImageDpiX = 96; paginationSettings.DynamicImageDpiY = 96; paginationSettings.DpiX = m_printDpiX; paginationSettings.DpiY = m_printDpiY; ImageWriter.GetScreenDpi(out int dpiX, out int dpiY); paginationSettings.MeasureImageDpiX = dpiX; paginationSettings.MeasureImageDpiY = dpiY; } else { paginationSettings.MeasureImageDpiX = paginationSettings.DpiX; paginationSettings.MeasureImageDpiY = paginationSettings.DpiY; } paginationSettings.MeasureTextDpi = paginationSettings.DpiX; Stream stream; using (Microsoft.ReportingServices.Rendering.HPBProcessing.HPBProcessing hPBProcessing = new Microsoft.ReportingServices.Rendering.HPBProcessing.HPBProcessing(report, paginationSettings, createAndRegisterStream, ref renderProperties)) { hPBProcessing.SetContext(hPBProcessing.PaginationSettings.StartPage, hPBProcessing.PaginationSettings.EndPage); using (Renderer renderer = new Renderer(physicalPagination: true)) { stream = createAndRegisterStream(report.Name + (flag ? ("_" + hPBProcessing.PaginationSettings.StartPage.ToString(CultureInfo.InvariantCulture)) : ""), text, null, "image/" + text, !flag, StreamOper.CreateAndRegister); using (ImageWriter imageWriter = new ImageWriter(renderer, stream, disposeRenderer: false, createAndRegisterStream, paginationSettings.MeasureImageDpiX, paginationSettings.MeasureImageDpiY)) { imageWriter.OutputFormat = hPBProcessing.PaginationSettings.OutputFormat; hPBProcessing.PaginationSettings.UseGenericDefault = !imageWriter.IsEmf; imageWriter.BeginReport(hPBProcessing.PaginationSettings.DpiX, hPBProcessing.PaginationSettings.DpiY); int num = hPBProcessing.PaginationSettings.StartPage; while (true) { hPBProcessing.GetNextPage(out RPLReport rplReport); if (rplReport == null) { break; } if (flag && num > hPBProcessing.PaginationSettings.StartPage) { stream = (imageWriter.OutputStream = createAndRegisterStream(report.Name + "_" + num, text, null, "image/" + text, !flag, StreamOper.CreateForPersistedStreams)); } renderer.ProcessPage(rplReport, num, hPBProcessing.SharedFontCache, hPBProcessing.GlyphCache); rplReport.Release(); rplReport = null; num++; } imageWriter.EndReport(); } } } stream.Flush(); }