private static ParagraphFormat BodyFormatter() { ParagraphFormat bodyformat = new ParagraphFormat(); bodyformat.FirstLineIndent = new Unit(20); bodyformat.SpaceAfter = new Unit(15); return bodyformat; }
/// <summary> /// Help function to receive a line height on empty paragraphs. /// </summary> /// <param name="format">The format.</param> /// <param name="gfx">The GFX.</param> /// <param name="renderer">The renderer.</param> internal static XUnit GetLineHeight(ParagraphFormat format, XGraphics gfx, DocumentRenderer renderer) { XFont font = FontHandler.FontToXFont(format.Font, renderer.PrivateFonts, gfx.MUH, gfx.MFEH); XUnit singleLineSpace = font.GetHeight(); switch (format.LineSpacingRule) { case LineSpacingRule.Exactly: return format.LineSpacing.Point; case LineSpacingRule.AtLeast: return Math.Max(format.LineSpacing.Point, font.GetHeight(gfx)); case LineSpacingRule.Multiple: return format.LineSpacing * format.Font.Size; case LineSpacingRule.OnePtFive: return 1.5 * singleLineSpace; case LineSpacingRule.Double: return 2.0 * singleLineSpace; case LineSpacingRule.Single: default: return singleLineSpace; } }
///<summary>Creates a new .pdf file containing all of the procedures attached to this appointment and ///returns the contents of the .pdf file as a base64 encoded string.</summary> private string GenerateProceduresIntoPdf(){ 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); string text; //Heading--------------------------------------------------------------------------------------------------------------- #region printHeading Paragraph par=section.AddParagraph(); ParagraphFormat parformat=new ParagraphFormat(); parformat.Alignment=ParagraphAlignment.Center; parformat.Font=MigraDocHelper.CreateFont(10,true); par.Format=parformat; text=Lan.g(this,"procedures").ToUpper(); par.AddFormattedText(text,headingFont); par.AddLineBreak(); text=pat.GetNameFLFormal(); par.AddFormattedText(text,headingFont); par.AddLineBreak(); text=DateTime.Now.ToShortDateString(); par.AddFormattedText(text,headingFont); par.AddLineBreak(); par.AddLineBreak(); #endregion //Procedure List-------------------------------------------------------------------------------------------------------- #region Procedure List ODGrid gridProg=new ODGrid(); this.Controls.Add(gridProg);//Only added temporarily so that printing will work. Removed at end with Dispose(). gridProg.BeginUpdate(); gridProg.Columns.Clear(); ODGridColumn col; List<DisplayField> fields=DisplayFields.GetDefaultList(DisplayFieldCategory.None); for(int i=0;i<fields.Count;i++){ if(fields[i].InternalName=="User" || fields[i].InternalName=="Signed"){ continue; } if(fields[i].Description==""){ col=new ODGridColumn(fields[i].InternalName,fields[i].ColumnWidth); } else{ col=new ODGridColumn(fields[i].Description,fields[i].ColumnWidth); } if(fields[i].InternalName=="Amount"){ col.TextAlign=HorizontalAlignment.Right; } if(fields[i].InternalName=="ADA Code") { col.TextAlign=HorizontalAlignment.Center; } gridProg.Columns.Add(col); } gridProg.NoteSpanStart=2; gridProg.NoteSpanStop=7; gridProg.Rows.Clear(); List <Procedure> procsForDay=Procedures.GetProcsForPatByDate(AptCur.PatNum,AptCur.AptDateTime); for(int i=0;i<procsForDay.Count;i++){ Procedure proc=procsForDay[i]; ProcedureCode procCode=ProcedureCodes.GetProcCodeFromDb(proc.CodeNum); Provider prov=Providers.GetProv(proc.ProvNum); Userod usr=Userods.GetUser(proc.UserNum); ODGridRow row=new ODGridRow(); row.ColorLborder=System.Drawing.Color.Black; for(int f=0;f<fields.Count;f++) { switch(fields[f].InternalName){ case "Date": row.Cells.Add(proc.ProcDate.Date.ToShortDateString()); break; case "Time": row.Cells.Add(proc.ProcDate.ToString("h:mm")+proc.ProcDate.ToString("%t").ToLower()); break; case "Th": row.Cells.Add(proc.ToothNum); break; case "Surf": row.Cells.Add(proc.Surf); break; case "Dx": row.Cells.Add(proc.Dx.ToString()); break; case "Description": row.Cells.Add((procCode.LaymanTerm!="")?procCode.LaymanTerm:procCode.Descript); break; case "Stat": row.Cells.Add(Lans.g("enumProcStat",proc.ProcStatus.ToString())); break; case "Prov": if(prov.Abbr.Length>5){ row.Cells.Add(prov.Abbr.Substring(0,5)); } else{ row.Cells.Add(prov.Abbr); } break; case "Amount": row.Cells.Add(proc.ProcFee.ToString("F")); break; case "ADA Code": if(procCode.ProcCode.Length>5 && procCode.ProcCode.StartsWith("D")) { row.Cells.Add(procCode.ProcCode.Substring(0,5));//Remove suffix from all D codes. } else { row.Cells.Add(procCode.ProcCode); } break; case "User": row.Cells.Add(usr!=null?usr.UserName:""); break; } } row.Note=proc.Note; //Row text color. switch(proc.ProcStatus) { case ProcStat.TP: row.ColorText=DefC.Long[(int)DefCat.ProgNoteColors][0].ItemColor; break; case ProcStat.C: row.ColorText=DefC.Long[(int)DefCat.ProgNoteColors][1].ItemColor; break; case ProcStat.EC: row.ColorText=DefC.Long[(int)DefCat.ProgNoteColors][2].ItemColor; break; case ProcStat.EO: row.ColorText=DefC.Long[(int)DefCat.ProgNoteColors][3].ItemColor; break; case ProcStat.R: row.ColorText=DefC.Long[(int)DefCat.ProgNoteColors][4].ItemColor; break; case ProcStat.D: row.ColorText=System.Drawing.Color.Black; break; case ProcStat.Cn: row.ColorText=DefC.Long[(int)DefCat.ProgNoteColors][22].ItemColor; break; } row.ColorBackG=System.Drawing.Color.White; if(proc.ProcDate.Date==DateTime.Today) { row.ColorBackG=DefC.Long[(int)DefCat.MiscColors][6].ItemColor; } gridProg.Rows.Add(row); } MigraDocHelper.DrawGrid(section,gridProg); #endregion MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer=new MigraDoc.Rendering.PdfDocumentRenderer(true,PdfFontEmbedding.Always); pdfRenderer.Document=doc; pdfRenderer.RenderDocument(); MemoryStream ms=new MemoryStream(); pdfRenderer.PdfDocument.Save(ms); byte[] pdfBytes=ms.GetBuffer(); //#region Remove when testing is complete. //string tempFilePath=Path.GetTempFileName(); //File.WriteAllBytes(tempFilePath,pdfBytes); //#endregion string pdfDataStr=Convert.ToBase64String(pdfBytes); ms.Dispose(); return pdfDataStr; }
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)){ printdoc.PrinterSettings=pd2.PrinterSettings; printdoc.Print(); } #endif }
/// <summary> /// Converts ParagraphFormat into DDL. /// </summary> internal void Serialize(Serializer serializer, string name, ParagraphFormat refFormat) { int pos = serializer.BeginContent(name); if (!this.IsNull("Font") && Parent.GetType() != typeof(Style)) this.Font.Serialize(serializer); // If a refFormat is specified, it is important to compare the fields and not the properties. // Only the fields holds the internal information whether a value is NULL. In contrast to the // Efw.Application framework the nullable values and all the meta stuff is kept internal to // give the user the illusion of simplicity. if (!this.alignment.IsNull && (refFormat == null || (this.alignment != refFormat.alignment))) serializer.WriteSimpleAttribute("Alignment", this.Alignment); if (!this.leftIndent.IsNull && (refFormat == null || (this.leftIndent != refFormat.leftIndent))) serializer.WriteSimpleAttribute("LeftIndent", this.LeftIndent); if (!this.firstLineIndent.IsNull && (refFormat == null || this.firstLineIndent != refFormat.firstLineIndent)) serializer.WriteSimpleAttribute("FirstLineIndent", this.FirstLineIndent); if (!this.rightIndent.IsNull && (refFormat == null || this.rightIndent != refFormat.rightIndent)) serializer.WriteSimpleAttribute("RightIndent", this.RightIndent); if (!this.spaceBefore.IsNull && (refFormat == null || this.spaceBefore != refFormat.spaceBefore)) serializer.WriteSimpleAttribute("SpaceBefore", this.SpaceBefore); if (!this.spaceAfter.IsNull && (refFormat == null || this.spaceAfter != refFormat.spaceAfter)) serializer.WriteSimpleAttribute("SpaceAfter", this.SpaceAfter); if (!this.lineSpacingRule.IsNull && (refFormat == null || this.lineSpacingRule != refFormat.lineSpacingRule)) serializer.WriteSimpleAttribute("LineSpacingRule", this.LineSpacingRule); if (!this.lineSpacing.IsNull && (refFormat == null || this.lineSpacing != refFormat.lineSpacing)) serializer.WriteSimpleAttribute("LineSpacing", this.LineSpacing); if (!this.keepTogether.IsNull && (refFormat == null || this.keepTogether != refFormat.keepTogether)) serializer.WriteSimpleAttribute("KeepTogether", this.KeepTogether); if (!this.keepWithNext.IsNull && (refFormat == null || this.keepWithNext != refFormat.keepWithNext)) serializer.WriteSimpleAttribute("KeepWithNext", this.KeepWithNext); if (!this.widowControl.IsNull && (refFormat == null || this.widowControl != refFormat.widowControl)) serializer.WriteSimpleAttribute("WidowControl", this.WidowControl); if (!this.pageBreakBefore.IsNull && (refFormat == null || this.pageBreakBefore != refFormat.pageBreakBefore)) serializer.WriteSimpleAttribute("PageBreakBefore", this.PageBreakBefore); if (!this.outlineLevel.IsNull && (refFormat == null || this.outlineLevel != refFormat.outlineLevel)) serializer.WriteSimpleAttribute("OutlineLevel", this.OutlineLevel); if (!this.IsNull("ListInfo")) this.ListInfo.Serialize(serializer); if (!this.IsNull("TabStops")) this.tabStops.Serialize(serializer); if (!this.IsNull("Borders")) { if (refFormat != null) this.borders.Serialize(serializer, refFormat.Borders); else this.borders.Serialize(serializer, null); } if (!this.IsNull("Shading")) this.shading.Serialize(serializer); serializer.EndContent(pos); }
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(); 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; }
///<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; }
private MigraDoc.DocumentObjectModel.Document CreateDocument(){ 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(); string text; 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); //Heading--------------------------------------------------------------------------------------------------------------- #region printHeading Paragraph par=section.AddParagraph(); ParagraphFormat parformat=new ParagraphFormat(); parformat.Alignment=ParagraphAlignment.Center; parformat.Font=MigraDocHelper.CreateFont(10,true); par.Format=parformat; if(gridPlans.SelectedIndices[0]==0) {//current TP text=Lan.g(this,"Proposed Treatment Plan"); } else { text=PlanList[gridPlans.SelectedIndices[0]-1].Heading; } par.AddFormattedText(text,headingFont); par.AddLineBreak(); if(PatCur.ClinicNum==0) { text=PrefC.GetString(PrefName.PracticeTitle); par.AddText(text); par.AddLineBreak(); text=PrefC.GetString(PrefName.PracticePhone); } else { Clinic clinic=Clinics.GetClinic(PatCur.ClinicNum); text=clinic.Description; par.AddText(text); par.AddLineBreak(); text=clinic.Phone; } 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(); text=PatCur.GetNameFL()+", DOB "+PatCur.Birthdate.ToShortDateString(); par.AddText(text); par.AddLineBreak(); if(gridPlans.SelectedIndices[0]>0){//not the default plan if(PlanList[gridPlans.SelectedIndices[0]-1].ResponsParty!=0){ text=Lan.g(this,"Responsible Party: ") +Patients.GetLim(PlanList[gridPlans.SelectedIndices[0]-1].ResponsParty).GetNameFL(); par.AddText(text); par.AddLineBreak(); } } if(gridPlans.SelectedIndices[0]==0) {//default TP text=DateTime.Today.ToShortDateString(); } else { text=PlanList[gridPlans.SelectedIndices[0]-1].DateTP.ToShortDateString(); } par.AddText(text); #endregion //Graphics--------------------------------------------------------------------------------------------------------------- #region PrintGraphics TextFrame frame; int widthDoc=MigraDocHelper.GetDocWidth(); if(PrefC.GetBool(PrefName.TreatPlanShowGraphics)) { frame=MigraDocHelper.CreateContainer(section); MigraDocHelper.DrawString(frame,Lan.g(this,"Your")+"\r\n"+Lan.g(this,"Right"),bodyFontx, new RectangleF(widthDoc/2-toothChart.Width/2-50,toothChart.Height/2-10,50,100)); MigraDocHelper.DrawBitmap(frame,chartBitmap,widthDoc/2-toothChart.Width/2,0); MigraDocHelper.DrawString(frame,Lan.g(this,"Your")+"\r\n"+Lan.g(this,"Left"),bodyFontx, new RectangleF(widthDoc/2+toothChart.Width/2+17,toothChart.Height/2-10,50,100)); if(checkShowCompleted.Checked) { float yPos=toothChart.Height+15; float xPos=225; MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][3].ItemColor,xPos,yPos,14,14); xPos+=16; MigraDocHelper.DrawString(frame,Lan.g(this,"Existing"),bodyFontx,xPos,yPos); Graphics g=this.CreateGraphics();//for measuring strings. xPos+=(int)g.MeasureString(Lan.g(this,"Existing"),bodyFont).Width+23; //The Complete work is actually a combination of EC and C. Usually same color. //But just in case they are different, this will show it. MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][2].ItemColor,xPos,yPos,7,14); xPos+=7; MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][1].ItemColor,xPos,yPos,7,14); xPos+=9; MigraDocHelper.DrawString(frame,Lan.g(this,"Complete"),bodyFontx,xPos,yPos); xPos+=(int)g.MeasureString(Lan.g(this,"Complete"),bodyFont).Width+23; MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][4].ItemColor,xPos,yPos,14,14); xPos+=16; MigraDocHelper.DrawString(frame,Lan.g(this,"Referred Out"),bodyFontx,xPos,yPos); xPos+=(int)g.MeasureString(Lan.g(this,"Referred Out"),bodyFont).Width+23; MigraDocHelper.FillRectangle(frame,DefC.Short[(int)DefCat.ChartGraphicColors][0].ItemColor,xPos,yPos,14,14); xPos+=16; MigraDocHelper.DrawString(frame,Lan.g(this,"Treatment Planned"),bodyFontx,xPos,yPos); g.Dispose(); } } #endregion MigraDocHelper.InsertSpacer(section,10); MigraDocHelper.DrawGrid(section,gridMain); //Print benefits---------------------------------------------------------------------------------------------------- #region printBenefits if(checkShowIns.Checked) { ODGrid gridFamIns=new ODGrid(); this.Controls.Add(gridFamIns); gridFamIns.BeginUpdate(); gridFamIns.Columns.Clear(); ODGridColumn col=new ODGridColumn("",140); gridFamIns.Columns.Add(col); col=new ODGridColumn(Lan.g(this,"Primary"),70,HorizontalAlignment.Right); gridFamIns.Columns.Add(col); col=new ODGridColumn(Lan.g(this,"Secondary"),70,HorizontalAlignment.Right); gridFamIns.Columns.Add(col); gridFamIns.Rows.Clear(); ODGridRow row; //Annual Family Max-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Family Maximum")); row.Cells.Add(textFamPriMax.Text); row.Cells.Add(textFamSecMax.Text); gridFamIns.Rows.Add(row); //Family Deductible-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Family Deductible")); row.Cells.Add(textFamPriDed.Text); row.Cells.Add(textFamSecDed.Text); gridFamIns.Rows.Add(row); //Print Family Insurance----------------------- MigraDocHelper.InsertSpacer(section,15); par=section.AddParagraph(); par.Format.Alignment=ParagraphAlignment.Center; par.AddFormattedText(Lan.g(this,"Family Dental Insurance Benefits"),totalFontx); MigraDocHelper.InsertSpacer(section,2); MigraDocHelper.DrawGrid(section,gridFamIns); gridFamIns.Dispose(); //Individual Insurance--------------------- ODGrid gridIns=new ODGrid(); this.Controls.Add(gridIns); gridIns.BeginUpdate(); gridIns.Columns.Clear(); col=new ODGridColumn("",140); gridIns.Columns.Add(col); col=new ODGridColumn(Lan.g(this,"Primary"),70,HorizontalAlignment.Right); gridIns.Columns.Add(col); col=new ODGridColumn(Lan.g(this,"Secondary"),70,HorizontalAlignment.Right); gridIns.Columns.Add(col); gridIns.Rows.Clear(); //Annual Max-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Annual Maximum")); row.Cells.Add(textPriMax.Text); row.Cells.Add(textSecMax.Text); gridIns.Rows.Add(row); //Deductible-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Deductible")); row.Cells.Add(textPriDed.Text); row.Cells.Add(textSecDed.Text); gridIns.Rows.Add(row); //Deductible Remaining-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Deductible Remaining")); row.Cells.Add(textPriDedRem.Text); row.Cells.Add(textSecDedRem.Text); gridIns.Rows.Add(row); //Insurance Used-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Insurance Used")); row.Cells.Add(textPriUsed.Text); row.Cells.Add(textSecUsed.Text); gridIns.Rows.Add(row); //Pending-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Pending")); row.Cells.Add(textPriPend.Text); row.Cells.Add(textSecPend.Text); gridIns.Rows.Add(row); //Remaining-------------------------- row=new ODGridRow(); row.Cells.Add(Lan.g(this,"Remaining")); row.Cells.Add(textPriRem.Text); row.Cells.Add(textSecRem.Text); gridIns.Rows.Add(row); gridIns.EndUpdate(); //Print Individual Insurance------------------------- MigraDocHelper.InsertSpacer(section,15); par=section.AddParagraph(); par.Format.Alignment=ParagraphAlignment.Center; par.AddFormattedText(Lan.g(this,"Individual Dental Insurance Benefits"),totalFontx); MigraDocHelper.InsertSpacer(section,2); MigraDocHelper.DrawGrid(section,gridIns); gridIns.Dispose(); } #endregion //Note------------------------------------------------------------------------------------------------------------ #region printNote string note=""; if(gridPlans.SelectedIndices[0]==0) {//current TP note=PrefC.GetString(PrefName.TreatmentPlanNote); } else { note=PlanList[gridPlans.SelectedIndices[0]-1].Note; } char nbsp='\u00A0'; //to prevent collapsing of multiple spaces to single spaces. We only do double spaces to leave single spaces in place. note=note.Replace(" ",nbsp.ToString()+nbsp.ToString()); MigraDocHelper.InsertSpacer(section,20); par=section.AddParagraph(note); par.Format.Font=bodyFontx; par.Format.Borders.Color=Colors.Gray; par.Format.Borders.DistanceFromLeft=Unit.FromInch(.05); par.Format.Borders.DistanceFromRight=Unit.FromInch(.05); par.Format.Borders.DistanceFromTop=Unit.FromInch(.05); par.Format.Borders.DistanceFromBottom=Unit.FromInch(.05); #endregion //Signature----------------------------------------------------------------------------------------------------------- #region signature if(gridPlans.SelectedIndices[0]!=0//can't be default TP && PlanList[gridPlans.SelectedIndices[0]-1].Signature!="") { System.Drawing.Bitmap sigBitmap=null; List<ProcTP> proctpList=ProcTPs.RefreshForTP(PlanList[gridPlans.SelectedIndices[0]-1].TreatPlanNum); if(PlanList[gridPlans.SelectedIndices[0]-1].SigIsTopaz){ Control sigBoxTopaz=CodeBase.TopazWrapper.GetTopaz(); sigBoxTopaz.Size=new System.Drawing.Size(362,79); Controls.Add(sigBoxTopaz); CodeBase.TopazWrapper.ClearTopaz(sigBoxTopaz); CodeBase.TopazWrapper.SetTopazCompressionMode(sigBoxTopaz,0); CodeBase.TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz,0); string keystring=TreatPlans.GetHashString(PlanList[gridPlans.SelectedIndices[0]-1],proctpList); CodeBase.TopazWrapper.SetTopazKeyString(sigBoxTopaz,keystring); CodeBase.TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz,2);//high encryption CodeBase.TopazWrapper.SetTopazCompressionMode(sigBoxTopaz,2);//high compression CodeBase.TopazWrapper.SetTopazSigString(sigBoxTopaz,PlanList[gridPlans.SelectedIndices[0]-1].Signature); sigBoxTopaz.Refresh(); //If sig is not showing, then try encryption mode 3 for signatures signed with old SigPlusNet.dll. if(CodeBase.TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz)==0) { CodeBase.TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz,3);//Unknown mode (told to use via TopazSystems) CodeBase.TopazWrapper.SetTopazSigString(sigBoxTopaz,PlanList[gridPlans.SelectedIndices[0]-1].Signature); } sigBitmap=new Bitmap(362,79); sigBoxTopaz.DrawToBitmap(sigBitmap,new Rectangle(0,0,362,79));//GetBitmap would probably work. Controls.Remove(sigBoxTopaz); sigBoxTopaz.Dispose(); } else{ SignatureBox sigBox=new SignatureBox(); sigBox.Size=new System.Drawing.Size(362,79); sigBox.ClearTablet(); //sigBox.SetSigCompressionMode(0); //sigBox.SetEncryptionMode(0); sigBox.SetKeyString(TreatPlans.GetHashString(PlanList[gridPlans.SelectedIndices[0]-1],proctpList)); //"0000000000000000"); //sigBox.SetAutoKeyData(ProcCur.Note+ProcCur.UserNum.ToString()); //sigBox.SetEncryptionMode(2);//high encryption //sigBox.SetSigCompressionMode(2);//high compression sigBox.SetSigString(PlanList[gridPlans.SelectedIndices[0]-1].Signature); //if(sigBox.NumberOfTabletPoints()==0) { // labelInvalidSig.Visible=true; //} //sigBox.SetTabletState(0);//not accepting input. To accept input, change the note, or clear the sig. sigBitmap=(Bitmap)sigBox.GetSigImage(true); } if(sigBitmap!=null){ frame=MigraDocHelper.CreateContainer(section); MigraDocHelper.DrawBitmap(frame,sigBitmap,widthDoc/2-sigBitmap.Width/2,20); } } #endregion return doc; }
/// <summary> /// Define los estilos para usarse dentro del reporte. /// </summary> /// <param name="document">Documento sobre el cual se añaden los estilos.</param> public static void DefineStyles(Document document) { Style style = document.Styles["Normal"]; style.Font.Name = "Times New Roman"; style = document.Styles["Heading1"]; style.Font.Name = "Tahoma"; style.Font.Size = 14; style.Font.Bold = true; style.Font.Color = Colors.Black; style.ParagraphFormat.PageBreakBefore = true; style.ParagraphFormat.SpaceAfter = 6; style = document.Styles["Heading2"]; style.Font.Size = 12; style.Font.Bold = true; style.ParagraphFormat.PageBreakBefore = false; style.ParagraphFormat.SpaceBefore = 6; style.ParagraphFormat.SpaceAfter = 6; style = document.Styles[StyleNames.Header]; ParagraphFormat pf = new ParagraphFormat(); style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Center); style.Font.Name = "Tahoma"; style.Font.Size = 14; style.Font.Bold = true; style.Font.Color = Colors.Black; }
private static ParagraphFormat HeaderFormatter() { ParagraphFormat headerformat = new ParagraphFormat(); headerformat.SpaceAfter = new Unit(20); return headerformat; }
private static ParagraphFormat IngredientFormatter() { ParagraphFormat ingredientformat = new ParagraphFormat(); ingredientformat.LeftIndent = new Unit(15); ingredientformat.SpaceAfter = new Unit(15); return ingredientformat; }
/// <summary> /// Converts Style into DDL. /// </summary> internal override void Serialize(Serializer serializer) { // For build-in styles all properties that differ from their default values // are serialized. // For user-defined styles all non-null properties are serialized. //!!!newTHHO 26.07.2007 Modified method for built-in styles. //!!!newTHHO 26.07.2007 Modified method for user-defined styles. Styles buildInStyles = Styles.BuildInStyles; Style refStyle = null; Font refFont = null; ParagraphFormat refFormat = null; serializer.WriteComment(this.comment.Value); if (this.buildIn.Value) { // BaseStyle is never null, but empty only for "Normal" and "DefaultParagraphFont" if (this.BaseStyle == "") { // case: style is "Normal" if (String.Compare(this.name.Value, Style.DefaultParagraphName, true) != 0) { throw new ArgumentException("Internal Error: BaseStyle not set."); } refStyle = buildInStyles[buildInStyles.GetIndex(this.Name)]; refFormat = refStyle.ParagraphFormat; refFont = refFormat.Font; string name = DdlEncoder.QuoteIfNameContainsBlanks(this.Name); serializer.WriteLineNoCommit(name); } else { // case: any build-in style except "Normal" refStyle = buildInStyles[buildInStyles.GetIndex(this.Name)]; refFormat = refStyle.ParagraphFormat; refFont = refFormat.Font; if (String.Compare(this.BaseStyle, refStyle.BaseStyle, true) == 0) { // case: build-in style with unmodified base style name string name = DdlEncoder.QuoteIfNameContainsBlanks(this.Name); serializer.WriteLineNoCommit(name); // It's fine if we have the predefined base style, but ... // ... the base style may have been modified or may even have a modified base style. // Methinks it's wrong to compare with the built-in style, so let's compare with the // real base style: refStyle = Document.Styles[Document.Styles.GetIndex(this.baseStyle.Value)]; refFormat = refStyle.ParagraphFormat; refFont = refFormat.Font; // Note: we must write "Underline = none" if the base style has "Underline = single" - we cannot // detect this if we compare with the built-in style that has no underline. // Known problem: Default values like "OutlineLevel = Level1" will now be serialized // TODO: optimize... } else { // case: build-in style with modified base style name string name = DdlEncoder.QuoteIfNameContainsBlanks(this.Name); string baseName = DdlEncoder.QuoteIfNameContainsBlanks(this.BaseStyle); serializer.WriteLine(name + " : " + baseName); refStyle = Document.Styles[Document.Styles.GetIndex(this.baseStyle.Value)]; refFormat = refStyle.ParagraphFormat; refFont = refFormat.Font; } } } else { // case: user-defined style; base style always exists string name = DdlEncoder.QuoteIfNameContainsBlanks(this.Name); string baseName = DdlEncoder.QuoteIfNameContainsBlanks(this.BaseStyle); serializer.WriteLine(name + " : " + baseName); #if true Style refStyle0 = Document.Styles[Document.Styles.GetIndex(this.baseStyle.Value)]; refStyle = Document.Styles[this.baseStyle.Value]; refFormat = refStyle != null ? refStyle.ParagraphFormat : null; refFont = refStyle.Font; #else refFormat = null; #endif } serializer.BeginContent(); if (!this.IsNull("ParagraphFormat")) { if (!this.ParagraphFormat.IsNull("Font")) { this.Font.Serialize(serializer, refFormat != null ? refFormat.Font : null); } if (this.Type == StyleType.Paragraph) { this.ParagraphFormat.Serialize(serializer, "ParagraphFormat", refFormat); } } serializer.EndContent(); }
/// <summary> /// Converts ParagraphFormat into DDL. /// </summary> internal void Serialize(Serializer serializer, string name, ParagraphFormat refFormat) { int pos = serializer.BeginContent(name); if (!IsNull("Font") && Parent.GetType() != typeof(Style)) { Font.Serialize(serializer); } // If a refFormat is specified, it is important to compare the fields and not the properties. // Only the fields holds the internal information whether a value is NULL. In contrast to the // Efw.Application framework the nullable values and all the meta stuff is kept internal to // give the user the illusion of simplicity. if (!_alignment.IsNull && (refFormat == null || (_alignment != refFormat._alignment))) { serializer.WriteSimpleAttribute("Alignment", Alignment); } if (!_leftIndent.IsNull && (refFormat == null || (_leftIndent != refFormat._leftIndent))) { serializer.WriteSimpleAttribute("LeftIndent", LeftIndent); } if (!_firstLineIndent.IsNull && (refFormat == null || _firstLineIndent != refFormat._firstLineIndent)) { serializer.WriteSimpleAttribute("FirstLineIndent", FirstLineIndent); } if (!_rightIndent.IsNull && (refFormat == null || _rightIndent != refFormat._rightIndent)) { serializer.WriteSimpleAttribute("RightIndent", RightIndent); } if (!_spaceBefore.IsNull && (refFormat == null || _spaceBefore != refFormat._spaceBefore)) { serializer.WriteSimpleAttribute("SpaceBefore", SpaceBefore); } if (!_spaceAfter.IsNull && (refFormat == null || _spaceAfter != refFormat._spaceAfter)) { serializer.WriteSimpleAttribute("SpaceAfter", SpaceAfter); } if (!_lineSpacingRule.IsNull && (refFormat == null || _lineSpacingRule != refFormat._lineSpacingRule)) { serializer.WriteSimpleAttribute("LineSpacingRule", LineSpacingRule); } if (!_lineSpacing.IsNull && (refFormat == null || _lineSpacing != refFormat._lineSpacing)) { serializer.WriteSimpleAttribute("LineSpacing", LineSpacing); } if (!_keepTogether.IsNull && (refFormat == null || _keepTogether != refFormat._keepTogether)) { serializer.WriteSimpleAttribute("KeepTogether", KeepTogether); } if (!_keepWithNext.IsNull && (refFormat == null || _keepWithNext != refFormat._keepWithNext)) { serializer.WriteSimpleAttribute("KeepWithNext", KeepWithNext); } if (!_widowControl.IsNull && (refFormat == null || _widowControl != refFormat._widowControl)) { serializer.WriteSimpleAttribute("WidowControl", WidowControl); } if (!_pageBreakBefore.IsNull && (refFormat == null || _pageBreakBefore != refFormat._pageBreakBefore)) { serializer.WriteSimpleAttribute("PageBreakBefore", PageBreakBefore); } if (!_outlineLevel.IsNull && (refFormat == null || _outlineLevel != refFormat._outlineLevel)) { serializer.WriteSimpleAttribute("OutlineLevel", OutlineLevel); } if (!IsNull("ListInfo")) { ListInfo.Serialize(serializer); } if (!IsNull("TabStops")) { _tabStops.Serialize(serializer); } if (!IsNull("Borders")) { if (refFormat != null) { _borders.Serialize(serializer, refFormat.Borders); } else { _borders.Serialize(serializer, null); } } if (!IsNull("Shading")) { _shading.Serialize(serializer); } serializer.EndContent(pos); }
/// <summary> /// Initializes a new instance of the Paragraph Renderer class. /// </summary> internal ParagraphFormatRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer) : base(domObj, docRenderer) { this.format = domObj as ParagraphFormat; }