private static void HandleDocumentMap(DocumentMap documentMap, PDFLabel currentLabel, int currentLevel) { while (documentMap.MoveNext()) { DocumentMapNode current = documentMap.Current; PDFLabel pDFLabel = new PDFLabel(current.Id, current.Label); if (current.Level > currentLevel) { if (currentLabel.Children == null) { currentLabel.Children = new List <PDFLabel>(); } currentLabel.Children.Add(pDFLabel); pDFLabel.Parent = currentLabel; currentLevel++; } else if (current.Level == currentLevel) { currentLabel.Parent.Children.Add(pDFLabel); pDFLabel.Parent = currentLabel.Parent; } else { for (int num = currentLevel - current.Level; num >= 0; num--) { currentLabel = currentLabel.Parent; } currentLabel.Children.Add(pDFLabel); pDFLabel.Parent = currentLabel; currentLevel = current.Level; } currentLabel = pDFLabel; } }
public bool AddDocumentMap(DocumentMap docMap) { if (docMap == null) { return(false); } this.m_excel.SetCurrentSheetName(ExcelRenderRes.DocumentMap); int num = 0; this.m_excel.SetColumnExtents(0, this.m_excel.MaxColumns - 1); this.m_excel.SetSummaryRowAfter(false); this.m_excel.DefineCachedStyle("DocumentMapHyperlinkStyle"); this.m_excel.GetCellStyle().Color = this.m_excel.AddColor("Blue"); this.m_excel.GetCellStyle().Underline = Underline.Single; this.m_excel.GetCellStyle().Name = "Arial"; this.m_excel.GetCellStyle().Size = 10.0; this.m_excel.EndCachedStyle(); while (docMap.MoveNext() && num <= this.m_excel.MaxRows) { if (num % this.m_excel.RowBlockSize == 0) { for (int i = 0; i < this.m_excel.RowBlockSize; i++) { this.m_excel.AddRow(i + num); } } DocumentMapNode current = docMap.Current; this.m_excel.SetRowContext(num); this.m_excel.SetColumnContext(current.Level - 1); this.m_excel.SetCellValue(current.Label, TypeCode.String); if (num == 0) { this.m_excel.GetCellStyle().Bold = 700; this.m_excel.GetCellStyle().Name = "Arial"; this.m_excel.GetCellStyle().Size = 10.0; this.m_excel.GetCellStyle().Color = this.m_excel.AddColor("Black"); } else { this.m_excel.AddBookmarkLink(current.Label, current.Id); this.m_excel.UseCachedStyle("DocumentMapHyperlinkStyle"); } this.m_excel.SetRowProperties(num, 240, (byte)(current.Level - 1), current.Level > 2, false); this.m_excel.AddMergeCell(num, current.Level - 1, num, 32); num++; } for (int j = 0; j < this.m_excel.MaxColumns; j++) { this.m_excel.SetColumnProperties(j, 20.0, 0, false); } return(true); }
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(); }