///<summary></summary> public static void DrawString(TextFrame frameContainer,string text,MigraDoc.DocumentObjectModel.Font font,RectangleF rectF, ParagraphAlignment alignment) { TextFrame frame=new TextFrame(); Paragraph par=frame.AddParagraph(); par.Format.Font=font.Clone(); par.Format.Alignment=alignment; par.AddText(text); frame.RelativeVertical=RelativeVertical.Page; frame.RelativeHorizontal=RelativeHorizontal.Page; frame.MarginLeft=Unit.FromInch(rectF.Left/100); frame.MarginTop=Unit.FromInch(rectF.Top/100); frame.Top=TopPosition.Parse("0 in"); frame.Left=LeftPosition.Parse("0 in"); frame.Width=Unit.FromInch(rectF.Right/100f);// frameContainer.Width; Unit bottom=Unit.FromInch(rectF.Bottom/100f); if(frameContainer.Height<bottom) { frameContainer.Height=bottom; } frame.Height=frameContainer.Height; //LineFormat lineformat=new LineFormat(); //lineformat.Width=1; //frame.LineFormat=lineformat; frameContainer.Elements.Add(frame); }
public RenderStyleTd(HtmlItem it, ref MigraDoc.DocumentObjectModel.Tables.Cell cc) { Cll = cc; It = it; }
private void PrepareStyles(MigraDoc.DocumentObjectModel.Document document) { // Get the predefined style Normal. Style style = document.Styles["Normal"]; // Because all styles are derived from Normal, the next line changes the // font of the whole document. Or, more exactly, it changes the font of // all styles and paragraphs that do not redefine the font. style.Font.Name = "Calibri"; style = document.Styles[StyleNames.Header]; style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right); style = document.Styles[StyleNames.Footer]; style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center); // Create a new style called Table based on style Normal style = document.Styles.AddStyle("Table", "Normal"); style.Font.Name = "Calibri"; style.Font.Size = 9; // Create a new style called Reference based on style Normal style = document.Styles.AddStyle("Reference", "Normal"); style.ParagraphFormat.SpaceBefore = "5mm"; style.ParagraphFormat.SpaceAfter = "5mm"; style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right); style.Font.Size = 16; }
internal static void Map(Font font, MigraDoc.DocumentObjectModel.Document domDocument, string domStyleName) { MigraDoc.DocumentObjectModel.Style domStyle = domDocument.Styles[domStyleName]; if (domStyle != null) { FontMapper mapper = new FontMapper(); mapper.MapObject(font, domStyle.Font); } }
void MapObject(DataLabel dataLabel, MigraDoc.DocumentObjectModel.Shapes.Charts.DataLabel domDataLabel) { if (!domDataLabel.IsNull("Style")) FontMapper.Map(dataLabel.Font, domDataLabel.Document, domDataLabel.Style); if (!domDataLabel.IsNull("Font")) FontMapper.Map(dataLabel.Font, domDataLabel.Font); dataLabel.Format = domDataLabel.Format; if (!domDataLabel.IsNull("Position")) dataLabel.Position = (DataLabelPosition)domDataLabel.Position; if (!domDataLabel.IsNull("Type")) dataLabel.Type = (DataLabelType)domDataLabel.Type; }
void MapObject(PlotArea plotArea, MigraDoc.DocumentObjectModel.Shapes.Charts.PlotArea domPlotArea) { plotArea.BottomPadding = domPlotArea.BottomPadding.Point; plotArea.RightPadding = domPlotArea.RightPadding.Point; plotArea.LeftPadding = domPlotArea.LeftPadding.Point; plotArea.TopPadding = domPlotArea.TopPadding.Point; if (!domPlotArea.IsNull("LineFormat")) LineFormatMapper.Map(plotArea.LineFormat, domPlotArea.LineFormat); if (!domPlotArea.IsNull("FillFormat")) FillFormatMapper.Map(plotArea.FillFormat, domPlotArea.FillFormat); }
void MapObject(FillFormat fillFormat, MigraDoc.DocumentObjectModel.Shapes.FillFormat domFillFormat) { if (domFillFormat.Color.IsEmpty) fillFormat.Color = XColor.Empty; else { #if noCMYK fillFormat.Color = XColor.FromArgb((int)domFillFormat.Color.Argb); #else fillFormat.Color = ColorHelper.ToXColor(domFillFormat.Color, domFillFormat.Document.UseCmykColor); #endif } fillFormat.Visible = domFillFormat.Visible; }
void MapObject(XValues xValues, MigraDoc.DocumentObjectModel.Shapes.Charts.XValues domXValues) { foreach (MigraDoc.DocumentObjectModel.Shapes.Charts.XSeries domXSeries in domXValues) { XSeries xSeries = xValues.AddXSeries(); MigraDoc.DocumentObjectModel.Shapes.Charts.XSeriesElements domXSeriesElements = domXSeries.GetValue("XSeriesElements") as MigraDoc.DocumentObjectModel.Shapes.Charts.XSeriesElements; foreach (MigraDoc.DocumentObjectModel.Shapes.Charts.XValue domXValue in domXSeriesElements) { if (domXValue == null) xSeries.AddBlank(); else xSeries.Add(domXValue.GetValue("Value").ToString()); } } }
void MapObject(Axis axis, MigraDoc.DocumentObjectModel.Shapes.Charts.Axis domAxis) { if (!domAxis.IsNull("TickLabels.Format")) axis.TickLabels.Format = domAxis.TickLabels.Format; if (!domAxis.IsNull("TickLabels.Style")) FontMapper.Map(axis.TickLabels.Font, domAxis.TickLabels.Document, domAxis.TickLabels.Style); if (!domAxis.IsNull("TickLabels.Font")) FontMapper.Map(axis.TickLabels.Font, domAxis.TickLabels.Font); if (!domAxis.IsNull("MajorTickMark")) axis.MajorTickMark = (TickMarkType)domAxis.MajorTickMark; if (!domAxis.IsNull("MinorTickMark")) axis.MinorTickMark = (TickMarkType)domAxis.MinorTickMark; if (!domAxis.IsNull("MajorTick")) axis.MajorTick = domAxis.MajorTick; if (!domAxis.IsNull("MinorTick")) axis.MinorTick = domAxis.MinorTick; if (!domAxis.IsNull("Title")) { axis.Title.Caption = domAxis.Title.Caption; if (!domAxis.IsNull("Title.Style")) FontMapper.Map(axis.Title.Font, domAxis.Title.Document, domAxis.Title.Style); if (!domAxis.IsNull("Title.Font")) FontMapper.Map(axis.Title.Font, domAxis.Title.Font); axis.Title.Orientation = domAxis.Title.Orientation.Value; axis.Title.Alignment = (HorizontalAlignment)domAxis.Title.Alignment; axis.Title.VerticalAlignment = (VerticalAlignment)domAxis.Title.VerticalAlignment; } axis.HasMajorGridlines = domAxis.HasMajorGridlines; axis.HasMinorGridlines = domAxis.HasMinorGridlines; if (!domAxis.IsNull("MajorGridlines") && !domAxis.MajorGridlines.IsNull("LineFormat")) LineFormatMapper.Map(axis.MajorGridlines.LineFormat, domAxis.MajorGridlines.LineFormat); if (!domAxis.IsNull("MinorGridlines") && !domAxis.MinorGridlines.IsNull("LineFormat")) LineFormatMapper.Map(axis.MinorGridlines.LineFormat, domAxis.MinorGridlines.LineFormat); if (!domAxis.IsNull("MaximumScale")) axis.MaximumScale = domAxis.MaximumScale; if (!domAxis.IsNull("MinimumScale")) axis.MinimumScale = domAxis.MinimumScale; if (!domAxis.IsNull("LineFormat")) LineFormatMapper.Map(axis.LineFormat, domAxis.LineFormat); }
void MapObject(LineFormat lineFormat, MigraDoc.DocumentObjectModel.Shapes.LineFormat domLineFormat) { if (domLineFormat.Color.IsEmpty) lineFormat.Color = XColor.Empty; else { #if noCMYK lineFormat.Color = XColor.FromArgb(domLineFormat.Color.Argb); #else lineFormat.Color = ColorHelper.ToXColor(domLineFormat.Color, domLineFormat.Document.UseCmykColor); #endif } switch (domLineFormat.DashStyle) { case MigraDoc.DocumentObjectModel.Shapes.DashStyle.Dash: lineFormat.DashStyle = XDashStyle.Dash; break; case MigraDoc.DocumentObjectModel.Shapes.DashStyle.DashDot: lineFormat.DashStyle = XDashStyle.DashDot; break; case MigraDoc.DocumentObjectModel.Shapes.DashStyle.DashDotDot: lineFormat.DashStyle = XDashStyle.DashDotDot; break; case MigraDoc.DocumentObjectModel.Shapes.DashStyle.Solid: lineFormat.DashStyle = XDashStyle.Solid; break; case MigraDoc.DocumentObjectModel.Shapes.DashStyle.SquareDot: lineFormat.DashStyle = XDashStyle.Dot; break; default: lineFormat.DashStyle = XDashStyle.Solid; break; } switch (domLineFormat.Style) { case MigraDoc.DocumentObjectModel.Shapes.LineStyle.Single: lineFormat.Style = LineStyle.Single; break; } lineFormat.Visible = domLineFormat.Visible; if (domLineFormat.IsNull("Visible")) lineFormat.Visible = true; lineFormat.Width = domLineFormat.Width.Point; }
void MapObject(Font font, MigraDoc.DocumentObjectModel.Font domFont) { font.Bold = domFont.Bold; if (domFont.Color.IsEmpty) font.Color = XColor.Empty; else { #if noCMYK font.Color = XColor.FromArgb((int)domFont.Color.Argb); #else font.Color = ColorHelper.ToXColor(domFont.Color, domFont.Document.UseCmykColor); #endif } font.Italic = domFont.Italic; if (!domFont.IsNull("Name")) font.Name = domFont.Name; if (!domFont.IsNull("Size")) font.Size = domFont.Size.Point; font.Subscript = domFont.Subscript; font.Superscript = domFont.Superscript; font.Underline = (Underline)domFont.Underline; }
private static void AddAttendanceData(List<AttendanceEventViewModel> membersList, Document document, List<int> month1Events, List<int> month2Events, int month1, int month2, MigraDoc.DocumentObjectModel.Tables.Table table, int totalColumns, Dictionary<int, string> comments) { var style = document.Styles["Normal"]; style.Font.Size = 8.0; TextMeasurement tm = new TextMeasurement(style.Font.Clone()); int familyId = 0; int personId = 0; //Sort the List membersList.Sort(delegate(AttendanceEventViewModel e1, AttendanceEventViewModel e2) { int familyIdComp = e1.FamilyId.CompareTo(e2.FamilyId); if (familyIdComp == 0) { int personIdComp = e1.PersonId.CompareTo(e2.PersonId); if (personIdComp == 0) { return e1.Date.CompareTo(e2.Date); } else { return personIdComp; } } return familyIdComp; }); if (membersList.Count == 0) { Row emptyRow = table.AddRow(); Cell emptyCell = emptyRow.Cells[0]; emptyCell.AddParagraph("No attendance has been captured over the last two months"); emptyCell.MergeRight = 4; } else { Row row = null; foreach (AttendanceEventViewModel attendanceEvent in membersList) { Cell cell; if (personId != attendanceEvent.PersonId) { row = table.AddRow(); cell = row.Cells[0]; if (familyId != attendanceEvent.FamilyId) { cell.AddParagraph(AdjustIfTooWideToFitIn(cell, attendanceEvent.Surname, tm)); } cell = row.Cells[1]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, attendanceEvent.Firstname, tm)); cell = row.Cells[totalColumns - 1]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, attendanceEvent.Role, tm)); var comment = (from c in comments where c.Key==attendanceEvent.PersonId select c.Value).FirstOrDefault(); if (!string.IsNullOrEmpty(comment)) { cell = row.Cells[totalColumns]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, comment, tm)); } } cell = row.Cells[GetEventColumn(attendanceEvent.Date, month1, month2, month1Events, month2Events)]; if (attendanceEvent.Attended) { cell.AddParagraph("x"); cell.Format.Alignment = ParagraphAlignment.Center; } else { cell.AddParagraph(" "); cell.Format.Alignment = ParagraphAlignment.Center; } familyId = attendanceEvent.FamilyId; personId = attendanceEvent.PersonId; } } }
internal static void Map(XValues xValues, MigraDoc.DocumentObjectModel.Shapes.Charts.XValues domXValues) { XValuesMapper mapper = new XValuesMapper(); mapper.MapObject(xValues, domXValues); }
private static void AddRoleHeader(MigraDoc.DocumentObjectModel.Tables.Table table, string headingType) { Font font = new Font("Arial", 8); MigraDoc.DocumentObjectModel.Tables.Row rowHeader = table.AddRow(); rowHeader.HeadingFormat = true; rowHeader.Format.Font.ApplyFont(font); rowHeader.Shading.Color = Colors.PaleGoldenrod; rowHeader.Format.Font.Bold = true; Cell cellHeader = rowHeader.Cells[0]; cellHeader.AddParagraph(headingType); cellHeader.MergeRight = 5; }
private static void AddHomegroupData(Document document, List<PersonViewModel> personList, MigraDoc.DocumentObjectModel.Tables.Table table) { var style = document.Styles["Normal"]; style.Font.Size = 8.0; TextMeasurement tm = new TextMeasurement(style.Font.Clone()); int familyId = 0; var roleName = string.Empty; foreach (PersonViewModel person in personList) { if (roleName != person.RoleName) { roleName = person.RoleName; AddRoleHeader(table, roleName); } Row row = table.AddRow(); Cell cell = row.Cells[0]; if (familyId != person.FamilyId) { cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.Surname, tm)); } cell = row.Cells[1]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.Firstname, tm)); cell = row.Cells[2]; if (familyId != person.FamilyId) { cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.HomePhone ?? string.Empty, tm)); } cell = row.Cells[3]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.WorkPhone ?? string.Empty, tm)); cell = row.Cells[4]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.CellPhone ?? string.Empty, tm)); cell = row.Cells[5]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.Email ?? string.Empty, tm)); familyId = person.FamilyId; } }
/// <summary> /// Erstellt das Dokumentenlayout als eine Micra Doc Tabelle /// </summary> /// <param name="hf">HeaderFooter</param> /// <returns>Tabelle</returns> internal virtual Table Write(MigraDoc.DocumentObjectModel.HeaderFooter hf) { var table = hf.AddTable(); if (this.Blocks.Count > 0) { table.Borders.Top.Width = "0.5"; var tableWidth = hf.Document.LastSection.PageSetup.PageWidth.Millimeter - hf.Document.LastSection.PageSetup.LeftMargin.Millimeter - hf.Document.LastSection.PageSetup.RightMargin.Millimeter; var columnWidth = tableWidth / this.Blocks.Count; foreach (var block in this.Blocks) { var myColumn = table.AddColumn(new Unit(columnWidth, UnitType.Millimeter)); } var row = table.AddRow(); var cellIndex = 0; foreach (var block in this.Blocks) { var par = row.Cells[cellIndex].AddParagraph(); par.Format.Font.Size = this.FontSize; row.Cells[cellIndex].VerticalAlignment = VerticalAlignment.Top; foreach (var line in block) { par.AddText(line); par.AddLineBreak(); } cellIndex++; } } else { table.AddColumn(); table.AddRow(); } if (!string.IsNullOrEmpty(this.LogoFilePath)) { var image = hf.AddImage(this.LogoFilePath); image.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through; image.RelativeHorizontal = RelativeHorizontal.Margin; image.RelativeVertical = RelativeVertical.Page; image.Top = hf.Document.LastSection.PageSetup.TopMargin - this.LogoHeight; image.Left = ShapePosition.Right; image.LockAspectRatio = true; image.Height = this.LogoHeight; } return table; }
public static RenderStyle CreateRenderStyle(HtmlItem it,ref MigraDoc.DocumentObjectModel.Shapes.Image imgt) { return new RenderStyleImage(it, ref imgt); }
internal static void Map(DataLabel dataLabel, MigraDoc.DocumentObjectModel.Shapes.Charts.DataLabel domDataLabel) { DataLabelMapper mapper = new DataLabelMapper(); mapper.MapObject(dataLabel, domDataLabel); }
private static int AddAttendanceHeaders(int month1, int month2, List<int> month1Events, List<int> month2Events, MigraDoc.DocumentObjectModel.Tables.Table table, string titleMessage) { //Headers // Create a font Font font = new Font("Arial", 8); int totalDays = month1Events.Count + month2Events.Count; table.Borders.Width = 0.25; table.AddColumn(Unit.FromCentimeter(3)); //Firstname table.AddColumn(Unit.FromMillimeter(28)); //Surname foreach (int day in month1Events) { table.AddColumn(Unit.FromMillimeter(56/totalDays)); //Weeks in month 1 } foreach (int day in month2Events) { table.AddColumn(Unit.FromMillimeter(56/totalDays)); //Weeks in month 2 } table.AddColumn(Unit.FromCentimeter(2)); //Member/Visitor table.AddColumn(Unit.FromCentimeter(5)); //Comments MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow(); row.HeadingFormat = true; row.Format.Font.ApplyFont(font); row.Format.Alignment = ParagraphAlignment.Center; row.Shading.Color = Colors.PaleGoldenrod; row.Format.Font.Bold = true; Cell cell = row.Cells[0]; cell.AddParagraph(titleMessage); cell.MergeRight = 1; cell = row.Cells[2]; cell.AddParagraph(Months[month1-1]); if (month1Events.Count > 1) { cell.MergeRight = month1Events.Count-1; } cell = row.Cells[2+month1Events.Count]; cell.AddParagraph(Months[month2-1]); if (month2Events.Count > 1) { cell.MergeRight = month2Events.Count - 1; } cell = row.Cells[2+month1Events.Count+month2Events.Count]; cell.AddParagraph(" "); //Add the 2nd row row = table.AddRow(); row.HeadingFormat = true; row.Format.Font.ApplyFont(font); row.Shading.Color = Colors.PaleGoldenrod; cell = row.Cells[0]; cell.AddParagraph("Surname"); cell = row.Cells[1]; cell.AddParagraph("Firstname"); int colCount = 2; foreach (int day in month1Events) { cell = row.Cells[colCount]; cell.AddParagraph(day.ToString()); cell.Format.Alignment = ParagraphAlignment.Center; colCount++; } foreach (int day in month2Events) { cell = row.Cells[colCount]; cell.AddParagraph(day.ToString()); cell.Format.Alignment = ParagraphAlignment.Center; colCount++; } cell = row.Cells[colCount++]; cell.AddParagraph("Role"); cell = row.Cells[colCount]; cell.AddParagraph("Comments"); return totalDays + 3; }
public static RenderStyle CreateRenderStyle(HtmlItem it, ref MigraDoc.DocumentObjectModel.Tables.Cell cl) { return new RenderStyleTd(it, ref cl); }
public RenderStyleList(HtmlItem it, ref MigraDoc.DocumentObjectModel.ListInfo lst) { Lst = lst; It = it; }
protected RenderStyle(HtmlItem it, ref MigraDoc.DocumentObjectModel.Tables.Cell cl) { }
public static RenderStyle CreateRenderStyle(HtmlItem it, ref MigraDoc.DocumentObjectModel.Tables.Table tt) { return new RenderStyleTable(it, ref tt); }
public static RenderStyle CreateRenderStyle(HtmlItem it, ref MigraDoc.DocumentObjectModel.ListInfo lst) { return new RenderStyleList(it, ref lst); }
protected RenderStyle(HtmlItem it, ref MigraDoc.DocumentObjectModel.Shapes.Image imgt) { }
public static RenderStyle CreateRenderStyle(HtmlItem it, ref MigraDoc.DocumentObjectModel.Paragraph prg) { return new RenderStyleParagraph(it, ref prg); }
private static void AddHeaders(MigraDoc.DocumentObjectModel.Tables.Table table, string optionalHeader) { //Headers // Create a font Font font = new Font("Arial", 8); table.Borders.Width = 0.25; table.AddColumn(Unit.FromCentimeter(3)); table.AddColumn(Unit.FromMillimeter(28)); table.AddColumn(Unit.FromMillimeter(28)); table.AddColumn(Unit.FromMillimeter(28)); table.AddColumn(Unit.FromMillimeter(28)); table.AddColumn(Unit.FromCentimeter(5)); if(optionalHeader != null) AddRoleHeader(table, optionalHeader); MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow(); row.HeadingFormat = true; row.Format.Font.ApplyFont(font); row.Format.Font.Bold = true; row.Shading.Color = Colors.PaleGoldenrod; Cell cell = row.Cells[0]; cell.AddParagraph("Surname"); cell = row.Cells[1]; cell.AddParagraph("Firstname"); cell = row.Cells[2]; cell.AddParagraph("Home"); cell = row.Cells[3]; cell.AddParagraph("Work"); cell = row.Cells[4]; cell.AddParagraph("Cell"); cell = row.Cells[5]; cell.AddParagraph("Email"); }
internal static void Map(Axis axis, MigraDoc.DocumentObjectModel.Shapes.Charts.Axis domAxis) { AxisMapper mapper = new AxisMapper(); mapper.MapObject(axis, domAxis); }
internal static void Map(FillFormat fillFormat, MigraDoc.DocumentObjectModel.Shapes.FillFormat domFillFormat) { FillFormatMapper mapper = new FillFormatMapper(); mapper.MapObject(fillFormat, domFillFormat); }
private ChartFrame MapObject(MigraDoc.DocumentObjectModel.Shapes.Charts.Chart domChart) { ChartFrame chartFrame = new ChartFrame(); chartFrame.Size = new XSize(domChart.Width.Point, domChart.Height.Point); chartFrame.Location = new XPoint(domChart.Left.Position.Point, domChart.Top.Position.Point); Chart chart = new Chart((ChartType)domChart.Type); if (!domChart.IsNull("XAxis")) AxisMapper.Map(chart.XAxis, domChart.XAxis); if (!domChart.IsNull("YAxis")) AxisMapper.Map(chart.YAxis, domChart.YAxis); PlotAreaMapper.Map(chart.PlotArea, domChart.PlotArea); SeriesCollectionMapper.Map(chart.SeriesCollection, domChart.SeriesCollection); LegendMapper.Map(chart, domChart); chart.DisplayBlanksAs = (BlankType)domChart.DisplayBlanksAs; chart.HasDataLabel = domChart.HasDataLabel; if (!domChart.IsNull("DataLabel")) DataLabelMapper.Map(chart.DataLabel, domChart.DataLabel); if (!domChart.IsNull("Style")) FontMapper.Map(chart.Font, domChart.Document, domChart.Style); if (!domChart.IsNull("Format.Font")) FontMapper.Map(chart.Font, domChart.Format.Font); if (!domChart.IsNull("XValues")) XValuesMapper.Map(chart.XValues, domChart.XValues); chartFrame.Add(chart); return chartFrame; }