/// <summary> /// Applies all non-null properties of a font to this font if the given font's property is different from the given refFont's property. /// </summary> internal void ApplyFont(Font font, Font refFont) { if (font == null) throw new ArgumentNullException("font"); if ((!font._name.IsNull && font._name.Value != "") && (refFont == null || font.Name != refFont.Name)) Name = font.Name; if (!font._size.IsNull && (refFont == null || font.Size != refFont.Size)) Size = font.Size; if (!font._bold.IsNull && (refFont == null || font.Bold != refFont.Bold)) Bold = font.Bold; if (!font._italic.IsNull && (refFont == null || font.Italic != refFont.Italic)) Italic = font.Italic; if (!font._subscript.IsNull && (refFont == null || font.Subscript != refFont.Subscript)) Subscript = font.Subscript; else if (!font._superscript.IsNull && (refFont == null || font.Superscript != refFont.Superscript)) Superscript = font.Superscript; if (!font._underline.IsNull && (refFont == null || font.Underline != refFont.Underline)) Underline = font.Underline; if (!font._color.IsNull && (refFont == null || font.Color.Argb != refFont.Color.Argb)) Color = font.Color; }
public static MigraDoc.DocumentObjectModel.Font CreateFont(float fsize) { MigraDoc.DocumentObjectModel.Font font=new MigraDoc.DocumentObjectModel.Font(); font.Name="Arial"; font.Size=Unit.FromPoint(fsize); return font; }
///<summary></summary> public static void DrawString(TextFrame frameContainer, string text, MigraDoc.DocumentObjectModel.Font font, float xPos, float yPos) { TextFrame frame = new TextFrame(); Paragraph par = frame.AddParagraph(); par.Format.Font = font.Clone(); par.AddText(text); frame.RelativeVertical = RelativeVertical.Page; frame.RelativeHorizontal = RelativeHorizontal.Page; frame.MarginLeft = Unit.FromInch(xPos / 100); frame.MarginTop = Unit.FromInch(yPos / 100); frame.Top = TopPosition.Parse("0 in"); frame.Left = LeftPosition.Parse("0 in"); frame.Width = frameContainer.Width; FontStyle fontstyle = FontStyle.Regular; if (font.Bold) { fontstyle = FontStyle.Bold; } System.Drawing.Font fontSystem = new System.Drawing.Font(font.Name, (float)font.Size.Point, fontstyle); float fontH = fontSystem.Height; Unit bottom = Unit.FromInch((yPos + fontH) / 100); 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); }
///<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 static MigraDoc.DocumentObjectModel.Font CreateFont(float fsize) { MigraDoc.DocumentObjectModel.Font font = new MigraDoc.DocumentObjectModel.Font(); font.Name = "Arial"; font.Size = Unit.FromPoint(fsize); return(font); }
private MigraDoc.DocumentObjectModel.Document CreatePrintDocument(PrintDocument pd) { string text; MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document(); doc.DefaultPageSetup.PageWidth = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Width / 100); doc.DefaultPageSetup.PageHeight = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Height / 100); doc.DefaultPageSetup.TopMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Top / 100); doc.DefaultPageSetup.LeftMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Left / 100); doc.DefaultPageSetup.RightMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Right / 100); doc.DefaultPageSetup.BottomMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Bottom / 100); MigraDoc.DocumentObjectModel.Section section = doc.AddSection(); section.PageSetup.StartingNumber = 1; MigraDoc.DocumentObjectModel.Font headingFont = MigraDocHelper.CreateFont(13, true); MigraDoc.DocumentObjectModel.Font bodyFontx = MigraDocHelper.CreateFont(9, false); MigraDoc.DocumentObjectModel.Font nameFontx = MigraDocHelper.CreateFont(9, true); MigraDoc.DocumentObjectModel.Font totalFontx = MigraDocHelper.CreateFont(9, true); Paragraph pageNumParag = new Paragraph(); pageNumParag.AddText(Lan.g(this, "Page") + " "); pageNumParag.AddPageField(); pageNumParag.AddText(" " + Lan.g(this, "of") + " "); pageNumParag.AddNumPagesField(); section.Footers.Primary.Add(pageNumParag); Paragraph par = section.AddParagraph(); ParagraphFormat parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Center; parformat.Font = MigraDocHelper.CreateFont(14, true); par.Format = parformat; //Render the reconcile grid. par = section.AddParagraph(); par.Format.Alignment = ParagraphAlignment.Center; par.AddFormattedText(Lan.g(this, "RECONCILE"), totalFontx); par.AddLineBreak(); text = Accounts.GetAccount(ReconcileCur.AccountNum).Description.ToUpper(); par.AddFormattedText(text, totalFontx); par.AddLineBreak(); text = PrefC.GetString(PrefName.PracticeTitle); par.AddText(text); par.AddLineBreak(); text = PrefC.GetString(PrefName.PracticePhone); if (text.Length == 10 && Application.CurrentCulture.Name == "en-US") { text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6); } par.AddText(text); par.AddLineBreak(); par.AddText(MiscData.GetNowDateTime().ToShortDateString()); par.AddLineBreak(); par.AddText(Lan.g(this, "Reconcile Date") + ": " + PIn.Date(textDate.Text).ToShortDateString()); par.AddLineBreak(); par.AddText(labelStart.Text + ": " + PIn.Double(textStart.Text).ToString("n")); par.AddLineBreak(); par.AddText(labelEnd.Text + ": " + PIn.Double(textEnd.Text).ToString("n")); MigraDocHelper.InsertSpacer(section, 10); MigraDocHelper.DrawGrid(section, gridMain); return(doc); }
///<summary>Draws the text and splits words that are too long for the column into multiple lines.</summary> private static void DrawTextWithWordSplits(Paragraph par, MigraDoc.DocumentObjectModel.Font fontBody, int colWidth, string cellText, XGraphics gx, XFont xFont) { string line = ""; string word = ""; //cellText=cellText.Replace("\r\n","\n").Replace("\n","\r\n");//Make sure all the line breaks are uniform for (int c = 0; c < cellText.Length; c++) { char letter = cellText[c]; word += letter; if (c == cellText.Length - 1 || (!char.IsWhiteSpace(letter) && char.IsWhiteSpace(cellText[c + 1]))) //We have reached the end of the word. { if ((line + word).All(x => char.IsWhiteSpace(x))) //Sometimes gx.MeasureString will throw an exception if the text is all whitespace. { par.AddFormattedText(line + word, fontBody); line = ""; word = ""; continue; } if (DoesTextFit(line + word, colWidth, gx, xFont)) { line += word; if (IsLastWord(c, cellText)) { par.AddFormattedText(line, fontBody); } } else //The line plus the word do not fit. { if (line == "") //The word by itself does not fit. { DrawWordChunkByChunk(word, colWidth, par, fontBody, gx, xFont); } else { par.AddFormattedText(line, fontBody); if (DoesTextFit(word, colWidth, gx, xFont)) { if (IsLastWord(c, cellText)) { par.AddFormattedText(word, fontBody); } line = word; } else //The word by itself does not fit. { DrawWordChunkByChunk(word, colWidth, par, fontBody, gx, xFont); line = ""; } } } word = ""; } } }
internal static XFontStyle GetXStyle(Font font) { XFontStyle style = XFontStyle.Regular; if (font.Bold) style = font.Italic ? XFontStyle.BoldItalic : XFontStyle.Bold; else if (font.Italic) style = XFontStyle.Italic; return style; }
public static MigraDoc.DocumentObjectModel.Font CreateFont(float fsize, bool isBold) { MigraDoc.DocumentObjectModel.Font font = new MigraDoc.DocumentObjectModel.Font(); //if(fontFamily==FontFamily.GenericSansSerif){ font.Name = "Arial"; //} //if(fontFamily==FontFamily.GenericSerif){ // font.Name="Times"; //} font.Size = Unit.FromPoint(fsize); font.Bold = isBold; return(font); }
public static MigraDoc.DocumentObjectModel.Font CreateFont(float fsize,bool isBold) { MigraDoc.DocumentObjectModel.Font font=new MigraDoc.DocumentObjectModel.Font(); //if(fontFamily==FontFamily.GenericSansSerif){ font.Name="Arial"; //} //if(fontFamily==FontFamily.GenericSerif){ // font.Name="Times"; //} font.Size=Unit.FromPoint(fsize); font.Bold=isBold; return font; }
public static MigraDoc.DocumentObjectModel.Font CreateFont(float fsize, bool isBold, System.Drawing.Color color) { MigraDoc.DocumentObjectModel.Color colorx = ConvertColor(color); MigraDoc.DocumentObjectModel.Font font = new MigraDoc.DocumentObjectModel.Font(); //if(fontFamily.==FontFamily.GenericSansSerif) { font.Name = "Arial"; //} //if(fontFamily==FontFamily.GenericSerif) { // font.Name="Times"; //} font.Size = Unit.FromPoint(fsize); font.Bold = isBold; font.Color = colorx; return(font); }
/// <summary> /// Converts a DOM Font to an XFont. /// </summary> internal static XFont FontToXFont(Font font, PdfFontEncoding encoding) { XPdfFontOptions options = new XPdfFontOptions(encoding); XFontStyle style = GetXStyle(font); #if DEBUG if (StringComparer.OrdinalIgnoreCase.Compare(font.Name, "Segoe UI Semilight") == 0 && (style & XFontStyle.BoldItalic) == XFontStyle.Italic) font.GetType(); #endif XFont xFont = new XFont(font.Name, font.Size, style, options); #if DEBUG CreateFontCounter++; #endif return xFont; }
private void PrintReceipt(string receiptStr) { string[] receiptLines = receiptStr.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document(); doc.DefaultPageSetup.PageWidth = Unit.FromInch(3.0); doc.DefaultPageSetup.PageHeight = Unit.FromInch(0.181 * receiptLines.Length + 0.56); //enough to print receipt text plus 9/16 inch (0.56) extra space at bottom. doc.DefaultPageSetup.TopMargin = Unit.FromInch(0.25); doc.DefaultPageSetup.LeftMargin = Unit.FromInch(0.25); doc.DefaultPageSetup.RightMargin = Unit.FromInch(0.25); MigraDoc.DocumentObjectModel.Font bodyFontx = MigraDocHelper.CreateFont(8, false); bodyFontx.Name = FontFamily.GenericMonospace.Name; MigraDoc.DocumentObjectModel.Section section = doc.AddSection(); Paragraph par = section.AddParagraph(); ParagraphFormat parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Left; parformat.Font = bodyFontx; par.Format = parformat; par.AddFormattedText(receiptStr, bodyFontx); MigraDoc.Rendering.Printing.MigraDocPrintDocument printdoc = new MigraDoc.Rendering.Printing.MigraDocPrintDocument(); MigraDoc.Rendering.DocumentRenderer renderer = new MigraDoc.Rendering.DocumentRenderer(doc); renderer.PrepareDocument(); printdoc.Renderer = renderer; #if DEBUG FormRpPrintPreview pView = new FormRpPrintPreview(printdoc); pView.ShowDialog(); #else try { ODprintout printout = PrinterL.CreateODprintout( printSit: PrintSituation.Receipt, auditPatNum: _patCur.PatNum, auditDescription: Lans.g(this, "PayConnect receipt printed") ); if (PrinterL.TrySetPrinter(printout)) { printdoc.PrinterSettings = printout.PrintDoc.PrinterSettings; printdoc.Print(); } } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Printer not available.") + "\r\n" + Lan.g(this, "Original error") + ": " + ex.Message); } #endif }
private MigraDoc.DocumentObjectModel.Document CreatePrintDocument() { string text; MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document(); doc.DefaultPageSetup.PageWidth = Unit.FromInch(8.5); doc.DefaultPageSetup.PageHeight = Unit.FromInch(11); doc.DefaultPageSetup.TopMargin = Unit.FromInch(.5); doc.DefaultPageSetup.LeftMargin = Unit.FromInch(.5); doc.DefaultPageSetup.RightMargin = Unit.FromInch(.5); MigraDoc.DocumentObjectModel.Section section = doc.AddSection(); MigraDoc.DocumentObjectModel.Font headingFont = MigraDocHelper.CreateFont(13, true); MigraDoc.DocumentObjectModel.Font bodyFontx = MigraDocHelper.CreateFont(9, false); MigraDoc.DocumentObjectModel.Font nameFontx = MigraDocHelper.CreateFont(9, true); MigraDoc.DocumentObjectModel.Font totalFontx = MigraDocHelper.CreateFont(9, true); Paragraph par = section.AddParagraph(); ParagraphFormat parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Center; parformat.Font = MigraDocHelper.CreateFont(14, true); par.Format = parformat; //Render the reconcile grid. par = section.AddParagraph(); par.Format.Alignment = ParagraphAlignment.Center; par.AddFormattedText(Lan.g(this, "RECONCILE"), totalFontx); par.AddLineBreak(); text = Accounts.GetAccount(ReconcileCur.AccountNum).Description.ToUpper(); par.AddFormattedText(text, totalFontx); par.AddLineBreak(); text = PrefC.GetString(PrefName.PracticeTitle); par.AddText(text); par.AddLineBreak(); text = PrefC.GetString(PrefName.PracticePhone); if (text.Length == 10 && Application.CurrentCulture.Name == "en-US") { text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6); } par.AddText(text); MigraDocHelper.InsertSpacer(section, 10); MigraDocHelper.DrawGrid(section, gridMain); return(doc); }
private static void DrawRecipe(RecipeEntry recipe, ref Section section) { ///<example> /// [Recipe Name] /// [Recipe Source] /// [Recipe Description] /// [# Recipe Ingredients] /// [Recipe Preparation Instructions] /// [Recipe Cooking Instructions] /// </example> Paragraph headerText = section.AddParagraph(); Paragraph DescParagraph = section.AddParagraph(); Paragraph ingredientList = section.AddParagraph(); Paragraph PrepInstr = section.AddParagraph(); Paragraph CookInstr = section.AddParagraph(); Font header = new Font("Times New Roman Bold", 20); Font body = new Font("Times New Roman", 14); headerText.Format = HeaderFormatter(); headerText.AddFormattedText(recipe.Name, header); headerText.AddLineBreak(); headerText.AddFormattedText("(" + recipe.Source + ")", new Font("Times New Roman", 16)); DescParagraph.Format = BodyFormatter(); DescParagraph.AddFormattedText(recipe.Description, body); ingredientList.Format = IngredientFormatter(); int count = 1; foreach (IngredientEntry i in recipe.Ingredients) { string entry = count.ToString() + ") " + i.ToString(); ingredientList.AddFormattedText(entry, body); ingredientList.AddLineBreak(); count++; } PrepInstr.Format = BodyFormatter(); PrepInstr.AddFormattedText(recipe.PrepInstructions, body); CookInstr.Format = BodyFormatter(); CookInstr.AddFormattedText(recipe.CookInstructions, body); }
private void PrintReceipt(string receiptStr) { string[] receiptLines = receiptStr.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document(); doc.DefaultPageSetup.PageWidth = Unit.FromInch(3.0); doc.DefaultPageSetup.PageHeight = Unit.FromInch(0.181 * receiptLines.Length + 0.56); //enough to print receipt text plus 9/16 inch (0.56) extra space at bottom. doc.DefaultPageSetup.TopMargin = Unit.FromInch(0.25); doc.DefaultPageSetup.LeftMargin = Unit.FromInch(0.25); doc.DefaultPageSetup.RightMargin = Unit.FromInch(0.25); MigraDoc.DocumentObjectModel.Font bodyFontx = MigraDocHelper.CreateFont(8, false); bodyFontx.Name = FontFamily.GenericMonospace.Name; MigraDoc.DocumentObjectModel.Section section = doc.AddSection(); Paragraph par = section.AddParagraph(); ParagraphFormat parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Left; parformat.Font = bodyFontx; par.Format = parformat; par.AddFormattedText(receiptStr, bodyFontx); MigraDoc.Rendering.Printing.MigraDocPrintDocument printdoc = new MigraDoc.Rendering.Printing.MigraDocPrintDocument(); MigraDoc.Rendering.DocumentRenderer renderer = new MigraDoc.Rendering.DocumentRenderer(doc); renderer.PrepareDocument(); printdoc.Renderer = renderer; //we might want to surround some of this with a try-catch #if DEBUG FormRpPrintPreview pView = new FormRpPrintPreview(); pView.printPreviewControl2.Document = printdoc; pView.ShowDialog(); #else if (PrinterL.SetPrinter(pd2, PrintSituation.Receipt, PatCur.PatNum, "PayConnect receipt printed")) { printdoc.PrinterSettings = pd2.PrinterSettings; printdoc.Print(); } #endif }
/// <summary> /// Converts an DOM Font to an XFont. /// </summary> internal static XFont FontToXFont(Font font, XPrivateFontCollection pfc, PdfFontEncoding encoding, PdfFontEmbedding fontEmbedding) { XFont xFont = null; #if GDI____ // done in PDFsharp #if CACHE_FONTS string signature = BuildSignature(font, unicode, fontEmbedding); xFont = fontCache[signature] as XFont; if (xFont == null) { XPdfFontOptions options = null; options = new XPdfFontOptions(fontEmbedding, unicode); XFontStyle style = GetXStyle(font); xFont = new XFont(font.Name, font.Size, style, options); fontCache[signature] = xFont; } #else XPdfFontOptions options = null; options = new XPdfFontOptions(encoding, fontEmbedding); XFontStyle style = GetXStyle(font); if (pfc != null && pfc.PrivateFontCollection != null) { // Is it a private font? try { foreach (System.Drawing.FontFamily ff in pfc.PrivateFontCollection.Families) { if (String.Compare(ff.Name, font.Name, true) == 0) { xFont = new XFont(ff, font.Size, style, options, pfc); break; } } } catch { #if DEBUG pfc.GetType(); #endif } } #endif #endif #if WPF___ XPdfFontOptions options = null; options = new XPdfFontOptions(encoding, fontEmbedding); XFontStyle style = GetXStyle(font); //if (pfc != null && // pfc.PrivateFontCollection != null) //{ // // Is it a private font? // try // { // foreach (System.Drawing.FontFamily ff in pfc.PrivateFontCollection.Families) // { // if (String.Compare(ff.Name, font.Name, true) == 0) // { // xFont = new XFont(ff, font.Size, style, options, pfc); // break; // } // } // } // catch // { // } //} #endif // #PFC XPdfFontOptions options = null; options = new XPdfFontOptions(encoding, fontEmbedding); XFontStyle style = GetXStyle(font); if (xFont == null) xFont = new XFont(font.Name, font.Size, style, options); #if DEBUG CreateFontCounter++; #endif return xFont; }
private Document DocumentoEpicrisisGabinete() { Document document = new Document(); if (TxtNumExpediente.Text.Trim() != "") { if (lstConsultasPaciente.Items.Count > 0) { if (oCEmpresa.LeeDatosEmpresa() == true && oCPacientes.LeeDatosPaciente(TxtNumExpediente.Text.Trim()) == true) { Section section = document.AddSection(); #region Encabezado (Fecha, Título, Datos Personales y Detalle Opcional) Table tableHeader = document.LastSection.AddTable(); tableHeader.Borders.Visible = true; tableHeader.Borders.Width = 0; Column columnHeader = tableHeader.AddColumn("8cm"); columnHeader.Format.Alignment = ParagraphAlignment.Right; columnHeader = tableHeader.AddColumn("8cm"); columnHeader.Format.Alignment = ParagraphAlignment.Center; Row rowHeader = tableHeader.AddRow(); tableHeader.AddRow(); tableHeader.AddRow(); tableHeader.AddRow(); #region Fecha Paragraph oParagraphDate = rowHeader.Cells[0].AddParagraph(DateTime.Now.Date.ToLongDateString()); oParagraphDate.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 10); rowHeader.Cells[0].MergeRight = 1; #endregion #region Título rowHeader = tableHeader.AddRow(); rowHeader.Cells[0].MergeRight = 1; Paragraph oParagraphTitle = rowHeader.Cells[0].AddParagraph("Epicrisis"); oParagraphTitle.Format.Alignment = ParagraphAlignment.Center; oParagraphTitle.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 26); #endregion tableHeader.AddRow(); tableHeader.AddRow(); tableHeader.AddRow(); #region Datos Personales (Nombre y Cédula) rowHeader = tableHeader.AddRow(); Paragraph oParagraphNombre = rowHeader.Cells[0].AddParagraph(); FormattedText oFormattedTextNombre = oParagraphNombre.AddFormattedText("Nombre: "); oFormattedTextNombre.Bold = true; oFormattedTextNombre.Font.Name = "Segoe UI"; oFormattedTextNombre.Font.Size = 11; oParagraphNombre.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 9); oParagraphNombre.AddText(oCPacientes.Nombre.Trim() + " " + oCPacientes.Apellidos.Trim()); oParagraphNombre.Format.Alignment = ParagraphAlignment.Left; Paragraph oParagraphCedula = rowHeader.Cells[1].AddParagraph(); FormattedText oFormattedTextCedula = oParagraphCedula.AddFormattedText("Cédula: "); oFormattedTextCedula.Bold = true; oFormattedTextCedula.Font.Name = "Segoe UI"; oFormattedTextCedula.Font.Size = 11; oParagraphCedula.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 9); oParagraphCedula.AddText(oCPacientes.Cedula); oParagraphCedula.Format.Alignment = ParagraphAlignment.Left; #endregion tableHeader.AddRow(); tableHeader.AddRow(); #region Detalle Opcional rowHeader = tableHeader.AddRow(); rowHeader.Cells[0].MergeRight = 1; Paragraph oParagraphDetalleOpcional = rowHeader.Cells[0].AddParagraph(); FormattedText oFormattedDetalleOpcional = oParagraphDetalleOpcional.AddFormattedText(textBox1.Text.Trim()); oFormattedDetalleOpcional.Font.Name = "Arial"; oFormattedDetalleOpcional.Font.Size = 10; oParagraphDetalleOpcional.Format.Alignment = ParagraphAlignment.Left; #endregion tableHeader.AddRow(); tableHeader.AddRow(); tableHeader.AddRow(); #endregion #region Tabla de Datos de Consultas if (rdNoIncluirDetallesConsultas.Checked == false) { Table tableData = document.LastSection.AddTable(); tableData.Borders.Visible = true; tableData.Borders.Width = 0.74; tableData.Borders.Color = new MigraDoc.DocumentObjectModel.Color(192, 80, 77); Column columnData = tableData.AddColumn("2.8cm"); columnData.Format.Alignment = ParagraphAlignment.Center; columnData = tableData.AddColumn("3.5cm"); columnData.Format.Alignment = ParagraphAlignment.Center; columnData = tableData.AddColumn("3.5cm"); columnData.Format.Alignment = ParagraphAlignment.Center; columnData = tableData.AddColumn("3.7cm"); columnData.Format.Alignment = ParagraphAlignment.Center; columnData = tableData.AddColumn("3.7cm"); columnData.Format.Alignment = ParagraphAlignment.Center; Row rowData = tableData.AddRow(); rowData.Borders.Top.Clear(); rowData.Borders.Left.Clear(); rowData.Borders.Right.Clear(); rowData.Borders.Bottom.Width = Unit.FromMillimeter(1); Paragraph oParagraphDataHeader = new Paragraph(); //oParagraphDataHeader = rowData.Cells[0].AddParagraph("Fecha de Consulta"); //oParagraphDataHeader.Format.Font = new MigraDoc.DocumentObjectModel.Font("Times New Roman", 13); //oParagraphDataHeader.Format.Font.Bold = true; oParagraphDataHeader = rowData.Cells[0].AddParagraph("Detalle de la Consulta"); oParagraphDataHeader.Format.Font = new MigraDoc.DocumentObjectModel.Font("Times New Roman", 13); oParagraphDataHeader.Format.Font.Bold = true; oParagraphDataHeader = rowData.Cells[1].AddParagraph("Diagnóstico"); oParagraphDataHeader.Format.Font = new MigraDoc.DocumentObjectModel.Font("Times New Roman", 13); oParagraphDataHeader.Format.Font.Bold = true; oParagraphDataHeader = rowData.Cells[2].AddParagraph("Tratamiento"); oParagraphDataHeader.Format.Font = new MigraDoc.DocumentObjectModel.Font("Times New Roman", 13); oParagraphDataHeader.Format.Font.Bold = true; oParagraphDataHeader = rowData.Cells[3].AddParagraph("Exámenes Prescritos"); oParagraphDataHeader.Format.Font = new MigraDoc.DocumentObjectModel.Font("Times New Roman", 13); oParagraphDataHeader.Format.Font.Bold = true; oParagraphDataHeader = rowData.Cells[4].AddParagraph("Gabinete"); oParagraphDataHeader.Format.Font = new MigraDoc.DocumentObjectModel.Font("Times New Roman", 13); oParagraphDataHeader.Format.Font.Bold = true; Paragraph oParagraphData = new Paragraph(); ArrayList oArregloDetallesConsultaEpicrisis = new ArrayList(); int alternateColor = 0; bool continuar = false; foreach (ListViewItem oItem in lstConsultasPaciente.Items) { if (rdTodas.Checked == true) { continuar = true; } else if (rdSeleccionar.Checked == true) { if (oItem.Checked == true) { continuar = true; } else { continuar = false; } } if (continuar == true) { oArregloDetallesConsultaEpicrisis = oCConsultas.DetallesConsultaEpicrisis(oItem.SubItems[1].Text.Trim()); rowData = tableData.AddRow(); //if (alternateColor == 0) // rowData.Shading.Color = new MigraDoc.DocumentObjectModel.Color(239, 211, 210); //else rowData.Shading.Color = Colors.White; string consultaHeader = Convert.ToDateTime(oItem.SubItems[3].Text).ToShortDateString(); oParagraphData = rowData.Cells[0].AddParagraph(consultaHeader); oParagraphData.Format.Font = new MigraDoc.DocumentObjectModel.Font("Times New Roman", 12); oParagraphData.Format.Font.Bold = true; oParagraphData.Format.Font.Color = new MigraDoc.DocumentObjectModel.Color(36, 64, 97); oParagraphData.Format.Alignment = ParagraphAlignment.Left; rowData.Cells[0].Shading.Color = Colors.White; oParagraphData = rowData.Cells[0].AddParagraph(""); oParagraphData = rowData.Cells[0].AddParagraph(oArregloDetallesConsultaEpicrisis[0].ToString().Trim()); oParagraphData.Format.Font.Bold = false; oParagraphData.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 8); oParagraphData.Format.Alignment = ParagraphAlignment.Left; string oTratamiento = oArregloDetallesConsultaEpicrisis[1].ToString().Trim(); int c = 0; while (oTratamiento.Contains("{") || oTratamiento.Contains("}")) { if (c == 0) { oTratamiento = Metodos_Globales.CortaSeccionDeTexto(oTratamiento, "{", "}", ""); } else { oTratamiento = Metodos_Globales.CortaSeccionDeTexto(oTratamiento, "{", "}", ", "); } c++; } oParagraphData = rowData.Cells[1].AddParagraph(oTratamiento.Trim()); oParagraphData.Format.Font.Bold = false; oParagraphData.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 8); oParagraphData.Format.Alignment = ParagraphAlignment.Left; oParagraphData = rowData.Cells[2].AddParagraph(oArregloDetallesConsultaEpicrisis[2].ToString().Trim()); oParagraphData.Format.Font.Bold = false; oParagraphData.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 8); oParagraphData.Format.Alignment = ParagraphAlignment.Left; string detalleExamen = ""; DataSet ds = oCExamenesConsulta.ConsultarSinParametros(oItem.SubItems[1].Text.Trim()); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { if (Convert.ToBoolean(dr[3]) == true) { detalleExamen = "• " + oCExamenesConsulta.NombreExamen(dr[0].ToString().Trim()) + "(" + dr[5].ToString().Trim() + ")."; } else { detalleExamen = "• " + oCExamenesConsulta.NombreExamen(dr[0].ToString().Trim()) + "(\"Pendiente de resultados\")."; } oParagraphData = rowData.Cells[3].AddParagraph(detalleExamen.Trim()); oParagraphData.Format.Font.Bold = false; oParagraphData.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 8); oParagraphData.Format.Alignment = ParagraphAlignment.Left; oParagraphData.AddLineBreak(); } } ds.Dispose(); } string gabinete = ""; DataSet ds1 = oCGabineteConsulta.ConsultarSinParametros(oItem.SubItems[1].Text.Trim()); if (ds1 != null) { if (ds1.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds1.Tables[0].Rows) { if (Convert.ToBoolean(dr[3]) == true) { gabinete = "• " + oCGabineteConsulta.NombreGabinete(dr[0].ToString().Trim()) + "(" + dr[5].ToString().Trim() + ")."; } else { gabinete = "• " + oCGabineteConsulta.NombreGabinete(dr[0].ToString().Trim()) + "(\"Pendiente de resultados\")."; } oParagraphData = rowData.Cells[4].AddParagraph(gabinete.Trim()); oParagraphData.Format.Font.Bold = false; oParagraphData.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 8); oParagraphData.Format.Alignment = ParagraphAlignment.Left; oParagraphData.AddLineBreak(); } } ds1.Dispose(); } if (alternateColor == 0) { alternateColor = 1; } else { alternateColor = 0; } rowData.Borders.Top.Clear(); rowData.Borders.Left.Clear(); //rowData.Borders.Bottom.Clear(); } } } #endregion #region Agrega Footer Section section2 = document.LastSection; section2.PageSetup.OddAndEvenPagesHeaderFooter = false; HeaderFooter footer = new HeaderFooter(); Paragraph paraFooter = new Paragraph(); MigraDoc.DocumentObjectModel.Font ofont = new MigraDoc.DocumentObjectModel.Font("Arial", 8); paraFooter.AddLineBreak(); ofont.Color = Colors.Black; string nombreEmp = oCEmpleados.ObtieneNombreEmpleado(Program.oIdUsuario); string codEmpleado = oCEmpleados.ObtieneCodigoColegiado(Program.oIdUsuario); string footerText = "________________________________" + Environment.NewLine + nombreEmp.Trim() + Environment.NewLine + "Cód. " + codEmpleado.Trim(); paraFooter.AddFormattedText(footerText, ofont); paraFooter.Format.Alignment = ParagraphAlignment.Right; footer.Add(paraFooter); //section2.Footers.Primary = footer; document.LastSection.Footers.Primary = footer; #endregion #region Crea el documento pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); #endregion } } } oDocument = document; return(document); }
private static void AddHeaders(Table table, string optionalHeader, bool includeSite) { //Headers // Create a font var font = new Font("Arial", 8); table.Borders.Width = 0.25; if (includeSite) { table.AddColumn(Unit.FromMillimeter(25)); table.AddColumn(Unit.FromMillimeter(25)); table.AddColumn(Unit.FromMillimeter(27)); table.AddColumn(Unit.FromMillimeter(27)); table.AddColumn(Unit.FromMillimeter(27)); table.AddColumn(Unit.FromCentimeter(4)); table.AddColumn(Unit.FromMillimeter(21)); } else { 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, includeSite); var row = table.AddRow(); row.HeadingFormat = true; row.Format.Font.ApplyFont(font); row.Format.Font.Bold = true; row.Shading.Color = Colors.PaleGoldenrod; var 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"); if (!includeSite) return; cell = row.Cells[6]; cell.AddParagraph("Site"); }
///<summary>Supply pd so that we know the paper size and margins.</summary> public static void CreateDocument(FormRpStatement sender, MigraDoc.DocumentObjectModel.Document doc, PrintDocument pd, Family fam, Patient pat, DataSet dataSet, Statement Stmt) { //doc= new MigraDoc.DocumentObjectModel.Document();//don't do this or the reference to the original doc will be lost. doc.DefaultPageSetup.PageWidth = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Width / 100); doc.DefaultPageSetup.PageHeight = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Height / 100); doc.DefaultPageSetup.TopMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Top / 100); doc.DefaultPageSetup.LeftMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Left / 100); doc.DefaultPageSetup.RightMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Right / 100); doc.DefaultPageSetup.BottomMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Bottom / 100); MigraDoc.DocumentObjectModel.Section section = doc.AddSection(); //so that Swiss will have different footer for each patient. string text; MigraDoc.DocumentObjectModel.Font font; //GetPatGuar(PatNums[famIndex][0]); //Family fam=Patients.GetFamily(Stmt.PatNum); Patient PatGuar = fam.ListPats[0]; //.Copy(); //Patient pat=fam.GetPatient(Stmt.PatNum); DataTable tableMisc = dataSet.Tables["misc"]; //HEADING------------------------------------------------------------------------------ #region Heading Paragraph par = section.AddParagraph(); ParagraphFormat parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Center; par.Format = parformat; font = MigraDocHelper.CreateFont(14, true); text = "This statement was generated from the plug-in"; par.AddFormattedText(text, font); text = DateTime.Today.ToShortDateString(); font = MigraDocHelper.CreateFont(10); par.AddLineBreak(); par.AddFormattedText(text, font); text = Lan.g("FormRpStatement", "Account Number") + " "; if (PrefC.GetBool(PrefName.StatementAccountsUseChartNumber)) { text += PatGuar.ChartNumber; } else { text += PatGuar.PatNum; } par.AddLineBreak(); par.AddFormattedText(text, font); TextFrame frame; #endregion //Practice Address---------------------------------------------------------------------- #region Practice Address if (PrefC.GetBool(PrefName.StatementShowReturnAddress)) { font = MigraDocHelper.CreateFont(10); frame = section.AddTextFrame(); frame.RelativeVertical = RelativeVertical.Page; frame.RelativeHorizontal = RelativeHorizontal.Page; frame.MarginLeft = Unit.Zero; frame.MarginTop = Unit.Zero; frame.Top = TopPosition.Parse("0.5 in"); frame.Left = LeftPosition.Parse("0.3 in"); frame.Width = Unit.FromInch(3); if (!PrefC.GetBool(PrefName.EasyNoClinics) && Clinics.List.Length > 0 && //if using clinics Clinics.GetClinic(PatGuar.ClinicNum) != null) //and this patient assigned to a clinic { Clinic clinic = Clinics.GetClinic(PatGuar.ClinicNum); par = frame.AddParagraph(); par.Format.Font = font; par.AddText(clinic.Description); par.AddLineBreak(); par.AddText(clinic.Address); par.AddLineBreak(); if (clinic.Address2 != "") { par.AddText(clinic.Address2); par.AddLineBreak(); } if (CultureInfo.CurrentCulture.Name.EndsWith("CH")) //CH is for switzerland. eg de-CH { par.AddText(clinic.Zip + " " + clinic.City); } else { par.AddText(clinic.City + ", " + clinic.State + " " + clinic.Zip); } par.AddLineBreak(); text = clinic.Phone; if (text.Length == 10) { text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6); } par.AddText(text); par.AddLineBreak(); } else { par = frame.AddParagraph(); par.Format.Font = font; par.AddText(PrefC.GetString(PrefName.PracticeTitle)); par.AddLineBreak(); if (CultureInfo.CurrentCulture.Name == "en-AU") //English (Australia) { Provider defaultProv = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)); par.AddText("ABN: " + defaultProv.NationalProvID); par.AddLineBreak(); } par.AddText(PrefC.GetString(PrefName.PracticeAddress)); par.AddLineBreak(); if (PrefC.GetString(PrefName.PracticeAddress2) != "") { par.AddText(PrefC.GetString(PrefName.PracticeAddress2)); par.AddLineBreak(); } if (CultureInfo.CurrentCulture.Name.EndsWith("CH")) //CH is for switzerland. eg de-CH { par.AddText(PrefC.GetString(PrefName.PracticeZip) + " " + PrefC.GetString(PrefName.PracticeCity)); } else { par.AddText(PrefC.GetString(PrefName.PracticeCity) + ", " + PrefC.GetString(PrefName.PracticeST) + " " + PrefC.GetString(PrefName.PracticeZip)); } par.AddLineBreak(); text = PrefC.GetString(PrefName.PracticePhone); if (text.Length == 10) { text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6); } par.AddText(text); par.AddLineBreak(); } } #endregion //AMOUNT ENCLOSED------------------------------------------------------------------------------------------------------ #region Amount Enclosed Table table; Column col; Row row; Cell cell; frame = MigraDocHelper.CreateContainer(section, 450, 110, 330, 29); if (!Stmt.HidePayment) { table = MigraDocHelper.DrawTable(frame, 0, 0, 29); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); row = table.AddRow(); row.Format.Alignment = ParagraphAlignment.Center; row.Borders.Color = Colors.Black; row.Shading.Color = Colors.LightGray; row.TopPadding = Unit.FromInch(0); row.BottomPadding = Unit.FromInch(0); font = MigraDocHelper.CreateFont(8, true); cell = row.Cells[0]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g("FormRpStatement", "Amount Due"), font); cell = row.Cells[1]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g("FormRpStatement", "Date Due"), font); cell = row.Cells[2]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g("FormRpStatement", "Amount Enclosed"), font); row = table.AddRow(); row.Format.Alignment = ParagraphAlignment.Center; row.Borders.Left.Color = Colors.Gray; row.Borders.Bottom.Color = Colors.Gray; row.Borders.Right.Color = Colors.Gray; font = MigraDocHelper.CreateFont(9); double balTotal = PatGuar.BalTotal; if (!PrefC.GetBool(PrefName.BalancesDontSubtractIns)) //this is typical { balTotal -= PatGuar.InsEst; } for (int m = 0; m < tableMisc.Rows.Count; m++) { if (tableMisc.Rows[m]["descript"].ToString() == "payPlanDue") { balTotal += PIn.Double(tableMisc.Rows[m]["value"].ToString()); //payPlanDue;//PatGuar.PayPlanDue; } } text = balTotal.ToString("F"); cell = row.Cells[0]; par = cell.AddParagraph(); par.AddFormattedText(text, font); if (PrefC.GetLong(PrefName.StatementsCalcDueDate) == -1) { text = Lan.g("FormRpStatement", "Upon Receipt"); } else { text = DateTime.Today.AddDays(PrefC.GetLong(PrefName.StatementsCalcDueDate)).ToShortDateString(); } cell = row.Cells[1]; par = cell.AddParagraph(); par.AddFormattedText(text, font); } #endregion //Credit Card Info-------------------------------------------------------------------------------------------------------- #region Credit Card Info if (!Stmt.HidePayment) { if (PrefC.GetBool(PrefName.StatementShowCreditCard)) { float yPos = 60; font = MigraDocHelper.CreateFont(7, true); text = Lan.g("FormRpStatement", "CREDIT CARD TYPE"); MigraDocHelper.DrawString(frame, text, font, 0, yPos); float rowHeight = 26; System.Drawing.Font wfont = new System.Drawing.Font("Arial", 7, FontStyle.Bold); System.Drawing.Image img = new Bitmap(500, 30); Graphics g = Graphics.FromImage(img); //just to measure strings MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width, yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g)); yPos += rowHeight; text = Lan.g("FormRpStatement", "#"); MigraDocHelper.DrawString(frame, text, font, 0, yPos); MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width, yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g)); yPos += rowHeight; text = Lan.g("FormRpStatement", "3 DIGIT CSV"); MigraDocHelper.DrawString(frame, text, font, 0, yPos); MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width, yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g)); yPos += rowHeight; text = Lan.g("FormRpStatement", "EXPIRES"); MigraDocHelper.DrawString(frame, text, font, 0, yPos); MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width, yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g)); yPos += rowHeight; text = Lan.g("FormRpStatement", "AMOUNT APPROVED"); MigraDocHelper.DrawString(frame, text, font, 0, yPos); MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width, yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g)); yPos += rowHeight; text = Lan.g("FormRpStatement", "NAME"); MigraDocHelper.DrawString(frame, text, font, 0, yPos); MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width, yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g)); yPos += rowHeight; text = Lan.g("FormRpStatement", "SIGNATURE"); MigraDocHelper.DrawString(frame, text, font, 0, yPos); MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width, yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g)); yPos -= rowHeight; text = Lan.g("FormRpStatement", "(As it appears on card)"); wfont = new System.Drawing.Font("Arial", 5); font = MigraDocHelper.CreateFont(5); MigraDocHelper.DrawString(frame, text, font, 625 - g.MeasureString(text, wfont).Width / 2 + 5, yPos + 13); g.Dispose(); img = null; } } #endregion //Patient's Billing Address--------------------------------------------------------------------------------------------- #region Patient Billing Address font = MigraDocHelper.CreateFont(11); frame = MigraDocHelper.CreateContainer(section, 62.5f + 12.5f, 225 + 1, 300, 200); par = frame.AddParagraph(); par.Format.Font = font; if (Stmt.SinglePatient) { par.AddText(fam.GetNameInFamFL(Stmt.PatNum)); } else { par.AddText(PatGuar.GetNameFLFormal()); } par.AddLineBreak(); par.AddText(PatGuar.Address); par.AddLineBreak(); if (PatGuar.Address2 != "") { par.AddText(PatGuar.Address2); par.AddLineBreak(); } if (CultureInfo.CurrentCulture.Name.EndsWith("CH")) //CH is for switzerland. eg de-CH { par.AddText(PatGuar.Zip + " " + PatGuar.City); } else { par.AddText(PatGuar.City + ", " + PatGuar.State + " " + PatGuar.Zip); } //perforated line------------------------------------------------------------------------------------------------------ //yPos=350;//3.62 inches from top, 1/3 page down frame = MigraDocHelper.CreateContainer(section, 0, 350, 850, 30); if (!Stmt.HidePayment) { MigraDocHelper.DrawLine(frame, System.Drawing.Color.LightGray, 0, 0, 850, 0); text = Lan.g("FormRpStatement", "PLEASE DETACH AND RETURN THE UPPER PORTION WITH YOUR PAYMENT"); font = MigraDocHelper.CreateFont(6, true, System.Drawing.Color.Gray); par = frame.AddParagraph(); par.Format.Alignment = ParagraphAlignment.Center; par.Format.Font = font; par.AddText(text); } #endregion //Australian Provider Legend #region Australian Provider Legend int legendOffset = 0; if (CultureInfo.CurrentCulture.Name == "en-AU") //English (Australia) { Providers.RefreshCache(); legendOffset = 25 + 15 * (1 + ProviderC.List.Length); MigraDocHelper.InsertSpacer(section, legendOffset); frame = MigraDocHelper.CreateContainer(section, 45, 390, 250, legendOffset); par = frame.AddParagraph(); par.Format.Font = MigraDocHelper.CreateFont(8, true); par.AddLineBreak(); par.AddText("PROVIDERS:"); par = frame.AddParagraph(); par.Format.Font = MigraDocHelper.CreateFont(8, false); for (int i = 0; i < ProviderC.List.Length; i++) //All non-hidden providers are added to the legend. { Provider prov = ProviderC.List[i]; string suffix = ""; if (prov.Suffix.Trim() != "") { suffix = ", " + prov.Suffix.Trim(); } par.AddText(prov.Abbr + " - " + prov.FName + " " + prov.LName + suffix + " - " + prov.MedicaidID); par.AddLineBreak(); } par.AddLineBreak(); } #endregion //Aging----------------------------------------------------------------------------------- #region Aging MigraDocHelper.InsertSpacer(section, 275); frame = MigraDocHelper.CreateContainer(section, 55, 390 + legendOffset, 250, 29); if (!Stmt.HidePayment) { table = MigraDocHelper.DrawTable(frame, 0, 0, 29); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); row = table.AddRow(); row.Format.Alignment = ParagraphAlignment.Center; row.Borders.Color = Colors.Black; row.Shading.Color = Colors.LightGray; row.TopPadding = Unit.FromInch(0); row.BottomPadding = Unit.FromInch(0); font = MigraDocHelper.CreateFont(8, true); cell = row.Cells[0]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g("FormRpStatement", "0-30"), font); cell = row.Cells[1]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g("FormRpStatement", "31-60"), font); cell = row.Cells[2]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g("FormRpStatement", "61-90"), font); cell = row.Cells[3]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g("FormRpStatement", "over 90"), font); row = table.AddRow(); row.Format.Alignment = ParagraphAlignment.Center; row.Borders.Left.Color = Colors.Gray; row.Borders.Bottom.Color = Colors.Gray; row.Borders.Right.Color = Colors.Gray; font = MigraDocHelper.CreateFont(9); text = PatGuar.Bal_0_30.ToString("F"); cell = row.Cells[0]; par = cell.AddParagraph(); par.AddFormattedText(text, font); text = PatGuar.Bal_31_60.ToString("F"); cell = row.Cells[1]; par = cell.AddParagraph(); par.AddFormattedText(text, font); text = PatGuar.Bal_61_90.ToString("F"); cell = row.Cells[2]; par = cell.AddParagraph(); par.AddFormattedText(text, font); text = PatGuar.BalOver90.ToString("F"); cell = row.Cells[3]; par = cell.AddParagraph(); par.AddFormattedText(text, font); } #endregion //Floating Balance, Ins info------------------------------------------------------------------- #region FloatingBalance frame = MigraDocHelper.CreateContainer(section, 460, 380 + legendOffset, 250, 200); //table=MigraDocHelper.DrawTable(frame,0,0,90); par = frame.AddParagraph(); parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Right; par.Format = parformat; font = MigraDocHelper.CreateFont(10, false); MigraDoc.DocumentObjectModel.Font fontBold = MigraDocHelper.CreateFont(10, true); if (PrefC.GetBool(PrefName.BalancesDontSubtractIns)) { text = Lan.g("FormRpStatement", "Balance:"); par.AddFormattedText(text, fontBold); //par.AddLineBreak(); //text = Lan.g(this, "Ins Pending:"); //par.AddFormattedText(text, font); //par.AddLineBreak(); //text = Lan.g(this, "After Ins:"); //par.AddFormattedText(text, font); //par.AddLineBreak(); } else //this is more common { if (PrefC.GetBool(PrefName.FuchsOptionsOn)) { text = Lan.g("FormRpStatement", "Balance:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g("FormRpStatement", "-Ins Estimate:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g("FormRpStatement", "=Owed Now:"); par.AddFormattedText(text, fontBold); par.AddLineBreak(); } else { text = Lan.g("FormRpStatement", "Total:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g("FormRpStatement", "-Ins Estimate:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g("FormRpStatement", "=Balance:"); par.AddFormattedText(text, fontBold); par.AddLineBreak(); } } frame = MigraDocHelper.CreateContainer(section, 730, 380 + legendOffset, 100, 200); //table=MigraDocHelper.DrawTable(frame,0,0,90); par = frame.AddParagraph(); parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Left; par.Format = parformat; font = MigraDocHelper.CreateFont(10, false); //numbers: if (PrefC.GetBool(PrefName.BalancesDontSubtractIns)) { text = PatGuar.BalTotal.ToString("c"); par.AddFormattedText(text, fontBold); //par.AddLineBreak(); //text = PatGuar.InsEst.ToString("c"); //par.AddFormattedText(text, font); //par.AddLineBreak(); //text = (PatGuar.BalTotal - PatGuar.InsEst).ToString("c"); //par.AddFormattedText(text, font); //par.AddLineBreak(); } else //more common { if (Stmt.SinglePatient) { double patInsEst = 0; for (int m = 0; m < tableMisc.Rows.Count; m++) { if (tableMisc.Rows[m]["descript"].ToString() == "patInsEst") { patInsEst = PIn.Double(tableMisc.Rows[m]["value"].ToString()); } } double patBal = pat.EstBalance - patInsEst; text = pat.EstBalance.ToString("c"); par.AddFormattedText(text, font); par.AddLineBreak(); text = patInsEst.ToString("c"); par.AddFormattedText(text, font); par.AddLineBreak(); text = patBal.ToString("c"); par.AddFormattedText(text, fontBold); } else { text = PatGuar.BalTotal.ToString("c"); par.AddFormattedText(text, font); par.AddLineBreak(); text = PatGuar.InsEst.ToString("c"); par.AddFormattedText(text, font); par.AddLineBreak(); text = (PatGuar.BalTotal - PatGuar.InsEst).ToString("c"); par.AddFormattedText(text, fontBold); par.AddLineBreak(); } } MigraDocHelper.InsertSpacer(section, 80); #endregion FloatingBalance //Bold note------------------------------------------------------------------------------- #region Bold note if (Stmt.NoteBold != "") { MigraDocHelper.InsertSpacer(section, 7); font = MigraDocHelper.CreateFont(10, true, System.Drawing.Color.DarkRed); par = section.AddParagraph(); par.Format.Font = font; par.AddText(Stmt.NoteBold); MigraDocHelper.InsertSpacer(section, 8); } #endregion Bold note //Payment plan grid definition--------------------------------------------------------------------------------- #region PayPlan grid definition ODGridColumn gcol; ODGridRow grow; ODGrid gridPP = new ODGrid(); //this.Controls.Add(gridPP); gridPP.BeginUpdate(); gridPP.Columns.Clear(); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Date"), 73); gridPP.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Description"), 270); gridPP.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Charges"), 60, HorizontalAlignment.Right); gridPP.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Credits"), 60, HorizontalAlignment.Right); gridPP.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Balance"), 60, HorizontalAlignment.Right); gridPP.Columns.Add(gcol); gridPP.Width = gridPP.WidthAllColumns + 20; gridPP.EndUpdate(); #endregion PayPlan grid definition //Payment plan grid. There will be only one, if any----------------------------------------------------------------- #region PayPlan grid DataTable tablePP = dataSet.Tables["payplan"]; ODGridCell gcell; if (tablePP.Rows.Count > 0) { //MigraDocHelper.InsertSpacer(section,5); par = section.AddParagraph(); par.Format.Font = MigraDocHelper.CreateFont(10, true); par.Format.Alignment = ParagraphAlignment.Center; //par.Format.SpaceBefore=Unit.FromInch(.05); //par.Format.SpaceAfter=Unit.FromInch(.05); par.AddText(Lan.g("FormRpStatement", "Payment Plans")); MigraDocHelper.InsertSpacer(section, 2); gridPP.BeginUpdate(); gridPP.Rows.Clear(); for (int p = 0; p < tablePP.Rows.Count; p++) { grow = new ODGridRow(); grow.Cells.Add(tablePP.Rows[p]["date"].ToString()); grow.Cells.Add(tablePP.Rows[p]["description"].ToString()); grow.Cells.Add(tablePP.Rows[p]["charges"].ToString()); grow.Cells.Add(tablePP.Rows[p]["credits"].ToString()); gcell = new ODGridCell(tablePP.Rows[p]["balance"].ToString()); if (p == tablePP.Rows.Count - 1) { gcell.Bold = YN.Yes; } else if (tablePP.Rows[p + 1]["balance"].ToString() == "") //if next row balance is blank. { gcell.Bold = YN.Yes; } grow.Cells.Add(gcell); gridPP.Rows.Add(grow); } gridPP.EndUpdate(); MigraDocHelper.DrawGrid(section, gridPP); MigraDocHelper.InsertSpacer(section, 2); par = section.AddParagraph(); par.Format.Font = MigraDocHelper.CreateFont(10, true); par.Format.Alignment = ParagraphAlignment.Right; par.Format.RightIndent = Unit.FromInch(0.25); double payPlanDue = 0; for (int m = 0; m < tableMisc.Rows.Count; m++) { if (tableMisc.Rows[m]["descript"].ToString() == "payPlanDue") { payPlanDue = PIn.Double(tableMisc.Rows[m]["value"].ToString()); } } par.AddText(Lan.g("FormRpStatement", "Payment Plan Amount Due: ") + payPlanDue.ToString("c")); //PatGuar.PayPlanDue.ToString("c")); MigraDocHelper.InsertSpacer(section, 10); } #endregion PayPlan grid //Body Table definition-------------------------------------------------------------------------------------------------------- #region Body Table definition ODGrid gridPat = new ODGrid(); //this.Controls.Add(gridPat); gridPat.BeginUpdate(); gridPat.Columns.Clear(); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Date"), 73); gridPat.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Patient"), 100); gridPat.Columns.Add(gcol); //prov gcol = new ODGridColumn(Lan.g("FormRpStatement", "Code"), 45); gridPat.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Tooth"), 42); gridPat.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Description"), 270); gridPat.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Charges"), 60, HorizontalAlignment.Right); gridPat.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Credits"), 60, HorizontalAlignment.Right); gridPat.Columns.Add(gcol); gcol = new ODGridColumn(Lan.g("FormRpStatement", "Balance"), 60, HorizontalAlignment.Right); gridPat.Columns.Add(gcol); gridPat.Width = gridPat.WidthAllColumns + 20; gridPat.EndUpdate(); #endregion Body Table definition //Loop through each table. Could be one intermingled, or one for each patient----------------------------------------- DataTable tableAccount; string tablename; long patnum; for (int i = 0; i < dataSet.Tables.Count; i++) { tableAccount = dataSet.Tables[i]; tablename = tableAccount.TableName; if (!tablename.StartsWith("account")) { continue; } par = section.AddParagraph(); par.Format.Font = MigraDocHelper.CreateFont(10, true); par.Format.SpaceBefore = Unit.FromInch(.05); par.Format.SpaceAfter = Unit.FromInch(.05); patnum = 0; if (tablename != "account") //account123 etc. { patnum = PIn.Long(tablename.Substring(7)); } if (patnum != 0) { par.AddText(fam.GetNameInFamFLnoPref(patnum)); } //if(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript!=""){ // par=section.AddParagraph(); // par.Format.Font=MigraDocHelper.CreateFont(9);//same as body font // par.AddText(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript); //} gridPat.BeginUpdate(); gridPat.Rows.Clear(); //lineData=FamilyStatementDataList[famIndex].PatDataList[i].PatData; for (int p = 0; p < tableAccount.Rows.Count; p++) { grow = new ODGridRow(); grow.Cells.Add(tableAccount.Rows[p]["date"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["patient"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["ProcCode"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["tth"].ToString()); if (CultureInfo.CurrentCulture.Name == "en-AU") //English (Australia) { if (tableAccount.Rows[p]["prov"].ToString().Trim() != "") { grow.Cells.Add(tableAccount.Rows[p]["prov"].ToString() + " - " + tableAccount.Rows[p]["description"].ToString()); } else //No provider on this account row item, so don't put the extra leading characters. { grow.Cells.Add(tableAccount.Rows[p]["description"].ToString()); } } else //Assume English (United States) { grow.Cells.Add(tableAccount.Rows[p]["description"].ToString()); } grow.Cells.Add(tableAccount.Rows[p]["charges"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["credits"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["balance"].ToString()); gridPat.Rows.Add(grow); } gridPat.EndUpdate(); MigraDocHelper.DrawGrid(section, gridPat); //Total frame = MigraDocHelper.CreateContainer(section); font = MigraDocHelper.CreateFont(9, true); float totalPos = ((float)(doc.DefaultPageSetup.PageWidth.Inch //-doc.DefaultPageSetup.LeftMargin.Inch //-doc.DefaultPageSetup.RightMargin.Inch) ) * 100f) / 2f + (float)gridPat.WidthAllColumns / 2f + 7; RectangleF rectF = new RectangleF(0, 0, totalPos, 16); if (patnum != 0) { MigraDocHelper.DrawString(frame, " ", //I decided this was unnecessary: //dataSet.Tables["patient"].Rows[fam.GetIndex(patnum)]["balance"].ToString(), font, rectF, ParagraphAlignment.Right); //MigraDocHelper.DrawString(frame,FamilyStatementDataList[famIndex].PatAboutList[i].Balance.ToString("F"),font,rectF, // ParagraphAlignment.Right); } } gridPat.Dispose(); //Future appointments--------------------------------------------------------------------------------------------- #region Future appointments font = MigraDocHelper.CreateFont(9); DataTable tableAppt = dataSet.Tables["appts"]; if (tableAppt.Rows.Count > 0) { par = section.AddParagraph(); par.Format.Font = font; par.AddText(Lan.g("FormRpStatement", "Scheduled Appointments:")); } for (int i = 0; i < tableAppt.Rows.Count; i++) { par.AddLineBreak(); par.AddText(tableAppt.Rows[i]["descript"].ToString()); } if (tableAppt.Rows.Count > 0) { MigraDocHelper.InsertSpacer(section, 10); } #endregion Future appointments //Note------------------------------------------------------------------------------------------------------------ font = MigraDocHelper.CreateFont(9); par = section.AddParagraph(); par.Format.Font = font; par.AddText(Stmt.Note); //bold note if (Stmt.NoteBold != "") { MigraDocHelper.InsertSpacer(section, 10); font = MigraDocHelper.CreateFont(10, true, System.Drawing.Color.DarkRed); par = section.AddParagraph(); par.Format.Font = font; par.AddText(Stmt.NoteBold); } //return doc; }
/// <summary> /// Adds a new FormattedText object with the given text and font. /// </summary> public FormattedText AddFormattedText(string text, Font font) { return this.Elements.AddFormattedText(text, font); }
static XFont XFontFromCache(Font font, bool unicode, PdfFontEmbedding fontEmbedding) { XFont xFont = null; XPdfFontOptions options = null; options = new XPdfFontOptions(fontEmbedding, unicode); XFontStyle style = GetXStyle(font); xFont = new XFont(font.Name, font.Size, style, options); return xFont; }
///<summary></summary> public static void DrawString(TextFrame frameContainer, string text, MigraDoc.DocumentObjectModel.Font font, RectangleF rectF) { DrawString(frameContainer, text, font, rectF, ParagraphAlignment.Left); }
/// <summary> /// Applies all non-null properties of a font to this font. /// </summary> public void ApplyFont(Font font) { if (font == null) throw new ArgumentNullException("font"); if (!font.name.IsNull && font.name.Value != "") this.Name = font.Name; if (!font.size.IsNull) this.Size = font.Size; if (!font.bold.IsNull) this.Bold = font.Bold; if (!font.italic.IsNull) this.Italic = font.Italic; if (!font.subscript.IsNull) this.Subscript = font.Subscript; else if (!font.superscript.IsNull) this.Superscript = font.Superscript; if (!font.underline.IsNull) this.Underline = font.Underline; if (!font.color.IsNull) this.Color = font.Color; }
/// <summary> /// Converts Font into DDL. Properties with the same value as in an optionally given /// font are not serialized. /// </summary> internal void Serialize(Serializer serializer, Font font) { if (this.Parent is FormattedText) { string fontStyle = ""; if (((FormattedText)this.Parent).style.IsNull) { // Check if we can use a DDL keyword. FontProperties notNull = CheckWhatIsNotNull(); if (notNull == FontProperties.Size) { serializer.Write("\\fontsize(" + size.ToString() + ")"); return; } else if (notNull == FontProperties.Bold && bold.Value) { serializer.Write("\\bold"); return; } else if (notNull == FontProperties.Italic && italic.Value) { serializer.Write("\\italic"); return; } else if (notNull == FontProperties.Color) { serializer.Write("\\fontcolor(" + color.ToString() + ")"); return; } } else fontStyle = "(\"" + ((FormattedText)this.Parent).Style + "\")"; //bool needBlank = false; // nice, but later... serializer.Write("\\font" + fontStyle + "["); if (!this.name.IsNull && this.name.Value != "") serializer.WriteSimpleAttribute("Name", this.Name); #if DEBUG // Test if (!this.size.IsNull && this.Size != 0 && this.Size.Point == 0) this.GetType(); #endif if ((!this.size.IsNull)) serializer.WriteSimpleAttribute("Size", this.Size); if (!this.bold.IsNull) serializer.WriteSimpleAttribute("Bold", this.Bold); if (!this.italic.IsNull) serializer.WriteSimpleAttribute("Italic", this.Italic); if (!this.underline.IsNull) serializer.WriteSimpleAttribute("Underline", this.Underline); if (!this.superscript.IsNull) serializer.WriteSimpleAttribute("Superscript", this.Superscript); if (!this.subscript.IsNull) serializer.WriteSimpleAttribute("Subscript", this.Subscript); if (!this.color.IsNull) serializer.WriteSimpleAttribute("Color", this.Color); serializer.Write("]"); } else { int pos = serializer.BeginContent("Font"); #if true // Don't write null values if font is null. // Do write null values if font is not null! if ((!name.IsNull && Name != String.Empty && font == null) || (font != null && !name.IsNull && Name != String.Empty && Name != font.Name)) serializer.WriteSimpleAttribute("Name", Name); // Test if (!size.IsNull && Size != 0 && Size.Point == 0) GetType(); if (!size.IsNull && (font == null || Size != font.Size)) serializer.WriteSimpleAttribute("Size", Size); //NBool and NEnum have to be compared directly to check whether the value Null is if (!bold.IsNull && (font == null || Bold != font.Bold || font.bold.IsNull)) serializer.WriteSimpleAttribute("Bold", Bold); if (!italic.IsNull && (font == null || Italic != font.Italic || font.italic.IsNull)) serializer.WriteSimpleAttribute("Italic", Italic); if (!underline.IsNull && (font == null || Underline != font.Underline || font.underline.IsNull)) serializer.WriteSimpleAttribute("Underline", Underline); if (!superscript.IsNull && (font == null || Superscript != font.Superscript || font.superscript.IsNull)) serializer.WriteSimpleAttribute("Superscript", Superscript); if (!subscript.IsNull && (font == null || Subscript != font.Subscript || font.subscript.IsNull)) serializer.WriteSimpleAttribute("Subscript", Subscript); if (!color.IsNull && (font == null || this.Color.Argb != font.Color.Argb))// && this.Color.RGB != Color.Transparent.RGB) serializer.WriteSimpleAttribute("Color", this.Color); #else if ((!this.name.IsNull && this.Name != String.Empty) && (font == null || this.Name != font.Name)) serializer.WriteSimpleAttribute("Name", this.Name); if (!this.size.IsNull && (font == null || this.Size != font.Size)) serializer.WriteSimpleAttribute("Size", this.Size); //NBool and NEnum have to be compared directly to check whether the value Null is if (!this.bold.IsNull && (font == null || this.Bold != font.Bold)) serializer.WriteSimpleAttribute("Bold", this.Bold); if (!this.italic.IsNull && (font == null || this.Italic != font.Italic)) serializer.WriteSimpleAttribute("Italic", this.Italic); if (!this.underline.IsNull && (font == null || this.Underline != font.Underline)) serializer.WriteSimpleAttribute("Underline", this.Underline); if (!this.superscript.IsNull && (font == null || this.Superscript != font.Superscript)) serializer.WriteSimpleAttribute("Superscript", this.Superscript); if (!this.subscript.IsNull && (font == null || this.Subscript != font.Subscript)) serializer.WriteSimpleAttribute("Subscript", this.Subscript); if (!this.color.IsNull && (font == null || this.Color.Argb != font.Color.Argb))// && this.Color.RGB != Color.Transparent.RGB) serializer.WriteSimpleAttribute("Color", this.Color); #endif serializer.EndContent(pos); } }
/// <summary> /// Adds a new FormattedText with the given Font. /// </summary> public FormattedText AddFormattedText(Font font) { FormattedText formattedText = new FormattedText(); formattedText.Font.ApplyFont(font); this.Add(formattedText); return formattedText; }
public static void DrawGrid(Section section,ODGrid grid) { //first, calculate width of dummy column that will push the grid over just enough to center it on the page. double pageW=0; if(CultureInfo.CurrentCulture.Name=="en-US") { pageW=850; } //don't know about Canada else { pageW=830; } //in 100ths/inch double widthAllColumns=(double)grid.WidthAllColumns/.96; double lmargin=section.Document.DefaultPageSetup.LeftMargin.Inch*100; double dummyColW=(pageW-widthAllColumns)/2-lmargin; Table table=new Table(); Column col; col=table.AddColumn(Unit.FromInch(dummyColW/100)); for(int i=0;i<grid.Columns.Count;i++){ col=table.AddColumn(Unit.FromInch((double)grid.Columns[i].ColWidth/96)); col.LeftPadding=Unit.FromInch(.01); col.RightPadding=Unit.FromInch(.01); } Row row; row=table.AddRow(); row.HeadingFormat=true; row.TopPadding=Unit.FromInch(0); row.BottomPadding=Unit.FromInch(-.01); Cell cell; Paragraph par; //dummy column: cell=row.Cells[0]; //cell.Shading.Color=Colors.LightGray; //format dummy cell? MigraDoc.DocumentObjectModel.Font fontHead=new MigraDoc.DocumentObjectModel.Font("Arial",Unit.FromPoint(8.5)); fontHead.Bold=true; for(int i=0;i<grid.Columns.Count;i++){ cell = row.Cells[i+1]; par=cell.AddParagraph(); par.AddFormattedText(grid.Columns[i].Heading,fontHead); par.Format.Alignment=ParagraphAlignment.Center; cell.Format.Alignment=ParagraphAlignment.Center; cell.Borders.Width=Unit.FromPoint(1); cell.Borders.Color=Colors.Black; cell.Shading.Color=Colors.LightGray; } MigraDoc.DocumentObjectModel.Font fontBody=null;//=new MigraDoc.DocumentObjectModel.Font("Arial",Unit.FromPoint(8.5)); bool isBold; System.Drawing.Color color; int edgeRows=1; for(int i=0;i<grid.Rows.Count;i++,edgeRows++){ row=table.AddRow(); row.TopPadding=Unit.FromInch(.01); row.BottomPadding=Unit.FromInch(0); for(int j=0;j<grid.Columns.Count;j++){ cell = row.Cells[j+1]; par=cell.AddParagraph(); if(grid.Rows[i].Cells[j].Bold==YN.Unknown){ isBold=grid.Rows[i].Bold; } else if(grid.Rows[i].Cells[j].Bold==YN.Yes){ isBold=true; } else{// if(grid.Rows[i].Cells[j].Bold==YN.No){ isBold=false; } if(grid.Rows[i].Cells[j].ColorText==System.Drawing.Color.Empty){ color=grid.Rows[i].ColorText; } else{ color=grid.Rows[i].Cells[j].ColorText; } fontBody=CreateFont(8.5f,isBold,color); par.AddFormattedText(grid.Rows[i].Cells[j].Text,fontBody); if(grid.Columns[j].TextAlign==HorizontalAlignment.Center){ cell.Format.Alignment=ParagraphAlignment.Center; } if(grid.Columns[j].TextAlign==HorizontalAlignment.Left) { cell.Format.Alignment=ParagraphAlignment.Left; } if(grid.Columns[j].TextAlign==HorizontalAlignment.Right) { cell.Format.Alignment=ParagraphAlignment.Right; } cell.Borders.Color=new MigraDoc.DocumentObjectModel.Color(180,180,180); if(grid.Rows[i].ColorLborder!=System.Drawing.Color.Empty){ cell.Borders.Bottom.Color=ConvertColor(grid.Rows[i].ColorLborder); } } if(grid.Rows[i].Note!=null && grid.Rows[i].Note!="" && grid.NoteSpanStop>0 && grid.NoteSpanStart<grid.Columns.Count){ row=table.AddRow(); row.TopPadding=Unit.FromInch(.01); row.BottomPadding=Unit.FromInch(0); cell=row.Cells[grid.NoteSpanStart+1]; par=cell.AddParagraph(); par.AddFormattedText(grid.Rows[i].Note,fontBody); cell.Format.Alignment=ParagraphAlignment.Left; cell.Borders.Color=new MigraDoc.DocumentObjectModel.Color(180,180,180); cell.MergeRight=grid.Columns.Count-1-grid.NoteSpanStart; edgeRows++; } } table.SetEdge(1,0,grid.Columns.Count,edgeRows,Edge.Box,MigraDoc.DocumentObjectModel.BorderStyle.Single,1,Colors.Black); section.Add(table); }
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 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"); }
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; }
static string BuildSignature(Font font, bool unicode, PdfFontEmbedding fontEmbedding) { StringBuilder signature = new StringBuilder(128); signature.Append(font.Name.ToLower()); signature.Append(font.Size.Point.ToString("##0.0")); return signature.ToString(); }
public virtual ActionResult RunReportToPdf(ReportParameters parms) { using (var db = NewDbContext()) { IDbCommand cmd; double fontSize = 9; try { cmd = ReportCommand(parms); } catch (Exception ex) { throw; } db.Database.Connection.Open(); cmd.Connection = (IDbConnection)db.Database.Connection; PdfDocument pdfDocument = new PdfDocument(); pdfDocument.Info.Title = parms.ReportName; pdfDocument.Info.Author = User.Identity.GetUserName(); pdfDocument.Info.Subject = parms.ReportDescription; pdfDocument.Info.Keywords = ""; PdfPage page = pdfDocument.AddPage(); page.Size = PdfSharp.PageSize.Letter; Document doc = new Document(); Section sec = doc.AddSection(); sec.PageSetup.PageFormat = PageFormat.Letter; sec.PageSetup.StartingNumber = 1; sec.PageSetup.RightMargin = ".25in"; sec.PageSetup.LeftMargin = ".25in"; sec.PageSetup.TopMargin = ".75in"; sec.PageSetup.BottomMargin = ".25in"; // 72 units per inch Style style = doc.Styles["Normal"]; style.Font.Name = "Verdana"; page.Orientation = (parms.PdfOrientation == "L") ? PdfSharp.PageOrientation.Landscape : PdfSharp.PageOrientation.Portrait; sec.PageSetup.Orientation = (parms.PdfOrientation == "L") ? Orientation.Landscape : Orientation.Portrait; double[] columnWidth = CalculateColumnWidths(parms, cmd, page, fontSize); double availWidth = page.Width.Point - sec.PageSetup.RightMargin.Point - sec.PageSetup.LeftMargin.Point - columnWidth.Length * 4; if (columnWidth.Sum() > availWidth) { //page.Orientation = PdfSharp.PageOrientation.Landscape; //sec.PageSetup.Orientation = Orientation.Landscape; availWidth = page.Width.Point - sec.PageSetup.RightMargin.Point - sec.PageSetup.LeftMargin.Point - columnWidth.Length * 4; while (columnWidth.Sum() > availWidth && fontSize > 5) { fontSize = fontSize - 1; columnWidth = CalculateColumnWidths(parms, cmd, page, fontSize); } } var blankCol = Array.FindIndex(parms.ColumnNames, c => c.Equals("blank")); if (blankCol >= 0) { double unused = availWidth - columnWidth.Sum(); columnWidth[blankCol] += unused; } var titleFont = new MigraDoc.DocumentObjectModel.Font("Verdana", 15); titleFont.Bold = true; var font = new MigraDoc.DocumentObjectModel.Font("Verdana", fontSize); var frame = sec.Headers.Primary.AddTextFrame(); frame.Width = page.Width.Point - sec.PageSetup.RightMargin.Point - sec.PageSetup.LeftMargin.Point; frame.Top = ".25in"; frame.Left = 0; frame.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Page; Paragraph paragraph = frame.AddParagraph(); paragraph.Format.Font = titleFont; paragraph.Format.Alignment = ParagraphAlignment.Center; paragraph.AddText(parms.ReportName); paragraph = frame.AddParagraph(); paragraph.Format.Font = font; paragraph.Format.Alignment = ParagraphAlignment.Center; paragraph.AddText(parms.ReportDescription); frame = sec.Headers.Primary.AddTextFrame(); frame.Height = ".2in"; frame.Width = "1.5in"; frame.Top = ".30in"; frame.Left = (page.Width.Point - sec.PageSetup.LeftMargin.Point - sec.PageSetup.RightMargin.Point - frame.Width.Point); frame.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Page; paragraph = frame.AddParagraph(); paragraph.Format.Font = font.Clone(); paragraph.Format.Alignment = ParagraphAlignment.Right; paragraph.AddText("Page "); paragraph.AddPageField(); paragraph.AddText(" of "); paragraph.AddNumPagesField(); Table table = sec.AddTable(); table.Style = "Table"; table.Borders.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray; table.Borders.Width = 0.25; table.Borders.Left.Width = 0.25; table.Borders.Right.Width = 0.25; table.Rows.LeftIndent = 0; table.Rows.Alignment = RowAlignment.Center; table.Format.Font = new MigraDoc.DocumentObjectModel.Font("Verdana", fontSize); for (int x = 0; x < parms.ColumnNames.Length; x++) { PdfTableColumnAdd(table, columnWidth[x], parms.ColumnNames[x]); } Row row = table.AddRow(); row.HeadingFormat = true; row.Format.Font.Bold = true; row.Shading.Color = MigraDoc.DocumentObjectModel.Colors.LightGray; for (int x = 0; x < parms.ColumnNames.Length; x++) { switch (parms.ColumnNames[x]) { default: row.Cells[x].AddParagraph(parms.ColumnHeadings[x]); break; } } using (var reader = cmd.ExecuteReader()) { int rowCnt = 0; while (reader.Read()) { try { rowCnt++; row = table.AddRow(); for (int i = 0; i < parms.ColumnNames.Length; i++) { switch (reader[i].GetType().Name) { case "Boolean": row.Cells[i].AddParagraph(BoolToString((bool)reader[i])); break; case "DateTime": row.Cells[i].AddParagraph(Zpm.FormatDate(reader[i])); break; default: row.Cells[i].AddParagraph(reader[i].ToString()); break; } } } catch (Exception ex) { throw; } } } PdfDocumentRenderer renderer = new PdfDocumentRenderer(true); renderer.Document = doc; renderer.RenderDocument(); string reportHandle = Guid.NewGuid().ToString(); using (MemoryStream ms = new MemoryStream()) { renderer.PdfDocument.Save(ms); TempData[reportHandle] = ms.ToArray(); } return(Json(reportHandle)); } }
public static void DrawGrid(Section section, ODGrid grid) { //first, calculate width of dummy column that will push the grid over just enough to center it on the page. double pageW = 0; if (CultureInfo.CurrentCulture.Name == "en-US") { pageW = (section.PageSetup.Orientation == MigraDoc.DocumentObjectModel.Orientation.Landscape) ? 1100 : 850; } //don't know about Canada else { pageW = (section.PageSetup.Orientation == MigraDoc.DocumentObjectModel.Orientation.Landscape) ? 1080 : 830; } //in 100ths/inch double widthAllColumns = (double)grid.WidthAllColumns / .96; double lmargin = section.Document.DefaultPageSetup.LeftMargin.Inch * 100; double dummyColW = (pageW - widthAllColumns) / 2 - lmargin; Table table = new Table(); Column col; col = table.AddColumn(Unit.FromInch(dummyColW / 100)); for (int i = 0; i < grid.ListGridColumns.Count; i++) { col = table.AddColumn(Unit.FromInch((double)grid.ListGridColumns[i].ColWidth / 96)); col.LeftPadding = Unit.FromInch(.01); col.RightPadding = Unit.FromInch(.01); } Row row; row = table.AddRow(); row.HeadingFormat = true; row.TopPadding = Unit.FromInch(0); row.BottomPadding = Unit.FromInch(-.01); Cell cell; Paragraph par; //dummy column: cell = row.Cells[0]; //cell.Shading.Color=Colors.LightGray; //format dummy cell? MigraDoc.DocumentObjectModel.Font fontHead = new MigraDoc.DocumentObjectModel.Font("Arial", Unit.FromPoint(8.5)); fontHead.Bold = true; PdfDocument pdfd = new PdfDocument(); PdfPage pg = pdfd.AddPage(); XGraphics gx = XGraphics.FromPdfPage(pg); //A dummy graphics object for measuring the text for (int i = 0; i < grid.ListGridColumns.Count; i++) { cell = row.Cells[i + 1]; par = cell.AddParagraph(); par.AddFormattedText(grid.ListGridColumns[i].Heading, fontHead); par.Format.Alignment = ParagraphAlignment.Center; cell.Format.Alignment = ParagraphAlignment.Center; cell.Borders.Width = Unit.FromPoint(1); cell.Borders.Color = Colors.Black; cell.Shading.Color = Colors.LightGray; } MigraDoc.DocumentObjectModel.Font fontBody = null; //=new MigraDoc.DocumentObjectModel.Font("Arial",Unit.FromPoint(8.5)); bool isBold; System.Drawing.Color color; int edgeRows = 1; for (int i = 0; i < grid.ListGridRows.Count; i++, edgeRows++) { row = table.AddRow(); row.TopPadding = Unit.FromInch(.01); row.BottomPadding = Unit.FromInch(0); for (int j = 0; j < grid.ListGridColumns.Count; j++) { cell = row.Cells[j + 1]; par = cell.AddParagraph(); if (grid.ListGridRows[i].Cells[j].Bold == YN.Unknown) { isBold = grid.ListGridRows[i].Bold; } else if (grid.ListGridRows[i].Cells[j].Bold == YN.Yes) { isBold = true; } else // if(grid.Rows[i].Cells[j].Bold==YN.No){ { isBold = false; } if (grid.ListGridRows[i].Cells[j].ColorText == System.Drawing.Color.Empty) { color = grid.ListGridRows[i].ColorText; } else { color = grid.ListGridRows[i].Cells[j].ColorText; } fontBody = CreateFont(8.5f, isBold, color); XFont xFont; if (isBold) { xFont = new XFont("Arial", 13.00); //Since we are using a dummy graphics object to measure the string, '13.00' is pretty much a guess-and-check //value that looks about right. } else { xFont = new XFont("Arial", 11.65); //Yep, a guess-and-check value here too. } int colWidth = grid.ListGridColumns[j].ColWidth; string cellText = grid.ListGridRows[i].Cells[j].Text; List <string> listWords = cellText.Split(new[] { " ", "\t", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries) .Where(x => !string.IsNullOrWhiteSpace(x)).ToList(); //PdfSharp.MeasureString sometimes throws an exception when measuring whitespace bool isAnyWordWiderThanColumn = listWords.Any(x => gx.MeasureString(x, xFont).Width > colWidth); if (!isAnyWordWiderThanColumn) { //Let MigraDoc format line breaks par.AddFormattedText(cellText, fontBody); } else { //Do our own line splitting and word splitting DrawTextWithWordSplits(par, fontBody, colWidth, cellText, gx, xFont); } if (grid.ListGridColumns[j].TextAlign == HorizontalAlignment.Center) { cell.Format.Alignment = ParagraphAlignment.Center; } if (grid.ListGridColumns[j].TextAlign == HorizontalAlignment.Left) { cell.Format.Alignment = ParagraphAlignment.Left; } if (grid.ListGridColumns[j].TextAlign == HorizontalAlignment.Right) { cell.Format.Alignment = ParagraphAlignment.Right; } cell.Borders.Color = new MigraDoc.DocumentObjectModel.Color(180, 180, 180); if (grid.ListGridRows[i].ColorLborder != System.Drawing.Color.Empty) { cell.Borders.Bottom.Color = ConvertColor(grid.ListGridRows[i].ColorLborder); } } if (grid.ListGridRows[i].Note != null && grid.ListGridRows[i].Note != "" && grid.NoteSpanStop > 0 && grid.NoteSpanStart < grid.ListGridColumns.Count) { row = table.AddRow(); row.TopPadding = Unit.FromInch(.01); row.BottomPadding = Unit.FromInch(0); cell = row.Cells[grid.NoteSpanStart + 1]; par = cell.AddParagraph(); par.AddFormattedText(grid.ListGridRows[i].Note, fontBody); cell.Format.Alignment = ParagraphAlignment.Left; cell.Borders.Color = new MigraDoc.DocumentObjectModel.Color(180, 180, 180); cell.MergeRight = grid.ListGridColumns.Count - 1 - grid.NoteSpanStart; edgeRows++; } } table.SetEdge(1, 0, grid.ListGridColumns.Count, edgeRows, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black); section.Add(table); }
internal FontRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer) : base(domObj, docRenderer) { this.font = domObj as Font; }
///<summary>Draws the word on multiple lines if it is too long to fit on one line.</summary> private static void DrawWordChunkByChunk(string word, int colWidth, Paragraph par, MigraDoc.DocumentObjectModel.Font fontBody, XGraphics gx, XFont xFont) { string chunk = ""; for (int i = 0; i < word.Length; i++) { char letter = word[i]; if ((chunk + letter).All(x => char.IsWhiteSpace(x))) //Sometimes gx.MeasureString will throw an exception if the text is all whitespace. { par.AddFormattedText(chunk + letter, fontBody); continue; } if (DoesTextFit(chunk + letter, colWidth, gx, xFont)) { if (i == word.Length - 1) //Reached the end of the word { par.AddFormattedText(chunk + letter, fontBody); return; } chunk += letter; continue; } par.AddFormattedText(chunk, fontBody); chunk = "" + letter; } }
public static void DrawGrid(Section section, ODGrid grid) { //first, calculate width of dummy column that will push the grid over just enough to center it on the page. double pageW = 0; if (CultureInfo.CurrentCulture.Name == "en-US") { pageW = 850; } //don't know about Canada else { pageW = 830; } //in 100ths/inch double widthAllColumns = (double)grid.WidthAllColumns / .96; double lmargin = section.Document.DefaultPageSetup.LeftMargin.Inch * 100; double dummyColW = (pageW - widthAllColumns) / 2 - lmargin; Table table = new Table(); Column col; col = table.AddColumn(Unit.FromInch(dummyColW / 100)); for (int i = 0; i < grid.Columns.Count; i++) { col = table.AddColumn(Unit.FromInch((double)grid.Columns[i].ColWidth / 96)); col.LeftPadding = Unit.FromInch(.01); col.RightPadding = Unit.FromInch(.01); } Row row; row = table.AddRow(); row.HeadingFormat = true; row.TopPadding = Unit.FromInch(0); row.BottomPadding = Unit.FromInch(-.01); Cell cell; Paragraph par; //dummy column: cell = row.Cells[0]; //cell.Shading.Color=Colors.LightGray; //format dummy cell? MigraDoc.DocumentObjectModel.Font fontHead = new MigraDoc.DocumentObjectModel.Font("Arial", Unit.FromPoint(8.5)); fontHead.Bold = true; for (int i = 0; i < grid.Columns.Count; i++) { cell = row.Cells[i + 1]; par = cell.AddParagraph(); par.AddFormattedText(grid.Columns[i].Heading, fontHead); par.Format.Alignment = ParagraphAlignment.Center; cell.Format.Alignment = ParagraphAlignment.Center; cell.Borders.Width = Unit.FromPoint(1); cell.Borders.Color = Colors.Black; cell.Shading.Color = Colors.LightGray; } MigraDoc.DocumentObjectModel.Font fontBody = null; //=new MigraDoc.DocumentObjectModel.Font("Arial",Unit.FromPoint(8.5)); bool isBold; System.Drawing.Color color; int edgeRows = 1; for (int i = 0; i < grid.Rows.Count; i++, edgeRows++) { row = table.AddRow(); row.TopPadding = Unit.FromInch(.01); row.BottomPadding = Unit.FromInch(0); for (int j = 0; j < grid.Columns.Count; j++) { cell = row.Cells[j + 1]; par = cell.AddParagraph(); if (grid.Rows[i].Cells[j].Bold == YN.Unknown) { isBold = grid.Rows[i].Bold; } else if (grid.Rows[i].Cells[j].Bold == YN.Yes) { isBold = true; } else // if(grid.Rows[i].Cells[j].Bold==YN.No){ { isBold = false; } if (grid.Rows[i].Cells[j].ColorText == System.Drawing.Color.Empty) { color = grid.Rows[i].ColorText; } else { color = grid.Rows[i].Cells[j].ColorText; } fontBody = CreateFont(8.5f, isBold, color); par.AddFormattedText(grid.Rows[i].Cells[j].Text, fontBody); if (grid.Columns[j].TextAlign == HorizontalAlignment.Center) { cell.Format.Alignment = ParagraphAlignment.Center; } if (grid.Columns[j].TextAlign == HorizontalAlignment.Left) { cell.Format.Alignment = ParagraphAlignment.Left; } if (grid.Columns[j].TextAlign == HorizontalAlignment.Right) { cell.Format.Alignment = ParagraphAlignment.Right; } cell.Borders.Color = new MigraDoc.DocumentObjectModel.Color(180, 180, 180); if (grid.Rows[i].ColorLborder != System.Drawing.Color.Empty) { cell.Borders.Bottom.Color = ConvertColor(grid.Rows[i].ColorLborder); } } if (grid.Rows[i].Note != null && grid.Rows[i].Note != "" && grid.NoteSpanStop > 0 && grid.NoteSpanStart < grid.Columns.Count) { row = table.AddRow(); row.TopPadding = Unit.FromInch(.01); row.BottomPadding = Unit.FromInch(0); cell = row.Cells[grid.NoteSpanStart + 1]; par = cell.AddParagraph(); par.AddFormattedText(grid.Rows[i].Note, fontBody); cell.Format.Alignment = ParagraphAlignment.Left; cell.Borders.Color = new MigraDoc.DocumentObjectModel.Color(180, 180, 180); cell.MergeRight = grid.Columns.Count - 1 - grid.NoteSpanStart; edgeRows++; } } table.SetEdge(1, 0, grid.Columns.Count, edgeRows, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black); section.Add(table); }
internal static XBrush FontColorToXBrush(Font font) { #if noCMYK return new XSolidBrush(XColor.FromArgb((int)font.Color.A, (int)font.Color.R, (int)font.Color.G, (int)font.Color.B)); #else return new XSolidBrush(ColorHelper.ToXColor(font.Color, font.Document.UseCmykColor)); #endif }
public static string CreatePDFFileFromTxtFile(string textfilefullpath, string playerName) { Document doc = new Document(); Section section = doc.AddSection(); section.PageSetup.TopMargin = 25; section.PageSetup.LeftMargin = 30; section.PageSetup.RightMargin = 30; section.PageSetup.BottomMargin = 25; MigraDoc.DocumentObjectModel.Font font = new MigraDoc.DocumentObjectModel.Font("Adobe Garamond Pro", 22); font.Bold = true; font.Italic = false; font.Underline = Underline.None; Paragraph paragraph = section.AddParagraph(); paragraph.AddFormattedText(playerName + "'s Stats up to Season " + ConfigFile.SEASON_LAST, font); paragraph.Format.Shading.Color = Colors.LightSteelBlue; paragraph.Format.Alignment = ParagraphAlignment.Center; Paragraph paragraph2 = section.AddParagraph(); paragraph2.AddFormattedText(" ", new MigraDoc.DocumentObjectModel.Font("Courier New", 24)); if (new FileInfo(Path.Combine(ConfigFile.DIRECTORY_OUTPUT.FullName, "chart.png")).Exists) { MigraDoc.DocumentObjectModel.Shapes.Image image = section.AddImage(Path.Combine(ConfigFile.DIRECTORY_OUTPUT.FullName, "chart.png")); image.Width = "18cm"; image.LockAspectRatio = true; image.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center; image.LineFormat.Visible = true; image.LineFormat.Width = 1; image.LineFormat.Color = Colors.LightGreen; } Paragraph paragraph3 = section.AddParagraph(); paragraph3.AddFormattedText(" ", new MigraDoc.DocumentObjectModel.Font("Courier New", 10)); if (new FileInfo(Path.Combine(ConfigFile.DIRECTORY_OUTPUT.FullName, "chart2.png")).Exists) { MigraDoc.DocumentObjectModel.Shapes.Image image = section.AddImage(Path.Combine(ConfigFile.DIRECTORY_OUTPUT.FullName, "chart2.png")); image.Width = "18cm"; image.LockAspectRatio = true; image.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center; image.LineFormat.Visible = true; image.LineFormat.Width = 1; image.LineFormat.Color = Colors.LightCoral; } Paragraph paragraph4 = section.AddParagraph(); paragraph4.AddFormattedText(" ", new MigraDoc.DocumentObjectModel.Font("Courier New", 10)); if (new FileInfo(Path.Combine(ConfigFile.DIRECTORY_OUTPUT.FullName, "chart3.png")).Exists) { MigraDoc.DocumentObjectModel.Shapes.Image image = section.AddImage(Path.Combine(ConfigFile.DIRECTORY_OUTPUT.FullName, "chart3.png")); image.Width = "18cm"; image.LockAspectRatio = true; image.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center; image.LineFormat.Visible = true; image.LineFormat.Width = 1; image.LineFormat.Color = Colors.LightBlue; } section.AddPageBreak(); //just font arrangements as you wish section = DataOps.PrintDataSeason(section, textfilefullpath); section.AddPageBreak(); section = DataOps.PrintDataByCategory(section, textfilefullpath); //add each line to pdf //foreach (string line in textFileLines) //{ // MigraDoc.DocumentObjectModel.Font font = new MigraDoc.DocumentObjectModel.Font("Courier New", 10); // font.Bold = true; // Paragraph paragraph = section.AddParagraph(); // paragraph.AddFormattedText(line, font); //} //save pdf document PdfDocumentRenderer renderer = new PdfDocumentRenderer(); renderer.Document = doc; renderer.RenderDocument(); FileInfo fileName = new FileInfo(Path.Combine(ConfigFile.DIRECTORY_OUTPUT.FullName, playerName + "_" + ConfigFile.SEASON_LAST.ToString() + ".pdf")); FileOps.CheckFile(fileName, true); renderer.Save(fileName.FullName); //if(fileName.Exists) // Process.Start(fileName.FullName); return(fileName.FullName); }
/// <summary> /// Adds a new FormattedText with the given Font. /// </summary> public FormattedText AddFormattedText(Font font) { return this.Elements.AddFormattedText(font); }
private static void AddRoleHeader(Table table, string headingType, bool includeSite) { var font = new Font("Arial", 8); var rowHeader = table.AddRow(); rowHeader.HeadingFormat = true; rowHeader.Format.Font.ApplyFont(font); rowHeader.Shading.Color = Colors.PaleGoldenrod; rowHeader.Format.Font.Bold = true; var cellHeader = rowHeader.Cells[0]; cellHeader.AddParagraph(headingType); cellHeader.MergeRight = includeSite ? 6 : 5; }
///<summary>Supply pd so that we know the paper size and margins.</summary> private MigraDoc.DocumentObjectModel.Document CreateDocument(PrintDocument pd,Family fam,Patient pat,DataSet dataSet){ MigraDoc.DocumentObjectModel.Document doc= new MigraDoc.DocumentObjectModel.Document(); if(Plugins.HookMethod(this,"FormRpStatement.CreateDocument",doc,pd,fam,pat,dataSet,Stmt)) { return doc; } doc.DefaultPageSetup.PageWidth=Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Width/100); doc.DefaultPageSetup.PageHeight=Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Height/100); doc.DefaultPageSetup.TopMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Top/100); doc.DefaultPageSetup.LeftMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Left/100); doc.DefaultPageSetup.RightMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Right/100); doc.DefaultPageSetup.BottomMargin=Unit.FromInch((double)pd.DefaultPageSettings.Margins.Bottom/100); MigraDoc.DocumentObjectModel.Section section=doc.AddSection();//so that Swiss will have different footer for each patient. string text; MigraDoc.DocumentObjectModel.Font font; //GetPatGuar(PatNums[famIndex][0]); //Family fam=Patients.GetFamily(Stmt.PatNum); Patient PatGuar=fam.ListPats[0];//.Clone(); //Patient pat=fam.GetPatient(Stmt.PatNum); DataTable tableMisc=dataSet.Tables["misc"]; //HEADING------------------------------------------------------------------------------ #region Heading Paragraph par=section.AddParagraph(); ParagraphFormat parformat=new ParagraphFormat(); parformat.Alignment=ParagraphAlignment.Center; par.Format=parformat; font=MigraDocHelper.CreateFont(14,true); if(Stmt.IsInvoice) { if(CultureInfo.CurrentCulture.Name=="en-NZ" || CultureInfo.CurrentCulture.Name=="en-AU") {//New Zealand and Australia text=Lan.g(this,"TAX INVOICE"); } else { text=Lan.g(this,"INVOICE"); text+=" #"+Stmt.StatementNum.ToString();//Some larger customers of OD need this to show in order to properly pay. } } else if(Stmt.IsReceipt) { text=Lan.g(this,"RECEIPT"); if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore text+=" #"+Stmt.StatementNum.ToString(); } } else { text=Lan.g(this,"STATEMENT"); } par.AddFormattedText(text,font); text=DateTime.Today.ToShortDateString(); font=MigraDocHelper.CreateFont(10); par.AddLineBreak(); par.AddFormattedText(text,font); text=Lan.g(this,"Account Number")+" "; if(PrefC.GetBool(PrefName.StatementAccountsUseChartNumber)) { text+=PatGuar.ChartNumber; } else { text+=PatGuar.PatNum; } par.AddLineBreak(); par.AddFormattedText(text,font); TextFrame frame; #endregion Heading //"COPY" for foreign countries' TAX INVOICES---------------------------------------------- #region Tax Invoice Copy if(Stmt.IsInvoiceCopy && CultureInfo.CurrentCulture.Name!="en-US") {//We don't show this for US. font=MigraDocHelper.CreateFont(28,true,System.Drawing.Color.Red); frame=section.AddTextFrame(); frame.RelativeVertical=RelativeVertical.Page; frame.RelativeHorizontal=RelativeHorizontal.Page; frame.MarginLeft=Unit.Zero; frame.MarginTop=Unit.Zero; frame.Top=TopPosition.Parse("0.35 in"); frame.Left=LeftPosition.Parse("5.4 in"); frame.Width=Unit.FromInch(3); par=frame.AddParagraph(); par.Format.Font=font; par.AddText("COPY"); } #endregion Tax Invoice Copy //Practice Address---------------------------------------------------------------------- #region Practice Address if(PrefC.GetBool(PrefName.StatementShowReturnAddress)) { font=MigraDocHelper.CreateFont(10); frame=section.AddTextFrame(); frame.RelativeVertical=RelativeVertical.Page; frame.RelativeHorizontal=RelativeHorizontal.Page; frame.MarginLeft=Unit.Zero; frame.MarginTop=Unit.Zero; frame.Top=TopPosition.Parse("0.5 in"); frame.Left=LeftPosition.Parse("0.3 in"); frame.Width=Unit.FromInch(3); if(!PrefC.GetBool(PrefName.EasyNoClinics) && Clinics.List.Length>0 //if using clinics && Clinics.GetClinic(PatGuar.ClinicNum)!=null)//and this patient assigned to a clinic { Clinic clinic=Clinics.GetClinic(PatGuar.ClinicNum); par=frame.AddParagraph(); par.Format.Font=font; par.AddText(clinic.Description); par.AddLineBreak(); if(CultureInfo.CurrentCulture.Name=="en-AU") {//Australia Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)); par.AddText("ABN: "+defaultProv.NationalProvID); par.AddLineBreak(); } if(CultureInfo.CurrentCulture.Name=="en-NZ") {//New Zealand Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)); par.AddText("GST: "+defaultProv.SSN); par.AddLineBreak(); } par.AddText(clinic.Address); par.AddLineBreak(); if(clinic.Address2!="") { par.AddText(clinic.Address2); par.AddLineBreak(); } if(CultureInfo.CurrentCulture.Name.EndsWith("CH")) {//CH is for switzerland. eg de-CH par.AddText(clinic.Zip+" "+clinic.City); } else if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore par.AddText(clinic.City+" "+clinic.Zip); } else { par.AddText(clinic.City+", "+clinic.State+" "+clinic.Zip); } par.AddLineBreak(); text=clinic.Phone; if(text.Length==10){ text="("+text.Substring(0,3)+")"+text.Substring(3,3)+"-"+text.Substring(6); } par.AddText(text); par.AddLineBreak(); } else { par=frame.AddParagraph(); par.Format.Font=font; par.AddText(PrefC.GetString(PrefName.PracticeTitle)); par.AddLineBreak(); if(CultureInfo.CurrentCulture.Name=="en-AU"){//Australia Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)); par.AddText("ABN: "+defaultProv.NationalProvID); par.AddLineBreak(); } if(CultureInfo.CurrentCulture.Name=="en-NZ") {//New Zealand Provider defaultProv=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)); par.AddText("GST: "+defaultProv.SSN); par.AddLineBreak(); } par.AddText(PrefC.GetString(PrefName.PracticeAddress)); par.AddLineBreak(); if(PrefC.GetString(PrefName.PracticeAddress2)!="") { par.AddText(PrefC.GetString(PrefName.PracticeAddress2)); par.AddLineBreak(); } if(CultureInfo.CurrentCulture.Name.EndsWith("CH")) {//CH is for switzerland. eg de-CH par.AddText(PrefC.GetString(PrefName.PracticeZip)+" "+PrefC.GetString(PrefName.PracticeCity)); } else if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore par.AddText(PrefC.GetString(PrefName.PracticeCity)+" "+PrefC.GetString(PrefName.PracticeZip)); } else { par.AddText(PrefC.GetString(PrefName.PracticeCity)+", "+PrefC.GetString(PrefName.PracticeST)+" "+PrefC.GetString(PrefName.PracticeZip)); } par.AddLineBreak(); text=PrefC.GetString(PrefName.PracticePhone); if(text.Length==10){ text="("+text.Substring(0,3)+")"+text.Substring(3,3)+"-"+text.Substring(6); } par.AddText(text); par.AddLineBreak(); } } #endregion //AMOUNT ENCLOSED------------------------------------------------------------------------------------------------------ #region Amount Enclosed Table table; Column col; Row row; Cell cell; frame=MigraDocHelper.CreateContainer(section,450,110,330,29); if(!Stmt.HidePayment) { table=MigraDocHelper.DrawTable(frame,0,0,29); col=table.AddColumn(Unit.FromInch(1.1)); col=table.AddColumn(Unit.FromInch(1.1)); col=table.AddColumn(Unit.FromInch(1.1)); row=table.AddRow(); row.Format.Alignment=ParagraphAlignment.Center; row.Borders.Color=Colors.Black; row.Shading.Color=Colors.LightGray; row.TopPadding=Unit.FromInch(0); row.BottomPadding=Unit.FromInch(0); font=MigraDocHelper.CreateFont(8,true); cell=row.Cells[0]; par=cell.AddParagraph(); par.AddFormattedText(Lan.g(this,"Amount Due"),font); cell=row.Cells[1]; par=cell.AddParagraph(); par.AddFormattedText(Lan.g(this,"Date Due"),font); cell=row.Cells[2]; par=cell.AddParagraph(); par.AddFormattedText(Lan.g(this,"Amount Enclosed"),font); row=table.AddRow(); row.Format.Alignment=ParagraphAlignment.Center; row.Borders.Left.Color=Colors.Gray; row.Borders.Bottom.Color=Colors.Gray; row.Borders.Right.Color=Colors.Gray; font=MigraDocHelper.CreateFont(9); double balTotal=PatGuar.BalTotal; if(!PrefC.GetBool(PrefName.BalancesDontSubtractIns)) {//this is typical balTotal-=PatGuar.InsEst; } for(int m=0;m<tableMisc.Rows.Count;m++){ if(tableMisc.Rows[m]["descript"].ToString()=="payPlanDue"){ balTotal+=PIn.Double(tableMisc.Rows[m]["value"].ToString()); //payPlanDue;//PatGuar.PayPlanDue; } } InstallmentPlan installPlan=InstallmentPlans.GetOneForFam(PatGuar.PatNum); if(installPlan!=null){ //show lesser of normal total balance or the monthly payment amount. if(installPlan.MonthlyPayment < balTotal) { text=installPlan.MonthlyPayment.ToString("F"); } else { text=balTotal.ToString("F"); } } else {//no installmentplan text=balTotal.ToString("F"); } cell=row.Cells[0]; par=cell.AddParagraph(); par.AddFormattedText(text,font); if(PrefC.GetLong(PrefName.StatementsCalcDueDate)==-1) { text=Lan.g(this,"Upon Receipt"); } else { text=DateTime.Today.AddDays(PrefC.GetLong(PrefName.StatementsCalcDueDate)).ToShortDateString(); } cell=row.Cells[1]; par=cell.AddParagraph(); par.AddFormattedText(text,font); } #endregion //Credit Card Info-------------------------------------------------------------------------------------------------------- #region Credit Card Info if(!Stmt.HidePayment) { if(PrefC.GetBool(PrefName.StatementShowCreditCard)) { float yPos=60; font=MigraDocHelper.CreateFont(7,true); text=Lan.g(this,"CREDIT CARD TYPE"); MigraDocHelper.DrawString(frame,text,font,0,yPos); float rowHeight=26; System.Drawing.Font wfont=new System.Drawing.Font("Arial",7,FontStyle.Bold); Graphics g=this.CreateGraphics();//just to measure strings MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width, yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g)); yPos+=rowHeight; text=Lan.g(this,"#"); MigraDocHelper.DrawString(frame,text,font,0,yPos); MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width, yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g)); yPos+=rowHeight; text=Lan.g(this,"3 DIGIT CSV"); MigraDocHelper.DrawString(frame,text,font,0,yPos); MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width, yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g)); yPos+=rowHeight; text=Lan.g(this,"EXPIRES"); MigraDocHelper.DrawString(frame,text,font,0,yPos); MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width, yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g)); yPos+=rowHeight; text=Lan.g(this,"AMOUNT APPROVED"); MigraDocHelper.DrawString(frame,text,font,0,yPos); MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width, yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g)); yPos+=rowHeight; text=Lan.g(this,"NAME"); MigraDocHelper.DrawString(frame,text,font,0,yPos); MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width, yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g)); yPos+=rowHeight; text=Lan.g(this,"SIGNATURE"); MigraDocHelper.DrawString(frame,text,font,0,yPos); MigraDocHelper.DrawLine(frame,System.Drawing.Color.Black,g.MeasureString(text,wfont).Width, yPos+wfont.GetHeight(g),326,yPos+wfont.GetHeight(g)); yPos-=rowHeight; text=Lan.g(this,"(As it appears on card)"); wfont=new System.Drawing.Font("Arial",5); font=MigraDocHelper.CreateFont(5); MigraDocHelper.DrawString(frame,text,font,625-g.MeasureString(text,wfont).Width/2+5,yPos+13); } } #endregion //Patient's Billing Address--------------------------------------------------------------------------------------------- #region Patient Billing Address font=MigraDocHelper.CreateFont(11); frame=MigraDocHelper.CreateContainer(section,62.5f+12.5f,225+1,300,200); par=frame.AddParagraph(); par.Format.Font=font; if(Stmt.SinglePatient){ par.AddText(fam.GetNameInFamFLnoPref(Stmt.PatNum)); } else{ par.AddText(PatGuar.GetNameFLFormal()); } par.AddLineBreak(); par.AddText(PatGuar.Address); par.AddLineBreak(); if(PatGuar.Address2!="") { par.AddText(PatGuar.Address2); par.AddLineBreak(); } if(CultureInfo.CurrentCulture.Name.EndsWith("CH")) {//CH is for switzerland. eg de-CH par.AddText(PatGuar.Zip+" "+PatGuar.City); } else if(CultureInfo.CurrentCulture.Name.EndsWith("SG")) {//SG=Singapore par.AddText(PatGuar.City+" "+PatGuar.Zip); } else { par.AddText(PatGuar.City+", "+PatGuar.State+" "+PatGuar.Zip); } if(PatGuar.Country!="") { par.AddLineBreak(); par.AddText(PatGuar.Country); } //perforated line------------------------------------------------------------------------------------------------------ //yPos=350;//3.62 inches from top, 1/3 page down frame=MigraDocHelper.CreateContainer(section,0,350,850,30); if(!Stmt.HidePayment) { MigraDocHelper.DrawLine(frame,System.Drawing.Color.LightGray,0,0,850,0); text=Lan.g(this,"PLEASE DETACH AND RETURN THE UPPER PORTION WITH YOUR PAYMENT"); font=MigraDocHelper.CreateFont(6,true,System.Drawing.Color.Gray); par=frame.AddParagraph(); par.Format.Alignment=ParagraphAlignment.Center; par.Format.Font=font; par.AddText(text); } #endregion //Australian Provider Legend #region Australian Provider Legend int legendOffset=0; if(CultureInfo.CurrentCulture.Name=="en-AU") {//English (Australia) Providers.RefreshCache(); legendOffset=25+15*(1+ProviderC.ListShort.Count); MigraDocHelper.InsertSpacer(section,legendOffset); frame=MigraDocHelper.CreateContainer(section,45,390,250,legendOffset); par=frame.AddParagraph(); par.Format.Font=MigraDocHelper.CreateFont(8,true); par.AddLineBreak(); par.AddText("PROVIDERS:"); par=frame.AddParagraph(); par.Format.Font=MigraDocHelper.CreateFont(8,false); for(int i=0;i<ProviderC.ListShort.Count;i++) {//All non-hidden providers are added to the legend. Provider prov=ProviderC.ListShort[i]; string suffix=""; if(prov.Suffix.Trim()!=""){ suffix=", "+prov.Suffix.Trim(); } par.AddText(prov.Abbr+" - "+prov.FName+" "+prov.LName+suffix+" - "+prov.MedicaidID); par.AddLineBreak(); } par.AddLineBreak(); } #endregion //Aging----------------------------------------------------------------------------------- #region Aging MigraDocHelper.InsertSpacer(section,275); frame=MigraDocHelper.CreateContainer(section,55,390+legendOffset,250,29); if (!Stmt.HidePayment) { table = MigraDocHelper.DrawTable(frame, 0, 0, 29); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); col = table.AddColumn(Unit.FromInch(1.1)); row = table.AddRow(); row.Format.Alignment = ParagraphAlignment.Center; row.Borders.Color = Colors.Black; row.Shading.Color = Colors.LightGray; row.TopPadding = Unit.FromInch(0); row.BottomPadding = Unit.FromInch(0); font = MigraDocHelper.CreateFont(8, true); cell = row.Cells[0]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g(this, "0-30"), font); cell = row.Cells[1]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g(this, "31-60"), font); cell = row.Cells[2]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g(this, "61-90"), font); cell = row.Cells[3]; par = cell.AddParagraph(); par.AddFormattedText(Lan.g(this, "over 90"), font); row = table.AddRow(); row.Format.Alignment = ParagraphAlignment.Center; row.Borders.Left.Color = Colors.Gray; row.Borders.Bottom.Color = Colors.Gray; row.Borders.Right.Color = Colors.Gray; font = MigraDocHelper.CreateFont(9); text= PatGuar.Bal_0_30.ToString("F"); cell = row.Cells[0]; par = cell.AddParagraph(); par.AddFormattedText(text, font); text = PatGuar.Bal_31_60.ToString("F"); cell = row.Cells[1]; par = cell.AddParagraph(); par.AddFormattedText(text, font); text = PatGuar.Bal_61_90.ToString("F"); cell = row.Cells[2]; par = cell.AddParagraph(); par.AddFormattedText(text, font); text = PatGuar.BalOver90.ToString("F"); cell = row.Cells[3]; par = cell.AddParagraph(); par.AddFormattedText(text, font); } /* ODGridColumn gcol; ODGridRow grow; if(!Stmt.HidePayment) { ODGrid gridAging=new ODGrid(); this.Controls.Add(gridAging); gridAging.BeginUpdate(); gridAging.Columns.Clear(); gcol=new ODGridColumn(Lan.g(this,"0-30"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"31-60"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"61-90"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"over 90"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); if(PrefC.GetBool(PrefName.BalancesDontSubtractIns")) {//less common gcol=new ODGridColumn(Lan.g(this,"Balance"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"InsPending"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"AfterIns"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); } else{//more common gcol=new ODGridColumn(Lan.g(this,"Total"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"- InsEst"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"= Balance"),70,HorizontalAlignment.Center); gridAging.Columns.Add(gcol); } gridAging.Rows.Clear(); //Annual max-------------------------- grow=new ODGridRow(); grow.Cells.Add(PatGuar.Bal_0_30.ToString("F")); grow.Cells.Add(PatGuar.Bal_31_60.ToString("F")); grow.Cells.Add(PatGuar.Bal_61_90.ToString("F")); grow.Cells.Add(PatGuar.BalOver90.ToString("F")); grow.Cells.Add(PatGuar.BalTotal.ToString("F")); grow.Cells.Add(PatGuar.InsEst.ToString("F")); grow.Cells.Add((PatGuar.BalTotal-PatGuar.InsEst).ToString("F")); gridAging.Rows.Add(grow); gridAging.EndUpdate(); MigraDocHelper.DrawGrid(section,gridAging); gridAging.Dispose(); */ #endregion //Floating Balance, Ins info------------------------------------------------------------------- #region FloatingBalance frame=MigraDocHelper.CreateContainer(section,460,380+legendOffset,250,200); //table=MigraDocHelper.DrawTable(frame,0,0,90); par = frame.AddParagraph(); parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Right; par.Format = parformat; font = MigraDocHelper.CreateFont(10,false); MigraDoc.DocumentObjectModel.Font fontBold=MigraDocHelper.CreateFont(10, true); if(Stmt.IsInvoice) { text=Lan.g(this,"Procedures:"); par.AddFormattedText(text,font); par.AddLineBreak(); text=Lan.g(this,"Adjustments:"); par.AddFormattedText(text,font); par.AddLineBreak(); text=Lan.g(this,"Total:"); par.AddFormattedText(text,font); par.AddLineBreak(); } else if(PrefC.GetBool(PrefName.BalancesDontSubtractIns)){ text = Lan.g(this, "Balance:"); par.AddFormattedText(text, fontBold); //par.AddLineBreak(); //text = Lan.g(this, "Ins Pending:"); //par.AddFormattedText(text, font); //par.AddLineBreak(); //text = Lan.g(this, "After Ins:"); //par.AddFormattedText(text, font); //par.AddLineBreak(); } else{//this is more common if (PrefC.GetBool(PrefName.FuchsOptionsOn)) { text = Lan.g(this, "Balance:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g(this, "-Ins Estimate:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g(this, "=Owed Now:"); par.AddFormattedText(text, fontBold); par.AddLineBreak(); } else { text = Lan.g(this, "Total:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g(this, "-Ins Estimate:"); par.AddFormattedText(text, font); par.AddLineBreak(); text = Lan.g(this, "=Balance:"); par.AddFormattedText(text, fontBold); par.AddLineBreak(); } } frame=MigraDocHelper.CreateContainer(section,730,380+legendOffset,100,200); //table=MigraDocHelper.DrawTable(frame,0,0,90); par = frame.AddParagraph(); parformat = new ParagraphFormat(); parformat.Alignment = ParagraphAlignment.Left; par.Format = parformat; font = MigraDocHelper.CreateFont(10,false); //numbers: if(Stmt.IsInvoice) { double adjAmt=0; double procAmt=0; DataTable tableAcct; string tableName; for(int i=0;i<dataSet.Tables.Count;i++) { tableAcct=dataSet.Tables[i]; tableName=tableAcct.TableName; if(!tableName.StartsWith("account")) { continue; } for(int p=0;p<tableAcct.Rows.Count;p++) { if(tableAcct.Rows[p]["AdjNum"].ToString()!="0") { adjAmt-=PIn.Double(tableAcct.Rows[p]["creditsDouble"].ToString()); adjAmt+=PIn.Double(tableAcct.Rows[p]["chargesDouble"].ToString()); } else {//must be a procedure procAmt+=PIn.Double(tableAcct.Rows[p]["chargesDouble"].ToString()); } } } text=procAmt.ToString("c"); par.AddFormattedText(text,font); par.AddLineBreak(); text=adjAmt.ToString("c"); par.AddFormattedText(text,font); par.AddLineBreak(); text=(procAmt+adjAmt).ToString("c"); par.AddFormattedText(text,fontBold); } else if(PrefC.GetBool(PrefName.BalancesDontSubtractIns)) { if(Stmt.SinglePatient) { //Show the current patient's balance without subtracting insurance estimates. text = pat.EstBalance.ToString("c"); par.AddFormattedText(text,font); } else { //Show the current family's balance without subtracting insurance estimates. text = PatGuar.BalTotal.ToString("c"); par.AddFormattedText(text,fontBold); } } else {//more common if(Stmt.SinglePatient) { double patInsEst=0; for(int m=0;m<tableMisc.Rows.Count;m++) { if(tableMisc.Rows[m]["descript"].ToString()=="patInsEst") { patInsEst=PIn.Double(tableMisc.Rows[m]["value"].ToString()); } } double patBal=pat.EstBalance-patInsEst; text = pat.EstBalance.ToString("c"); par.AddFormattedText(text,font); par.AddLineBreak(); text = patInsEst.ToString("c"); par.AddFormattedText(text,font); par.AddLineBreak(); text = patBal.ToString("c"); par.AddFormattedText(text,fontBold); } else { text = PatGuar.BalTotal.ToString("c"); par.AddFormattedText(text,font); par.AddLineBreak(); text = PatGuar.InsEst.ToString("c"); par.AddFormattedText(text,font); par.AddLineBreak(); text = (PatGuar.BalTotal - PatGuar.InsEst).ToString("c"); par.AddFormattedText(text,fontBold); par.AddLineBreak(); } } MigraDocHelper.InsertSpacer(section, 80); #endregion FloatingBalance //Bold note------------------------------------------------------------------------------- #region Bold note if(Stmt.NoteBold!=""){ MigraDocHelper.InsertSpacer(section,7); font=MigraDocHelper.CreateFont(10,true,System.Drawing.Color.DarkRed); par=section.AddParagraph(); par.Format.Font=font; par.AddText(Stmt.NoteBold); MigraDocHelper.InsertSpacer(section,8); } #endregion Bold note //Payment plan grid definition--------------------------------------------------------------------------------- #region PayPlan grid definition ODGridColumn gcol; ODGridRow grow; ODGrid gridPP = new ODGrid(); this.Controls.Add(gridPP); gridPP.BeginUpdate(); gridPP.Columns.Clear(); gcol=new ODGridColumn(Lan.g(this,"Date"),73); gridPP.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Description"),270); gridPP.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Charges"),60,HorizontalAlignment.Right); gridPP.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Credits"),60,HorizontalAlignment.Right); gridPP.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Balance"),60,HorizontalAlignment.Right); gridPP.Columns.Add(gcol); gridPP.Width=gridPP.WidthAllColumns+20; gridPP.EndUpdate(); #endregion PayPlan grid definition //Payment plan grid. There will be only one, if any----------------------------------------------------------------- #region PayPlan grid DataTable tablePP=dataSet.Tables["payplan"]; ODGridCell gcell; if(tablePP.Rows.Count>0){ //MigraDocHelper.InsertSpacer(section,5); par=section.AddParagraph(); par.Format.Font=MigraDocHelper.CreateFont(10,true); par.Format.Alignment=ParagraphAlignment.Center; //par.Format.SpaceBefore=Unit.FromInch(.05); //par.Format.SpaceAfter=Unit.FromInch(.05); par.AddText(Lan.g(this,"Payment Plans")); MigraDocHelper.InsertSpacer(section,2); gridPP.BeginUpdate(); gridPP.Rows.Clear(); for(int p=0;p<tablePP.Rows.Count;p++){ grow=new ODGridRow(); grow.Cells.Add(tablePP.Rows[p]["date"].ToString()); grow.Cells.Add(tablePP.Rows[p]["description"].ToString()); grow.Cells.Add(tablePP.Rows[p]["charges"].ToString()); grow.Cells.Add(tablePP.Rows[p]["credits"].ToString()); gcell=new ODGridCell(tablePP.Rows[p]["balance"].ToString()); if(p==tablePP.Rows.Count-1){ gcell.Bold=YN.Yes; } else if(tablePP.Rows[p+1]["balance"].ToString()==""){//if next row balance is blank. gcell.Bold=YN.Yes; } grow.Cells.Add(gcell); gridPP.Rows.Add(grow); } gridPP.EndUpdate(); MigraDocHelper.DrawGrid(section,gridPP); MigraDocHelper.InsertSpacer(section,2); par=section.AddParagraph(); par.Format.Font=MigraDocHelper.CreateFont(10,true); par.Format.Alignment=ParagraphAlignment.Right; par.Format.RightIndent=Unit.FromInch(0.25); double payPlanDue=0; for(int m=0;m<tableMisc.Rows.Count;m++){ if(tableMisc.Rows[m]["descript"].ToString()=="payPlanDue"){ payPlanDue=PIn.Double(tableMisc.Rows[m]["value"].ToString()); } } par.AddText(Lan.g(this,"Payment Plan Amount Due: ")+payPlanDue.ToString("c"));//PatGuar.PayPlanDue.ToString("c")); MigraDocHelper.InsertSpacer(section,10); } #endregion PayPlan grid //Body Table definition-------------------------------------------------------------------------------------------------------- #region Body Table definition ODGrid gridPat = new ODGrid(); this.Controls.Add(gridPat); gridPat.BeginUpdate(); gridPat.Columns.Clear(); gcol=new ODGridColumn(Lan.g(this,"Date"),73); gridPat.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Patient"),100); gridPat.Columns.Add(gcol); //prov gcol=new ODGridColumn(Lan.g(this,"Code"),45); gridPat.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Tooth"),42); gridPat.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Description"),270); gridPat.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Charges"),60,HorizontalAlignment.Right); gridPat.Columns.Add(gcol); gcol=new ODGridColumn(Lan.g(this,"Credits"),60,HorizontalAlignment.Right); gridPat.Columns.Add(gcol); if(Stmt.IsInvoice) { gcol=new ODGridColumn(Lan.g(this,"Total"),60,HorizontalAlignment.Right); gridPat.Columns.Add(gcol); } else { gcol=new ODGridColumn(Lan.g(this,"Balance"),60,HorizontalAlignment.Right); gridPat.Columns.Add(gcol); } gridPat.Width=gridPat.WidthAllColumns+20; gridPat.EndUpdate(); #endregion Body Table definition //Loop through each table. Could be one intermingled, or one for each patient----------------------------------------- DataTable tableAccount; string tablename; long patnum; for(int i=0;i<dataSet.Tables.Count;i++){ tableAccount=dataSet.Tables[i]; tablename=tableAccount.TableName; if(!tablename.StartsWith("account")){ continue; } par=section.AddParagraph(); par.Format.Font=MigraDocHelper.CreateFont(10,true); par.Format.SpaceBefore=Unit.FromInch(.05); par.Format.SpaceAfter=Unit.FromInch(.05); patnum=0; if(tablename!="account"){//account123 etc. patnum=PIn.Long(tablename.Substring(7)); } if(patnum!=0){ par.AddText(fam.GetNameInFamFLnoPref(patnum)); } //if(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript!=""){ // par=section.AddParagraph(); // par.Format.Font=MigraDocHelper.CreateFont(9);//same as body font // par.AddText(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript); //} gridPat.BeginUpdate(); gridPat.Rows.Clear(); //lineData=FamilyStatementDataList[famIndex].PatDataList[i].PatData; for(int p=0;p<tableAccount.Rows.Count;p++) { if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA if(Stmt.IsReceipt) { if(tableAccount.Rows[p]["StatementNum"].ToString()!="0") {//Hide statement rows for Canadian receipts. continue; } if(tableAccount.Rows[p]["ClaimNum"].ToString()!="0") {//Hide claim rows and claim payment rows for Canadian receipts. continue; } } } if(CultureInfo.CurrentCulture.Name=="en-US") { if(Stmt.IsReceipt) { if(tableAccount.Rows[p]["PayNum"].ToString()=="0") {//Hide everything except patient payments continue; } } //js Some additional features would be nice for receipts, such as hiding the bal column, the aging, and the amount due sections. } grow=new ODGridRow(); grow.Cells.Add(tableAccount.Rows[p]["date"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["patient"].ToString()); if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA if(Stmt.IsReceipt) { grow.Cells.Add("");//Code: blank in Canada normally because this information is used on taxes and is considered a security concern. grow.Cells.Add("");//Tooth: blank in Canada normally because this information is used on taxes and is considered a security concern. } else { grow.Cells.Add(tableAccount.Rows[p]["ProcCode"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["tth"].ToString()); } } else { grow.Cells.Add(tableAccount.Rows[p]["ProcCode"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["tth"].ToString()); } if(CultureInfo.CurrentCulture.Name=="en-AU") {//English (Australia) if(tableAccount.Rows[p]["prov"].ToString().Trim()!="") { grow.Cells.Add(tableAccount.Rows[p]["prov"].ToString()+" - "+tableAccount.Rows[p]["description"].ToString()); } else {//No provider on this account row item, so don't put the extra leading characters. grow.Cells.Add(tableAccount.Rows[p]["description"].ToString()); } } else if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA if(Stmt.IsReceipt) { if(PIn.Long(tableAccount.Rows[p]["ProcNum"].ToString())==0) { grow.Cells.Add(tableAccount.Rows[p]["description"].ToString()); } else {//Only clear description for procedures. grow.Cells.Add("");//Description: blank in Canada normally because this information is used on taxes and is considered a security concern. } } else { grow.Cells.Add(tableAccount.Rows[p]["description"].ToString()); } } else {//Assume English (United States) grow.Cells.Add(tableAccount.Rows[p]["description"].ToString()); } grow.Cells.Add(tableAccount.Rows[p]["charges"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["credits"].ToString()); grow.Cells.Add(tableAccount.Rows[p]["balance"].ToString()); gridPat.Rows.Add(grow); } gridPat.EndUpdate(); MigraDocHelper.DrawGrid(section,gridPat); //Total frame=MigraDocHelper.CreateContainer(section); font=MigraDocHelper.CreateFont(9,true); float totalPos=((float)(doc.DefaultPageSetup.PageWidth.Inch//-doc.DefaultPageSetup.LeftMargin.Inch //-doc.DefaultPageSetup.RightMargin.Inch) )*100f)/2f+(float)gridPat.WidthAllColumns/2f+7; RectangleF rectF=new RectangleF(0,0,totalPos,16); if(patnum!=0){ MigraDocHelper.DrawString(frame," ", //I decided this was unnecessary: //dataSet.Tables["patient"].Rows[fam.GetIndex(patnum)]["balance"].ToString(), font,rectF,ParagraphAlignment.Right); //MigraDocHelper.DrawString(frame,FamilyStatementDataList[famIndex].PatAboutList[i].Balance.ToString("F"),font,rectF, // ParagraphAlignment.Right); } } gridPat.Dispose(); //Future appointments--------------------------------------------------------------------------------------------- #region Future appointments if(!Stmt.IsReceipt && !Stmt.IsInvoice) { font=MigraDocHelper.CreateFont(9); DataTable tableAppt=dataSet.Tables["appts"]; if(tableAppt.Rows.Count>0) { par=section.AddParagraph(); par.Format.Font=font; par.AddText(Lan.g(this,"Scheduled Appointments:")); } for(int i=0;i<tableAppt.Rows.Count;i++) { par.AddLineBreak(); par.AddText(tableAppt.Rows[i]["descript"].ToString()); } if(tableAppt.Rows.Count>0) { MigraDocHelper.InsertSpacer(section,10); } } #endregion Future appointments //Region specific static notes------------------------------------------------------------------------------------ if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA if(Stmt.IsReceipt) { font=MigraDocHelper.CreateFont(9); par=section.AddParagraph(); par.Format.Font=font; par.AddText("KEEP THIS RECEIPT FOR INCOME TAX PURPOSES"); MigraDocHelper.InsertSpacer(section,10); } } //Note------------------------------------------------------------------------------------------------------------ font=MigraDocHelper.CreateFont(9); par=section.AddParagraph(); par.Format.Font=font; par.AddText(Stmt.Note); //bold note if(Stmt.NoteBold!=""){ MigraDocHelper.InsertSpacer(section,10); font=MigraDocHelper.CreateFont(10,true,System.Drawing.Color.DarkRed); par=section.AddParagraph(); par.Format.Font=font; par.AddText(Stmt.NoteBold); } #region SwissBanking if(CultureInfo.CurrentCulture.Name.EndsWith("CH")){//CH is for switzerland. eg de-CH //&& pagesPrinted==0)//only on the first page //{ //float yred=744;//768;//660 for testing //Red line (just temp) //g.DrawLine(Pens.Red,0,yred,826,yred); MigraDoc.DocumentObjectModel.Font swfont=MigraDocHelper.CreateFont(10); //new Font(FontFamily.GenericSansSerif,10); //Bank Address--------------------------------------------------------- HeaderFooter footer=section.Footers.Primary; footer.Format.Borders.Color=Colors.Black; //footer.AddParagraph(PrefC.GetString(PrefName.BankAddress")); frame=footer.AddTextFrame(); frame.RelativeVertical=RelativeVertical.Line; frame.RelativeHorizontal=RelativeHorizontal.Page; frame.MarginLeft=Unit.Zero; frame.MarginTop=Unit.Zero; frame.Top=TopPosition.Parse("0 in"); frame.Left=LeftPosition.Parse("0 in"); frame.Width=Unit.FromInch(8.3); frame.Height=300; //RectangleF=new RectangleF(0,0, MigraDocHelper.DrawString(frame,PrefC.GetString(PrefName.BankAddress),swfont,30,30); MigraDocHelper.DrawString(frame,PrefC.GetString(PrefName.BankAddress),swfont,246,30); //Office Name and Address---------------------------------------------- text=PrefC.GetString(PrefName.PracticeTitle)+"\r\n" +PrefC.GetString(PrefName.PracticeAddress)+"\r\n"; if(PrefC.GetString(PrefName.PracticeAddress2)!="") { text+=PrefC.GetString(PrefName.PracticeAddress2)+"\r\n"; } text+=PrefC.GetString(PrefName.PracticeZip)+" "+PrefC.GetString(PrefName.PracticeCity); MigraDocHelper.DrawString(frame,text,swfont,30,89); MigraDocHelper.DrawString(frame,text,swfont,246,89); //Bank account number-------------------------------------------------- string origBankNum=PrefC.GetString(PrefName.PracticeBankNumber);//must be exactly 9 digits. 2+6+1. //the 6 digit portion might have 2 leading 0's which would not go into the dashed bank num. string dashedBankNum="?"; //examples: 01-200027-2 // 01-4587-1 (from 010045871) if(origBankNum.Length==9) { dashedBankNum=origBankNum.Substring(0,2)+"-" +origBankNum.Substring(2,6).TrimStart(new char[] { '0' })+"-" +origBankNum.Substring(8,1); } swfont=MigraDocHelper.CreateFont(9,true); //new Font(FontFamily.GenericSansSerif,9,FontStyle.Bold); MigraDocHelper.DrawString(frame,dashedBankNum,swfont,95,169); MigraDocHelper.DrawString(frame,dashedBankNum,swfont,340,169); //Amount------------------------------------------------------------ double amountdue=PatGuar.BalTotal-PatGuar.InsEst; text=amountdue.ToString("F2"); text=text.Substring(0,text.Length-3); swfont=MigraDocHelper.CreateFont(10); MigraDocHelper.DrawString(frame,text,swfont,new RectangleF(50,205,100,25),ParagraphAlignment.Right); MigraDocHelper.DrawString(frame,text,swfont,new RectangleF(290,205,100,25),ParagraphAlignment.Right); text=amountdue.ToString("F2");//eg 92.00 text=text.Substring(text.Length-2,2);//eg 00 MigraDocHelper.DrawString(frame,text,swfont,185,205); MigraDocHelper.DrawString(frame,text,swfont,425,205); //Patient Address----------------------------------------------------- string patAddress=PatGuar.FName+" "+PatGuar.LName+"\r\n" +PatGuar.Address+"\r\n"; if(PatGuar.Address2!="") { patAddress+=PatGuar.Address2+"\r\n"; } patAddress+=PatGuar.Zip+" "+PatGuar.City; patAddress+=((PatGuar.Country=="")?"":"\r\n"+PatGuar.Country); MigraDocHelper.DrawString(frame,text,swfont,495,218);//middle left MigraDocHelper.DrawString(frame,text,swfont,30,263);//Lower left //Compute Reference#------------------------------------------------------ //Reference# has exactly 27 digits //First 6 numbers are what we are calling the BankRouting number. //Next 20 numbers represent the invoice #. //27th number is the checksum string referenceNum=PrefC.GetString(PrefName.BankRouting);//6 digits if(referenceNum.Length!=6) { referenceNum="000000"; } referenceNum+=PatGuar.PatNum.ToString().PadLeft(12,'0') //"000000000000"//12 0's +DateTime.Today.ToString("yyyyMMdd");//+8=20 //for testing: //referenceNum+="09090271100000067534"; //"00000000000000037112"; referenceNum+=Modulo10(referenceNum).ToString(); //at this point, the referenceNum will always be exactly 27 digits long. string spacedRefNum=referenceNum.Substring(0,2)+" "+referenceNum.Substring(2,5)+" "+referenceNum.Substring(7,5) +" "+referenceNum.Substring(12,5)+" "+referenceNum.Substring(17,5)+" "+referenceNum.Substring(22,5); //text=spacedRefNum.Substring(0,15)+"\r\n"+spacedRefNum.Substring(16)+"\r\n"; //reference# at lower left above address. Small swfont=MigraDocHelper.CreateFont(7); MigraDocHelper.DrawString(frame,spacedRefNum,swfont,30,243); //Reference# at upper right--------------------------------------------------------------- swfont=MigraDocHelper.CreateFont(10); MigraDocHelper.DrawString(frame,spacedRefNum,swfont,490,140); //Big long number at the lower right-------------------------------------------------- /*The very long number on the bottom has this format: >13 numbers > 27 numbers + 9 numbers > >Example: 0100000254306>904483000000000000000371126+ 010045871> > >The first group of 13 numbers would begin with either 01 or only have >042 without any other following numbers. 01 would be used if there is >a specific amount, and 042 would be used if there is not a specific >amount billed. So in the example, the billed amount is 254.30. It has >01 followed by leading zeros to fill in the balance of the digits >required. The last digit is a checksum done by the program. If the >amount would be 1,254.30 then the example should read 0100001254306. > >There is a > separator, then the reference number made up previously. > >Then a + separator, followed by the bank account number. Previously, >the number printed without the zeros, but in this case it has the zeros >and not the dashes.*/ swfont=new MigraDoc.DocumentObjectModel.Font("OCR-B 10 BT",12); text="01"+amountdue.ToString("F2").Replace(".","").PadLeft(10,'0'); text+=Modulo10(text).ToString()+">" +referenceNum+"+ "+origBankNum+">"; MigraDocHelper.DrawString(frame,text,swfont,255,345); } #endregion SwissBanking return doc; }
public static MigraDoc.DocumentObjectModel.Font CreateFont(float fsize,bool isBold,System.Drawing.Color color) { MigraDoc.DocumentObjectModel.Color colorx=ConvertColor(color); MigraDoc.DocumentObjectModel.Font font=new MigraDoc.DocumentObjectModel.Font(); //if(fontFamily.==FontFamily.GenericSansSerif) { font.Name="Arial"; //} //if(fontFamily==FontFamily.GenericSerif) { // font.Name="Times"; //} font.Size=Unit.FromPoint(fsize); font.Bold=isBold; font.Color=colorx; return font; }
/// <summary> /// Adds a new FormattedText object with the given text and font. /// </summary> public FormattedText AddFormattedText(string text, Font font) { FormattedText formattedText = AddFormattedText(font); formattedText.AddText(text); return formattedText; }
/// <summary> /// Applies all non-null properties of a font to this font. /// </summary> public void ApplyFont(Font font) { if (font == null) throw new ArgumentNullException("font"); if (!font._name.IsNull && font._name.Value != "") Name = font.Name; if (!font._size.IsNull) Size = font.Size; if (!font._bold.IsNull) Bold = font.Bold; if (!font._italic.IsNull) Italic = font.Italic; if (!font._subscript.IsNull) Subscript = font.Subscript; else if (!font._superscript.IsNull) Superscript = font.Superscript; if (!font._underline.IsNull) Underline = font.Underline; if (!font._color.IsNull) Color = font.Color; }