/// <summary> /// creates a new rectangle /// </summary> /// <param name="RectangleArea">the area which will contains the rectangle</param> /// <param name="BorderColor"></param> public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor) { this.PdfDocument=PdfDocument; this.rectangleArea=RectangleArea; this.BorderColor=BorderColor; this.strokeWidth=1; }
/// <summary> /// creates a new rectangle /// </summary> /// <param name="RectangleArea"></param> /// <param name="BorderColor"></param> /// <param name="BorderWidth"></param> public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor,double BorderWidth) { this.PdfDocument=PdfDocument; if (BorderWidth<=0) throw new Exception("BorderWidth must be greater than zero."); this.rectangleArea=RectangleArea; this.BorderColor=BorderColor; this.strokeWidth=BorderWidth; }
internal void SetArea() { this.area=this.CellArea(startRow,0).Merge(this.CellArea(endRow,0)); double great=0; foreach (PdfArea pa in this.cellAreas.Values) { double d=pa.BottomRightCornerX; if(d>great) great=d; } this.area.BottomRightCornerX=great; }
/// <summary> /// Creates a new Flow Text Area. /// </summary> /// <param name="TextArea">the PdfArea which will contains the Text.</param> /// <param name="Font">the starting Font of the writings.</param> /// <param name="Color">the starting Color of the writings.</param> public PdfFlowTextArea(PdfArea TextArea,Font Font,Color Color) { this.Stream=""; this.posX=TextArea.PosX; this.posY=TextArea.PosY; this.startX=TextArea.PosX; this.startY=TextArea.PosY; this.endX=TextArea.BottomRightCornerX; this.endY=TextArea.BottomRightCornerY; this.interline=Font.Size*1.6; this.Fonts=new ArrayList(); this.SetColor(Color); this.SetFont(Font); }
internal void SetArea() { this.area = this.CellArea(startRow, 0).Merge(this.CellArea(endRow, 0)); double great = 0; foreach (PdfArea pa in this.cellAreas.Values) { double d = pa.BottomRightCornerX; if (d > great) { great = d; } } this.area.BottomRightCornerX = great; }
/// <summary> /// creates a circle with different x and y diamaters (ellipse) /// </summary> /// <param name="posx">center's x coordinate</param> /// <param name="posy">center's y coordinate</param> /// <param name="XDiameter">x diameter measure</param> /// <param name="YDiameter">y diameter measure</param> /// <param name="Color">circumference color</param> public PdfCircle(double posx, double posy, double XDiameter, double YDiameter, Color Color) { if (XDiameter <= 0) { throw new Exception("XDiameter must be grater than zero."); } if (YDiameter <= 0) { throw new Exception("YDiameter must be grater than zero."); } this.axesArea = new PdfArea(this.PdfDocument, posx - XDiameter / 2, posy - YDiameter / 2, XDiameter, YDiameter); this.BorderColor = Color; this.strokeWidth = 1; }
/// <summary> /// Creates a new Flow Text Area. /// </summary> /// <param name="TextArea">the PdfArea which will contains the Text.</param> /// <param name="Font">the starting Font of the writings.</param> /// <param name="Color">the starting Color of the writings.</param> /// <param name="StartX">the starting X position of the writing cursor.</param> /// <param name="StartY">the starting Y position of the writing cursor.</param> public PdfFlowTextArea(PdfArea TextArea,Font Font,Color Color,double StartX,double StartY) { this.Stream=""; this.posX=TextArea.PosX; this.posY=TextArea.PosY; this.startX=StartX; this.startY=StartY; this.endX=TextArea.BottomRightCornerX; this.endY=TextArea.BottomRightCornerY; if (this.startX<this.posX||this.startX>this.endX) throw new Exception("Starting Point cannot be outside the FlowTextArea."); if (this.startY<this.posY||this.startY>this.endY) throw new Exception("Starting Point cannot be outside the FlowTextArea."); this.Fonts=new ArrayList(); this.SetColor(Color); this.SetFont(Font); this.interline=Font.Size*1.6; }
private void AddLeyenda(int yPos, PdfPage page, params string[] leyendas) { var colores = new[] { FunctionLibrary.ChartBarColorBlue, FunctionLibrary.ChartBarColorRed, FunctionLibrary.ChartBarColorGreen }; for (int i = 0; i < leyendas.Length && i < 3; i++) { var lArea = new PdfArea(pdfDocument, 410, yPos + i * 15, 5, 5); var r = new PdfRectangle(pdfDocument, lArea, colores[i], 1, colores[i]); var text = new PdfTextArea( Function_Library.FontTexto09, Color.Black, new PdfArea(pdfDocument, 425, (yPos - 2) + i * 15, 100, 20), ContentAlignment.TopLeft, leyendas[i]); page.Add(r); page.Add(text); } }
private void ProcessBox(PdfPage page, Com.Delta.Print.Engine.Box box) { try { if (box.FillStyle == Box.FillStyles.Solid) { PdfArea area = new PdfArea(pdfDocument, Convert(box.Bounds.X), Convert(box.Bounds.Y), Convert(box.Bounds.Width), Convert(box.Bounds.Height)); if (box.BorderWidth > 0 || box.Color != Color.Transparent) { PdfRectangle pdfBox = new PdfRectangle(pdfDocument, area, box.BorderColor, box.BorderWidth, box.Color); page.Add(pdfBox); } } else { int boxHash = box.GetHashCode(); PdfImage image = null; if (images.Contains(boxHash)) { image = pdfDocument.GetObject((int)images[boxHash]) as PdfImage; } else { if (box.Color != Color.Transparent && box.GradientColor != Color.Transparent) { image = new PdfImage(pdfDocument.GetNextId, box.Image, false); } else { image = pdfDocument.NewImage(box.Image); } images[boxHash] = image.PublicID; } image.Width = Convert(box.Width); image.Height = Convert(box.Height); page.Add(image, Convert(box.Bounds.X), Convert(box.Bounds.Y), Convert(box.Bounds.Width), Convert(box.Bounds.Height)); } } catch (Exception e) {} }
private void ProcessRichTextField(PdfPage page, Com.Delta.Print.Engine.RichTextField richTextField) { try { PdfArea area = new PdfArea(pdfDocument, Convert(richTextField.Bounds.X), Convert(richTextField.Bounds.Y), Convert(richTextField.Bounds.Width), Convert(richTextField.Bounds.Height)); if ((richTextField.BorderWidth > 0 && richTextField.BorderColor != Color.Transparent) || richTextField.BackgroundColor != Color.Transparent) { PdfRectangle border = new PdfRectangle(pdfDocument, area, richTextField.BorderColor, Convert(richTextField.BorderWidth), richTextField.BackgroundColor); page.Add(border); } PdfRichTextBox p = new PdfRichTextBox(pdfDocument, (int)Convert(richTextField.Bounds.X + richTextField.Padding), (int)Convert(richTextField.Bounds.Y + richTextField.Padding), (int)Convert(richTextField.Bounds.Width - 2 * richTextField.Padding), (int)Convert(richTextField.Bounds.Height - 2 * richTextField.Padding)); p.SetLines(new ArrayList(richTextField.lines)); page.Add(p); } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
private void ProcessTextField(PdfPage page, Com.Delta.Print.Engine.TextField textField) { try { //PdfArea area = new PdfArea(pdfDocument, Convert(textField.X), Convert(textField.Y), Convert(textField.Width), Convert(textField.Height)); PdfArea area = new PdfArea(pdfDocument, Convert(textField.Bounds.X), Convert(textField.Bounds.Y), Convert(textField.Bounds.Width), Convert(textField.Bounds.Height)); if ((textField.BorderWidth > 0 && textField.BorderColor != Color.Transparent) || textField.BackgroundColor != Color.Transparent) { PdfRectangle border = new PdfRectangle(pdfDocument, area, textField.BorderColor, textField.BorderWidth, textField.BackgroundColor); page.Add(border); } string content = textField.CurrentText.Replace("\r", ""); if (content != String.Empty) { //PdfArea textArea = new PdfArea(pdfDocument, Convert(textField.X + textField.Padding), Convert(textField.Y + textField.Padding), Convert(textField.Width - 2*textField.Padding), Convert(textField.Height - 2*textField.Padding)); PdfArea textArea = new PdfArea(pdfDocument, Convert(textField.Bounds.X + textField.Padding), Convert(textField.Bounds.Y + textField.Padding), Convert(textField.Bounds.Width - 2 * textField.Padding), Convert(textField.Bounds.Height - 2 * textField.Padding)); float ratio = 96f / textField.Section.Document.GetGraphics().DpiX; PdfTextArea pdfTextArea = new PdfTextArea(textField.Font, textField.ForegroundColor, textArea, GetTextHorizontalAlignment(textField.TextAlignment), GetTextVerticalAlignment(textField.TextVerticalAlignment), content, textField.TextOrientation == TextField.Orientation.Vertical); pdfTextArea.Underline = textField.Font.Underline; pdfTextArea.SetFontRatio(ratio); pdfTextArea.SetLineSpacing(Convert(textField.Spacing)); if (textField.TextAlignment == TextField.TextAlignmentType.Justified) { pdfTextArea.SetJustification(textField.Justification); } page.Add(pdfTextArea); } } catch (Exception e) {} }
private void AddGraficoPercentiles(int y, PdfPage page) { var text = new PdfTextArea( Function_Library.FontTitulo, Color.Black, new PdfArea(pdfDocument, 80, y, 450, 20), ContentAlignment.MiddleCenter, PDF_Resources.Title_GraficosResultadosGenerales); page.Add(text); var chart = new Ar_Chart(ChartReportClass.PERCENTILES, 1000, 650, datos.TNotaciones.ChR_TNotaciones); PdfImage grafico = Function_Library.ToPDFImage(chart.ToBinary(), pdfDocument); if (grafico != null) { page.Add(grafico, 55, y + 25, 170); } var lArea = new PdfArea(pdfDocument, 55, y + 20, 490, 280); var r = new PdfRectangle(pdfDocument, lArea, Color.LightGray); page.Add(r); }
private void AddGraficoErrores(int y, PdfPage page) { var text = new PdfTextArea( Function_Library.FontTitulo, Color.Black, new PdfArea(pdfDocument, 80, y, 450, 20), ContentAlignment.MiddleCenter, PDF_Resources.Title_GraficoErrores); page.Add(text); var chart = new Ar_Chart(ChartReportClass.ERRORES, 1000, 600, datos.ChR_Errores); PdfImage grafico = Function_Library.ToPDFImage(chart.ToBinary(), pdfDocument); if (grafico != null) { page.Add(grafico, 55, y + 25, 200); } AddLeyenda(y + 95, page, PDF_Resources.Leyend_EComision, PDF_Resources.Leyend_EOmision, PDF_Resources.Leyend_IA); var lArea = new PdfArea(pdfDocument, 55, y + 20, 490, 250); var r = new PdfRectangle(pdfDocument, lArea, Color.LightGray); page.Add(r); }
private void ProcessStyledTable(PdfPage page, Com.Delta.Print.Engine.StyledTable table) { try { DataTable data = table.DataSource == null ? table.DisplayData : table.Data; int visibleColumnCount = table.GetVisibleColumnsCount(); if (data == null) { data = new DataTable(); for (int i = 0; i < visibleColumnCount; i++) { data.Columns.Add(); } } if (data.Rows.Count == 0) { if (table.DrawEmptyRows) { int maxRows = table.Bounds.Height / table.CellHeight; PdfTable pdfTable = pdfDocument.NewTable(table.DataFont, maxRows, visibleColumnCount, 2); System.Data.DataTable dt = new System.Data.DataTable(); for (int i = 0; i < visibleColumnCount; i++) { dt.Columns.Add(""); } for (int i = 0; i < table.Height / table.CellHeight; i++) { dt.Rows.Add(dt.NewRow()); if (dt.Columns.Count > 0) { dt.Rows[i][0] = " "; } } pdfTable.ImportDataTable(dt); pdfTable.SetRowHeight(Convert(table.CellHeight)); pdfTable.HeadersRow.SetRowHeight(Convert(table.CellHeight)); pdfTable.HeadersRow.SetColors(table.HeaderFontColor, table.HeaderBackgroundColor); pdfTable.HeadersRow.SetFont(table.HeaderFont); int count = 0; for (int i = 0; i < table.Columns.Length; i++) { if (table.Columns[i].Width > 0) { string columnName = table.Columns[i].Label == String.Empty || table.Columns[i].Label == "" ? " " : table.Columns[i].Label; pdfTable.HeadersRow[count].SetContent(columnName); count++; } } pdfTable.SetColors(table.DataFontColor, table.BackgroundColor); pdfTable.SetBorders(table.BorderColor, 1, BorderType.CompleteGrid); if (table.AlternateBackColor) { for (int i = 0; i < dt.Rows.Count; i++) { if (i % 2 == 1) { pdfTable.Rows[i].SetBackgroundColor(table.AlternatingBackColor); } } } int[] columnWidths = new int[visibleColumnCount]; int tableWidth = 0; count = 0; for (int i = 0; i < table.Columns.Length; i++) { if (table.Columns[i].Width > 0) { columnWidths[count] = (int)Convert(table.Columns[i].Width); tableWidth += columnWidths[count]; count++; } } pdfTable.SetColumnsWidth(columnWidths); count = 0; for (int i = 0; i < table.Columns.Length; i++) { if (table.Columns[i].Width > 0) { Com.Delta.Print.Engine.Pdf.HorizontalAlignment columnAlignment = GetColumnContentAlignment(table.Columns[i].Alignment); pdfTable.HeadersRow[count].SetContentAlignment(columnAlignment, VerticalAlignment.Middle); pdfTable.Columns[count].SetContentAlignment(columnAlignment, VerticalAlignment.Middle); count++; } } pdfTable.VisibleHeaders = table.DrawHeader; PdfTablePage tablePage = pdfTable.CreateTablePage(new PdfArea(pdfDocument, Convert(table.Bounds.X), Convert(table.Bounds.Y), tableWidth, Convert(table.Bounds.Height))); page.Add(tablePage); } else if (table.DrawHeader && !table.DrawEmptyRows) { int position = table.Bounds.X; int headerRelativeHeight = 1; for (int i = 0; i < table.Columns.Length; i++) { if (table.Columns[i].Width > 0) { PdfArea area = new PdfArea(pdfDocument, Convert(position + 2), Convert(table.Bounds.Y + 2), Convert(table.Columns[i].Width - 4), Convert(table.CellHeight - 4)); PdfTextArea pdfTextArea = new PdfTextArea(table.HeaderFont, table.HeaderFontColor, area, GetColumnContentAlignment(table.Columns[i].Alignment), VerticalAlignment.Middle, table.Columns[i].Label, false); int minimumLines = pdfTextArea.RenderLines().Count; headerRelativeHeight = Math.Max(headerRelativeHeight, minimumLines); } } int headerHeight = table.CellHeight * headerRelativeHeight; for (int i = 0; i < table.Columns.Length; i++) { if (table.Columns[i].Width > 0) { PdfArea area = new PdfArea(pdfDocument, Convert(position + 2), Convert(table.Bounds.Y + 2), Convert(table.Columns[i].Width - 4), Convert(headerHeight - 4)); PdfArea borderArea = new PdfArea(pdfDocument, Convert(position), Convert(table.Bounds.Y), Convert(table.Columns[i].Width), Convert(headerHeight)); PdfRectangle border = new PdfRectangle(pdfDocument, borderArea, table.BorderColor, 1, table.HeaderBackgroundColor); page.Add(border); PdfTextArea pdfTextArea = new PdfTextArea(table.HeaderFont, table.HeaderFontColor, area, GetColumnContentAlignment(table.Columns[i].Alignment), VerticalAlignment.Middle, table.Columns[i].Label, false); // arbitrary line spacing pdfTextArea.SetLineSpacing(Convert(table.CellHeight / 8)); page.Add(pdfTextArea); position += table.Columns[i].Width; } } } else { return; } } else { int maxRows = table.Height / table.CellHeight; int rowCount = data.Rows.Count; PdfTable pdfTable; double cellPadding = Math.Max(0, Math.Min(2, Math.Floor(0.5 * (table.CellHeight - table.DataFont.GetHeight())))); if (table.DrawEmptyRows) { pdfTable = pdfDocument.NewTable(table.DataFont, rowCount + maxRows, visibleColumnCount, cellPadding); } else { pdfTable = pdfDocument.NewTable(table.DataFont, rowCount, visibleColumnCount, cellPadding); } pdfTable.pdfPage = page; System.Data.DataTable dt = new System.Data.DataTable(); for (int i = 0; i < table.Columns.Length; i++) { if (table.Columns[i].Width > 0) { if (table.Columns[i].FormatMask == "Image") { dt.Columns.Add("", typeof(byte[])); } else { dt.Columns.Add("", typeof(System.String)); } } } for (int i = 0; i < data.Rows.Count; i++) { if (data.Rows[i].RowError == "Subtotal") { object[] rowData = new object[visibleColumnCount]; int cnt = 0; for (int j = 0; j < table.Columns.Length; j++) { if (table.Columns[j].Width > 0) { rowData[cnt] = table.Subtotals[j]; cnt++; } } dt.Rows.Add(rowData); } else { object[] rowData = new object[visibleColumnCount]; int cnt = 0; for (int j = 0; j < table.Columns.Length; j++) { if (table.Columns[j].Width > 0) { if (table.Columns[j].FormatMask == null || table.Columns[j].FormatMask == String.Empty) { rowData[cnt] = String.Format("{0}", data.Rows[i][j]); } else if (table.Columns[j].FormatMask == "Image") { rowData[cnt] = data.Rows[i][j] is byte[] ? data.Rows[i][j] : null; } else { rowData[cnt] = String.Format("{0:" + table.Columns[j].FormatMask + "}", data.Rows[i][j]); } cnt++; } } dt.Rows.Add(rowData); } } if (table.DrawEmptyRows) { for (int i = 0; i < table.Height / table.CellHeight; i++) { dt.Rows.Add(dt.NewRow()); } } pdfTable.ImportDataTable(dt); pdfTable.SetRowHeight(Convert(table.CellHeight)); pdfTable.VisibleHeaders = table.DrawHeader; pdfTable.HeadersRow.SetRowHeight(Convert(table.CellHeight)); pdfTable.HeadersRow.SetColors(table.HeaderFontColor, table.HeaderBackgroundColor); pdfTable.HeadersRow.SetFont(table.HeaderFont); pdfTable.SetColors(table.DataFontColor, table.BackgroundColor); pdfTable.SetBorders(table.BorderColor, 1, BorderType.CompleteGrid); //pdfTable.SetBorders(table.BorderColor, (table.BorderColor == Color.Transparent ? 0 : 1), BorderType.CompleteGrid); int[] columnWidths = new int[visibleColumnCount]; int tableWidth = 0; int count = 0; for (int i = 0; i < table.Columns.Length; i++) { if (table.Columns[i].Width > 0) { columnWidths[count] = (int)Convert(table.Columns[i].Width); tableWidth += columnWidths[count]; string columnName = table.Columns[i].Label == String.Empty || table.Columns[i].Label == "" ? " " : table.Columns[i].Label; pdfTable.HeadersRow[count].SetContent(columnName); Com.Delta.Print.Engine.Pdf.HorizontalAlignment columnAlignment = GetColumnContentAlignment(table.Columns[i].Alignment); pdfTable.HeadersRow[count].SetContentAlignment(columnAlignment, VerticalAlignment.Middle); pdfTable.Columns[count].SetContentAlignment(columnAlignment, VerticalAlignment.Middle); count++; } } pdfTable.SetColumnsWidth(columnWidths); ArrayList alterRows = table.AlterRows; for (int i = 0; i < data.Rows.Count; i++) { if (table.AlternateBackColor && i % 2 == 1) { pdfTable.Rows[i].SetBackgroundColor(table.AlternatingBackColor); } if (alterRows != null && alterRows.Count > 0) { if (alterRows.Contains(data.Rows[i]) && i < pdfTable.Rows.Length) { pdfTable.Rows[i].SetForegroundColor(table.AlterDataColor); pdfTable.Rows[i].SetBackgroundColor(table.AlterDataBackColor); } } } if (table.DrawEmptyRows && table.AlternateBackColor) { for (int i = data.Rows.Count; i < table.Height / table.CellHeight; i++) { if (i % 2 == 1) { pdfTable.Rows[i].SetBackgroundColor(table.AlternatingBackColor); } } } if (table.HasSubtotals) { for (int i = 0; i < data.Rows.Count; i++) { if (data.Rows[i].RowError == "Subtotal" && i < pdfTable.Rows.Length) { pdfTable.Rows[i].SetForegroundColor(table.SubtotalsColor); } } } PdfTablePage tablePage = pdfTable.CreateTablePage(new PdfArea(pdfDocument, Convert(table.Bounds.X), Convert(table.Bounds.Y), tableWidth, Convert(table.Bounds.Height))); page.Add(tablePage); foreach (PdfImage image in pdfTable.Images.Keys) { RectangleF area = (RectangleF)pdfTable.Images[image]; page.Add(image, area.X, area.Y, 0.72 * area.Width, 0.72 * area.Height); } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
private void ProcessPicture(PdfPage page, Com.Delta.Print.Engine.PictureBox picture) { try { if (picture.Image == null && (picture.Image == null || picture.ImageFile == string.Empty)) { return; } string imageFile = picture.Section.Document.DocRoot + Path.DirectorySeparatorChar + picture.ImageFile; PdfImage image = null; if (picture.Image != null) { int imageHash = picture.Image.GetHashCode(); if (images.Contains(imageHash)) { image = pdfDocument.GetObject((int)images[imageHash]) as PdfImage; } else { if (picture.Image.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg)) { image = new PdfImage(pdfDocument.GetNextId, picture.Image, false); } else { image = pdfDocument.NewImage(picture.Image); } images[imageHash] = image.PublicID; } if (picture.Stretch) { image.Width = Convert(picture.Width); image.Height = Convert(picture.Height); } else { image.Width = Convert(picture.ImageSize.Width); image.Height = Convert(picture.ImageSize.Height); } } else { if (images.Contains(imageFile)) { image = pdfDocument.GetObject((int)images[imageFile]) as PdfImage; if (picture.Stretch) { image.Width = Convert(picture.Width); image.Height = Convert(picture.Height); } else { image.Width = Convert(picture.ImageSize.Width); image.Height = Convert(picture.ImageSize.Height); } } else { double imageWidth = 0; double imageHeight = 0; if (picture.Stretch) { imageWidth = Convert(picture.Width); imageHeight = Convert(picture.Height); } else { imageWidth = Convert(picture.ImageSize.Width); imageHeight = Convert(picture.ImageSize.Height); } image = pdfDocument.NewImage(picture.Section.Document.DocRoot + Path.DirectorySeparatorChar + picture.ImageFile, imageWidth, imageHeight); images[imageFile] = image.PublicID; } } if (image != null) { image.Quality = System.Convert.ToInt64(picture.ExportQuality); page.Add(image, Convert(picture.Bounds.X), Convert(picture.Bounds.Y), Convert(picture.Bounds.Width), Convert(picture.Bounds.Height)); } if (picture.BorderWidth > 0) { PdfArea area = new PdfArea(pdfDocument, Convert(picture.Bounds.X), Convert(picture.Bounds.Y), Convert(picture.Bounds.Width), Convert(picture.Bounds.Height)); PdfRectangle border = new PdfRectangle(pdfDocument, area, picture.BorderColor, picture.BorderWidth, Color.Transparent); page.Add(border); } } catch (Exception e) {} }
/// <summary> /// creates a new PdfTextArea /// </summary> /// <param name="Font">the font that will be used</param> /// <param name="Color">the color of the font that will be used</param> /// <param name="TextArea">the estabilished area for the Text</param> /// <param name="PdfTextAlign">the ContentAlignment for the Text inside the area</param> /// <param name="Text">the text that will be written inside the area</param> public PdfTextArea(System.Drawing.Font Font,System.Drawing.Color Color,PdfArea TextArea,ContentAlignment PdfTextAlign,string Text) { if (Text==null) throw new Exception("Text cannot be null."); this.Font=Font; this.Color=Color; this.textArea=TextArea; this.text=Text; this.textAlign=PdfTextAlign; this.lineHeight=(double)(Font.Size); }
/// <summary> /// creates a new rectangle /// </summary> /// <param name="RectangleArea"></param> /// <param name="BorderColor"></param> /// <param name="FillingColor"></param> public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor,Color FillingColor) { this.PdfDocument=PdfDocument; this.rectangleArea=RectangleArea; this.BorderColor=BorderColor; this.FillingColor=FillingColor; this.filled=true; this.strokeWidth=1; }
/// <summary> /// creates a new circle /// </summary> /// <param name="posx">center's x coordinate</param> /// <param name="posy">center's y coordinate</param> /// <param name="ray">ray measure</param> /// <param name="Color">circumference color</param> public PdfCircle(double posx,double posy,double ray,Color Color) { if (ray<=0) throw new Exception("Ray must be grater than zero."); this.axesArea=new PdfArea(this.PdfDocument,posx-ray,posy-ray,ray*2,ray*2); this.BorderColor=Color; this.strokeWidth=1; }
/// <summary> /// Creates the TablePage, the rasterized page of a Table. /// </summary> /// <param name="PageArea"></param> /// <returns></returns> public PdfTablePage CreateTablePage(PdfArea PageArea) { this.TableArea=PageArea.Clone(); PdfTablePage ptp; if (!this.visibleHeaders) ptp=this.createTablePage(); else { this.header.TableArea=PageArea.Clone(); this.header.TableArea.height=this.HeadersRow.Height; this.TableArea.posy+=this.HeadersRow.Height; this.TableArea.height-=this.HeadersRow.Height; ptp=this.createTablePage(); ptp.stream+=this.header.createTablePage().stream; this.header.renderingIndex=0; } foreach (PdfColumn pc in this.Columns) pc.CompensatedWidth=-1; foreach (PdfColumn pc in this.header.Columns) pc.CompensatedWidth=-1; return ptp; }
public PdfAutoBox(PdfXY upper_left, PdfGrow grow_direction, PdfArea area = null, PdfArea max_area = null, PdfBorder borders = null, PdfBoxLayout box_layout = null) : this(upper_left, grow_direction, PdfAlign.Far, area ?? new PdfArea(0, 0), max_area, borders, box_layout) { }
public PdfAutoBox(PdfXY upper_left, PdfGrow grow_direction, PdfAlign v_align, PdfArea area, PdfArea max_area = null, PdfBorder borders = null, PdfBoxLayout box_layout = null) : base(borders, box_layout) { UpperLeft = upper_left; GrowDirection = grow_direction; VAlign = v_align; Area = area; MaxArea = max_area ?? new PdfArea(max_box_size, max_box_size); }
public Stream GenerateSelectedTasksPDF(IEnumerable <SelectedTask> selectedTasks, ReportInfo reportInfo) { int countSelectedTasks = selectedTasks.Count(); int totalNoiseDosage = selectedTasks.Sum(x => x.Percentage); NoiseLevelEnum noiseLevelEnum = _noiseLevelService.CalculateNoiseLevelEnum(totalNoiseDosage); Color noiseLevelColor = GetColorForNoiseLevel(noiseLevelEnum); DataTable dataTable = GenerateDataTable(selectedTasks); // Starting instantiate the document. // Remember to set the Docuement Format. In this case, we specify width and height. PdfDocument myPdfDocument = new PdfDocument(PdfDocumentFormat.A4_Horizontal); // Now we create a Table with lines likt the number of selected tasks, 6 columns and 4 points of Padding. PdfTable myPdfTable = myPdfDocument.NewTable(new Font("Verdana", 12), countSelectedTasks, 6, 4); // Importing datas from the datatables... (also column names for the headers!) myPdfTable.ImportDataTable(dataTable); // Now we set our Graphic Design: Colors and Borders... myPdfTable.HeadersRow.SetColors(Color.FromRgb(255, 255, 255), Color.FromRgb(0, 0, 255)); myPdfTable.SetColors(Color.FromRgb(0, 0, 0), Color.FromRgb(255, 255, 255), Color.FromRgb(0, 255, 255)); myPdfTable.SetBorders(Color.FromRgb(0, 0, 0), 1, BorderType.CompleteGrid); // With just one method we can set the proportional width of the columns. // It's a "percentage like" assignment, but the sum can be different from 100. myPdfTable.SetColumnsWidth(new int[] { 90, 25, 45, 20, 20, 10 }); // Now we set some alignment... for the whole table and then, for a column. myPdfTable.SetContentAlignment(ContentAlignment.MiddleCenter); foreach (PdfColumn pdfColumn in myPdfTable.Columns) { pdfColumn.SetContentAlignment(ContentAlignment.MiddleLeft); } // Here we start the loop to generate the table... while (!myPdfTable.AllTablePagesCreated) { // we create a new page to put the generation of the new TablePage: PdfPage newPdfPage = myPdfDocument.NewPage(); // LAKHA PdfArea pdfArea = new PdfArea(myPdfDocument, 48, 95, 750, 670); PdfTablePage taskTable = myPdfTable.CreateTablePage(pdfArea); // we also put a Label PdfTextArea reportTitle = new PdfTextArea(new Font("Verdana", 26, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 48, 20, 595, 60), ContentAlignment.TopLeft, ReportResource.ReportTitle); // LAKHA - Status PdfTextArea statusText = new PdfTextArea(new Font("Verdana", 14, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 48, taskTable.CellArea(taskTable.LastRow, 6 - 1).BottomRightCornerY + 10, 595, 60), ContentAlignment.TopLeft, _noiseLevelService.GetNoiseLevelStatusText(noiseLevelEnum)); // LAKHA - Total prosent PdfRectangle summaryBackground = new PdfArea(myPdfDocument, 635, taskTable.CellArea(taskTable.LastRow, 6 - 1).BottomRightCornerY + 10, 165, 45).ToRectangle(noiseLevelColor, noiseLevelColor); PdfTextArea summary = new PdfTextArea(new Font("Verdana", 26, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 640, taskTable.CellArea(taskTable.LastRow, 6 - 1).BottomRightCornerY + 20, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.TotalPercentageFormatString, totalNoiseDosage)); // nice thing: we can put all the objects in the following lines, so we can have // a great control of layer sequence... newPdfPage.Add(taskTable); newPdfPage.Add(reportTitle); newPdfPage.Add(statusText); newPdfPage.Add(summaryBackground); newPdfPage.Add(summary); // Info from report input window PdfTextArea reportPlant = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 48, 50, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.PlantFormatString, reportInfo.Plant)); PdfTextArea reportCreatedBy = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 650, 50, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.UserFormatString, reportInfo.CreatedBy)); PdfTextArea reportProfession = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 48, 65, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.ProfessionFormatString, reportInfo.Group)); PdfTextArea reportDate = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 650, 65, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.DateFormatString, (reportInfo.Date.HasValue) ? reportInfo.Date.Value.ToString("dd.MM.yyyy") : string.Empty)); PdfTextArea reportComment = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0) , new PdfArea(myPdfDocument, 48, 80, 700, 60), ContentAlignment.TopLeft, string.Format(ReportResource.CommentFormatString, reportInfo.Comment)); newPdfPage.Add(reportPlant); newPdfPage.Add(reportCreatedBy); newPdfPage.Add(reportProfession); newPdfPage.Add(reportDate); newPdfPage.Add(reportComment); // LAKHA - Add footnotes... const int widthOfFootnote = 750; Font footnoteFont = new Font("Verdana", 9, FontStyle.Regular); double posY = statusText.PdfArea.BottomRightCornerY + 3; foreach (string footNoteText in reportInfo.Footnotes) { int heightOfFootnote = 10; if (footNoteText.Length > 380) { heightOfFootnote = heightOfFootnote * 3; } else if (footNoteText.Length > 160) { heightOfFootnote = heightOfFootnote * 2; } PdfArea pdfAreaForText = new PdfArea(myPdfDocument, 48, posY, widthOfFootnote, heightOfFootnote); PdfTextArea footNote = new PdfTextArea(footnoteFont, Color.FromRgb(0, 0, 0), pdfAreaForText, ContentAlignment.TopLeft, string.Format("* {0}", footNoteText)); newPdfPage.Add(footNote); posY = footNote.PdfArea.BottomRightCornerY + 2; } // we save each generated page before start rendering the next. newPdfPage.SaveToDocument(); } // Finally we save the docuement... Stream memoryStream = new MemoryStream(); myPdfDocument.SaveToStream(memoryStream); memoryStream.Seek(0, SeekOrigin.Begin); return(memoryStream); }
/// <summary> /// creates a circle with different x and y diamaters (ellipse) /// </summary> /// <param name="posx">center's x coordinate</param> /// <param name="posy">center's y coordinate</param> /// <param name="XDiameter">x diameter measure</param> /// <param name="YDiameter">y diameter measure</param> /// <param name="Color">circumference color</param> public PdfCircle(double posx,double posy,double XDiameter,double YDiameter,Color Color) { if (XDiameter<=0) throw new Exception("XDiameter must be grater than zero."); if (YDiameter<=0) throw new Exception("YDiameter must be grater than zero."); this.axesArea=new PdfArea(this.PdfDocument,posx-XDiameter/2,posy-YDiameter/2,XDiameter,YDiameter); this.BorderColor=Color; this.strokeWidth=1; }
public PdfPage(PdfArea area) { Area = area; }
public PdfJpegImage(byte[] jpeg_data, PdfArea jpeg_area, PdfRect image_position, int bits_per_color = 8) : base(jpeg_data, jpeg_area, image_position) { BitsPerColor = bits_per_color; }
public PdfImage(byte[] image_data, PdfArea image_size, PdfRect image_position) { ImageData = image_data; ImageArea = image_size; Rectange = image_position; }
/// <summary> /// sets the diameters lenght of the circle. /// </summary> /// <param name="XDiameter"></param> /// <param name="YDiameter"></param> public void SetDiameters(double XDiameter,double YDiameter) { if (XDiameter<=0) throw new Exception("XDiameter must be grater than zero."); if (YDiameter<=0) throw new Exception("YDiameter must be grater than zero."); this.axesArea=new PdfArea(this.PdfDocument,this.axesArea.CenterX-XDiameter/2,this.axesArea.CenterY-YDiameter/2,XDiameter,YDiameter); }
public PdfCircle(float posx, float posy, float ray, Color Color) { this.axesArea = new PdfArea(posx - ray, posy - ray, ray * 2, ray * 2); this.BorderColor = Color; this.strokeWidth = 1; }
/// <summary> /// Extends the area to the bounds of another area /// </summary> /// <param name="Area"></param> /// <returns></returns> public PdfArea Merge(PdfArea Area) { PdfArea res=this.MemberwiseClone() as PdfArea; if (this.PosX>Area.PosX) { res.PosX=Area.PosX; res.Width=Area.Width; } if (this.PosY>Area.PosY) { res.PosY=Area.PosY; res.Height=Area.Height; } if (this.BottomRightCornerX<Area.BottomRightCornerX) { res.BottomRightCornerX=Area.BottomRightCornerX; } if (this.BottomRightCornerY<Area.BottomRightCornerY) { res.BottomRightCornerY=Area.BottomRightCornerY; } return res; }