public void SaveGO95(PPLMain pPPLMain, PPLPole pPole, string pFileName) { PPLReportsForm reportTemplate = new PPLReportsForm(pPPLMain, pPole); reportTemplate.BuildReportsList(); //don't worry about the dock content error. it still works in ocalc MigraDocReportControl mgDocControl = new MigraDocReportControl(); foreach (ReportTemplate rep in reportTemplate.cAvailableReports) { if (Convert.ToString(rep.Description).Equals("GO95 Analysis Report")) { rep.CreateReport(pPPLMain, null); rep.AddPole(pPole, (string)null); //mgDocControl.SetReport(doc, pPPLMain, (PPLWorkingDialog)null); Document doc = rep.GetReport(); MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer = new MigraDoc.Rendering.PdfDocumentRenderer(false, PdfSharp.Pdf.PdfFontEmbedding.Always); pdfRenderer.Document = doc; pdfRenderer.RenderDocument(); pdfRenderer.PdfDocument.Save(pFileName); rep.Reset(); //mgDocControl.SetReport(doc, pPPLMain, (PPLWorkingDialog)null); } } }
readonly static int MaxColPerSplitTable = 8; // 8 was tested default private void splitExportC1FlexgridButton_Click(object sender, RoutedEventArgs e) { double PDFPageHeight; C1FlexGrid augrid = new C1FlexGrid();// PopulateTable(); string strMaxTblCol = "7", strMaxTblRow = "20", strPDFfontsize = "12"; MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document(); PDFPageHeight = doc.DefaultPageSetup.PageHeight.Centimeter; MigraDoc.DocumentObjectModel.Section sec = doc.AddSection(); sec.AddParagraph("BSky Flexgrid Output"); sec.AddParagraph(); //empty space List <MigraDoc.DocumentObjectModel.Tables.Table> tableParts = ExportMultiHeaderFlexgridToPDF(PDFPageHeight, augrid, strMaxTblCol, strMaxTblRow, strPDFfontsize); //finally rendring doc and then saving to disk file foreach (MigraDoc.DocumentObjectModel.Tables.Table t in tableParts) { //add table part to doc doc.LastSection.Add(t); //table.Format.KeepWithNext = true; sec.AddParagraph(); } //rendering doc MigraDoc.Rendering.PdfDocumentRenderer docrender = new MigraDoc.Rendering.PdfDocumentRenderer(false); docrender.Document = doc; docrender.RenderDocument(); string filename = "D:\\BSkyFG6.pdf"; docrender.PdfDocument.Save(filename); MessageBox.Show("Export Finished"); }
private void CreatePDF(string tempFile) { MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer = new MigraDoc.Rendering.PdfDocumentRenderer(true, PdfFontEmbedding.Always); pdfRenderer.Document = CreateDocument(); pdfRenderer.RenderDocument(); pdfRenderer.PdfDocument.Save(tempFile); }
public static void ExportFlexGridToPDF(string fullpathzipcsvhtmfilename, string TblTitle, AUXGrid fgrid) { int imgnamecounter = 0; List <string> filelist = new List <string>(); bool fileExists = File.Exists(fullpathzipcsvhtmfilename); double left, top, right, bottom; GetPDFpageMargins(strPDFPageMargin, out left, out top, out right, out bottom); //Creating a PDF doc to which we will add PDFTables MigraDoc.DocumentObjectModel.Document Doc = new MigraDoc.DocumentObjectModel.Document(); MigraDoc.DocumentObjectModel.Tables.Table pdfTable; //Set Page margins from configuration Doc.DefaultPageSetup.LeftMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(left); //left margin Doc.DefaultPageSetup.TopMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(top); //top margin Doc.DefaultPageSetup.RightMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(right); //right margin Doc.DefaultPageSetup.BottomMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(bottom); //bottom margin Doc.AddSection(); ExportFlexgrid(Doc, TblTitle, fgrid); ////rendering doc MigraDoc.Rendering.PdfDocumentRenderer docrender = new MigraDoc.Rendering.PdfDocumentRenderer(false); docrender.Document = Doc; docrender.RenderDocument(); docrender.PdfDocument.Save(fullpathzipcsvhtmfilename); }
public static MemoryStream PDFFromGridView(System.Windows.Forms.DataGridView grd, bool useDefaultCellStyle, string path = null) { var document = new Document(); var section = document.AddSection(); section.PageSetup.PageFormat = PageFormat.A4; section.PageSetup.Orientation = Orientation.Landscape; section.PageSetup.LeftMargin = new Unit(1, UnitType.Centimeter); section.PageSetup.RightMargin = new Unit(1, UnitType.Centimeter); PDFTableHelper.setStyle(document); var table = PDFTableHelper.createTable(section, getHeaders(grd), StyleNames.Header, colDivideur); table.Borders.Width = 0.75; if (grd.RowCount > 0) { useDefaultCellStyle &= !(grd.Rows[0].DefaultCellStyle.BackColor.R == 0 && grd.Rows[0].DefaultCellStyle.BackColor.G == 0 && grd.Rows[0].DefaultCellStyle.BackColor.B == 0); //force } var cmpt = 0; foreach (System.Windows.Forms.DataGridViewRow dr in grd.Rows) { cmpt++; if (cmpt > 1000) { break; } var currentRow = PDFTableHelper.addRowFromGridViewRow(table, dr, StyleNames.Normal); currentRow.Shading.Color = useDefaultCellStyle ? new Color(dr.DefaultCellStyle.BackColor.R, dr.DefaultCellStyle.BackColor.G, dr.DefaultCellStyle.BackColor.B) : new Color(255, 255, 255, 255); } document.LastSection.Add(table); var renderer = new MigraDoc.Rendering.PdfDocumentRenderer(true); renderer.Document = document; renderer.RenderDocument(); if (path != null) { renderer.PdfDocument.Save(path); return(null); } MemoryStream ms = new MemoryStream(); renderer.PdfDocument.Save(ms, false); return(ms); }
public static void SaveAsPDFAllAnalyisOuput(ObservableCollection <AnalyticsData> DataList, string fullpathzipcsvhtmfilename) { int imgnamecounter = 0; List <string> filelist = new List <string>(); bool extratags = false; bool fileExists = File.Exists(fullpathzipcsvhtmfilename); double left, top, right, bottom; GetPDFpageMargins(strPDFPageMargin, out left, out top, out right, out bottom); //Creating a PDF doc to which we will add PDFTables MigraDoc.DocumentObjectModel.Document Doc = new MigraDoc.DocumentObjectModel.Document(); MigraDoc.DocumentObjectModel.Tables.Table pdfTable; //Set Page margins from configuration Doc.DefaultPageSetup.LeftMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(left); //left margin Doc.DefaultPageSetup.TopMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(top); //top margin Doc.DefaultPageSetup.RightMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(right); //right margin Doc.DefaultPageSetup.BottomMargin = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(bottom); //bottom margin Doc.AddSection(); //////// looping thru all analysis one by one ////// foreach (AnalyticsData analysisdata in DataList) { //03Aug2012 ICommandAnalyser analyser = CommandAnalyserFactory.GetClientAnalyser(analysisdata); CommandOutput output = analysisdata.Output; // getting refrence of already generated objects. SessionOutput sessionoutput = analysisdata.SessionOutput; //27Nov2013 if there is session output if (output != null) { output.NameOfAnalysis = analysisdata.AnalysisType;//For Parent Node name 02Aug2012 } if (sessionoutput != null) { sessionoutput.NameOfSession = analysisdata.AnalysisType; } /////// dumping output // if (output != null) { ExportOutputPDF(output, Doc, extratags, filelist); } else if (sessionoutput != null) { foreach (CommandOutput cout in sessionoutput) { ExportOutputPDF(cout, Doc, extratags, filelist, true); } } } ////rendering doc MigraDoc.Rendering.PdfDocumentRenderer docrender = new MigraDoc.Rendering.PdfDocumentRenderer(false); docrender.Document = Doc; docrender.RenderDocument(); docrender.PdfDocument.Save(fullpathzipcsvhtmfilename); }
internal static void RenderPdfToStream(MemoryStream streamToWriteTo, BaseDocument document) { document.DrawDocument(); var printer = new MigraDoc.Rendering.PdfDocumentRenderer(); printer.Document = document.Document; printer.RenderDocument(); printer.PdfDocument.Save(streamToWriteTo, false); }
public void ExportToPDF(IList <Student> students) { //Contract.Requires<ArgumentException>(students.Count > 0, "The list should not be empty"); Common.GeneratePDFResults pdfGenerator = new Common.GeneratePDFResults(); Document doc = pdfGenerator.GenerateResults(students); MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(doc, "MigraDoc.mdddl"); MigraDoc.Rendering.PdfDocumentRenderer renderer = new MigraDoc.Rendering.PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always); renderer.Document = doc; renderer.RenderDocument(); string fileName = "FIIAdmission.pdf"; renderer.PdfDocument.Save(string.Format(fileName)); Process.Start(fileName); }
private void generateMapPdf(string reportTitle, string imageFilename, string outputFilename) { Document document = new Document(); setupStyles(document); // Each MigraDoc document needs at least one section. Section section = document.AddSection(); // Create header Paragraph paragraph1 = section.AddParagraph(); paragraph1.AddText(reportTitle); paragraph1.Format.Font.Size = 14; paragraph1.Format.Font.Bold = true; paragraph1.Format.Alignment = ParagraphAlignment.Left; paragraph1.Format.SpaceAfter = new Unit(6.0); paragraph1.Format.SpaceBefore = new Unit(0.0); // Create footer /*Paragraph paragraph = section.Footers.Primary.AddParagraph(); * paragraph.AddText(string.Format("- Generated {0} {1} -", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString())); * paragraph.Format.Font.Size = 8; * paragraph.Format.Alignment = ParagraphAlignment.Center;*/ var image = section.AddImage(imageFilename); image.Width = new Unit(10.7, UnitType.Inch); image.Height = new Unit(6.5, UnitType.Inch); var pdfRenderer = new MigraDoc.Rendering.PdfDocumentRenderer(false); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); pdfRenderer.PdfDocument.Save(outputFilename); System.Diagnostics.Process.Start(outputFilename); }
/// <summary> /// Serializes the given document to DDL and renders a PDF document from it to make sure that /// the generated DDL is valid. /// </summary> public static void ParseDdl(Document doc) { var sb = new StringBuilder(); using (var writer = new StringWriter(sb)) { doc.WriteDdl(writer); } var ddl = sb.ToString(); var mDoc = MigraDoc.DocumentObjectModel.IO.DdlReader.DocumentFromString(ddl); MigraDoc.Rendering.PdfDocumentRenderer renderer = new MigraDoc.Rendering.PdfDocumentRenderer(true) { Document = mDoc }; renderer.RenderDocument(); using (var strm = new MemoryStream()) { renderer.PdfDocument.Save(strm); } }
private void generatePDFAsync(string outputFilename) { //apply filters to get all records using paging - streaming records into a temporary database table BusyMessage.Show("Downloading data...", this.FindForm()); try { Document mDoc = new Document(); Table table = new Table(); int record = 1; int total = 0; StringBuilder sb = new StringBuilder(32000); if (filterBar.Filter.RecentOnly) { using (StreamWriter sr = new StreamWriter(outputFilename, false)) { var outputDocs = getRecentModuleDocsAsync(); string[] headers = { "Client:3cm", "Farm:2.8cm", "Field:3cm", "Serial:2.2cm", "Load:1.30cm", "Gin Tkt Load:1.50cm", "Latitude:3.15cm", "Longitude:3.15cm", "TruckID:1.5cm", "Driver:1.75cm", "Status:1.4cm", "Timestamp:2.0cm" }; string[] columns = { "{Client}", "{Farm}", "{Field}", "{SerialNumber}", "{LoadNumber}", "{GinTagLoadNumber}", "{Latitude}", "{Longitude}", "{TruckID}", "{Driver}", "{Status}", "{DateAdded}" }; setupPdf(mDoc, headers, ref table, tbReportTitle.Text); total = outputDocs.Count(); foreach (var d in outputDocs) { BusyMessage.UpdateMessage(string.Format("Building Row {0} of {1}", record, total)); List <string> values = new List <string>(); foreach (var v in columns) { values.Add(getOutputLine(v, d)); } addPdfRow(mDoc, values.ToArray(), table); record++; } } } else { using (StreamWriter sr = new StreamWriter(outputFilename, false)) { var historyDocs = getAllLocationRecordsAsync(); string[] headers = { "Client:2.5cm", "Farm:2.0cm", "Field:2.5cm", "Serial:2.2cm", "Load:1.30cm", "Gin ticket load:1.50cm", "Latitude:3.15cm", "Longitude:3.15cm", "TruckID:1.5cm", "Driver:1.75cm", "Status:1.2cm", "Event:1.75cm", "Timestamp:2.0cm" }; string[] columns = { "{Client}", "{Farm}", "{Field}", "{SerialNumber}", "{LoadNumber}", "{GinTagLoadNumber}", "{Latitude}", "{Longitude}", "{TruckID}", "{Driver}", "{Status}", "{EventType}", "{DateAdded}" }; setupPdf(mDoc, headers, ref table, tbReportTitle.Text); total = historyDocs.Count(); foreach (var d in historyDocs) { BusyMessage.UpdateMessage(string.Format("Building Row {0} of {1}", record, total)); List <string> values = new List <string>(); foreach (var v in columns) { values.Add(getHistoryOutputLine(v, d)); } addPdfRow(mDoc, values.ToArray(), table); record++; } } } if (total > 10000) { BusyMessage.Close(); MessageBox.Show("Too many records to render to a single PDF. Please add additional filter criteria to reduce the number of included records."); return; } else { BusyMessage.UpdateMessage("Rendering PDF"); var pdfRenderer = new MigraDoc.Rendering.PdfDocumentRenderer(false); pdfRenderer.Document = mDoc; pdfRenderer.RenderDocument(); pdfRenderer.PdfDocument.Save(outputFilename); System.Diagnostics.Process.Start(outputFilename); } } catch (Exception exc) { Logging.Logger.Log(exc); MessageBox.Show(exc.Message); } BusyMessage.Close(); }
///<summary>Creates a new pdf, attaches it to a new doc, and attaches that to the statement. If it cannot create a pdf, for example if no AtoZ folders, then it will simply result in a docnum of zero, so no attached doc.</summary> public void CreateStatementPdf(Statement stmt,Patient pat,Family fam,DataSet dataSet){ Stmt=stmt; dataSett=dataSet; //dataSet=AccountModuleL.GetStatement(stmt.PatNum,stmt.SinglePatient,stmt.DateRangeFrom,stmt.DateRangeTo, // stmt.Intermingled); //if(ImageStore.UpdatePatient == null){ // ImageStore.UpdatePatient = new FileStore.UpdatePatientDelegate(Patients.Update); //} //The "pat2" could be either the pat or the guarantor Patient pat2=fam.GetPatient(stmt.PatNum); //Patient pat=Patients.GetPat(stmt.PatNum); //imageStore = ImageStore.GetImageStore(pat2); //Save to a temp pdf-------------------------------------------------------------------------- string tempPath=CodeBase.ODFileUtils.CombinePaths(Path.GetTempPath(),pat2.PatNum.ToString()+".pdf"); PrintDocument pd=new PrintDocument(); pd.DefaultPageSettings.Margins=new Margins(40,40,40,60); if(CultureInfo.CurrentCulture.Name.EndsWith("CH")) {//CH is for switzerland. eg de-CH //leave a big margin on the bottom for the routing slip pd.DefaultPageSettings.Margins=new Margins(40,40,40,440);//4.4" from bottom } //pd.OriginAtMargins=true; //fixes a bug if user has label printer as default printer on their computer: if(pd.DefaultPageSettings.PrintableArea.Height<1000 || pd.DefaultPageSettings.PrintableArea.Width<750) { pd.DefaultPageSettings.PaperSize=new PaperSize("default",850,1100); } MigraDoc.DocumentObjectModel.Document doc=CreateDocument(pd,fam,pat,dataSet); MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer=new MigraDoc.Rendering.PdfDocumentRenderer(true,PdfFontEmbedding.Always); pdfRenderer.Document=doc; pdfRenderer.RenderDocument(); pdfRenderer.PdfDocument.Save(tempPath); //get the category----------------------------------------------------------------------------- long category=0; for(int i=0;i<DefC.Short[(int)DefCat.ImageCats].Length;i++){ if(Regex.IsMatch(DefC.Short[(int)DefCat.ImageCats][i].ItemValue,@"S")){ category=DefC.Short[(int)DefCat.ImageCats][i].DefNum; break; } } if(category==0){ category=DefC.Short[(int)DefCat.ImageCats][0].DefNum;//put it in the first category. } //create doc-------------------------------------------------------------------------------------- OpenDentBusiness.Document docc=null; try { docc=ImageStore.Import(tempPath,category,pat2); } catch { MsgBox.Show(this,"Error saving document."); //this.Cursor=Cursors.Default; return; } docc.ImgType=ImageType.Document; if(Stmt.IsInvoice) { docc.Description=Lan.g(this,"Invoice"); } else { if(Stmt.IsReceipt==true) { docc.Description=Lan.g(this,"Receipt"); } else { docc.Description=Lan.g(this,"Statement"); } } docc.DateCreated=stmt.DateSent; Documents.Update(docc); stmt.DocNum=docc.DocNum;//this signals the calling class that the pdf was created successfully. Statements.AttachDoc(stmt.StatementNum,docc.DocNum); }
private void ToolBarMainCreate_Click(){//Save TP if(gridPlans.SelectedIndices[0]!=0){ MsgBox.Show(this,"The default TP must be selected before saving a TP. You can highlight some procedures in the default TP to save a TP with only those procedures in it."); return; } //Check for duplicate procedures on the appointment before sending the DFT to eCW. if(Programs.UsingEcwTightOrFullMode() && Bridges.ECW.AptNum!=0) { List<Procedure> procs=Procedures.GetProcsForSingle(Bridges.ECW.AptNum,false); string duplicateProcs=ProcedureL.ProcsContainDuplicates(procs); if(duplicateProcs!="") { MessageBox.Show(duplicateProcs); return; } } if(gridMain.SelectedIndices.Length==0){ gridMain.SetSelected(true); } TreatPlan tp=new TreatPlan(); tp.Heading=Lan.g(this,"Proposed Treatment Plan"); tp.DateTP=DateTimeOD.Today; tp.PatNum=PatCur.PatNum; tp.Note=PrefC.GetString(PrefName.TreatmentPlanNote); tp.ResponsParty=PatCur.ResponsParty; TreatPlans.Insert(tp); ProcTP procTP; Procedure proc; int itemNo=0; List<Procedure> procList=new List<Procedure>(); for(int i=0;i<gridMain.SelectedIndices.Length;i++){ if(gridMain.Rows[gridMain.SelectedIndices[i]].Tag==null){ //user must have highlighted a subtotal row. continue; } proc=(Procedure)gridMain.Rows[gridMain.SelectedIndices[i]].Tag; procList.Add(proc); procTP=new ProcTP(); procTP.TreatPlanNum=tp.TreatPlanNum; procTP.PatNum=PatCur.PatNum; procTP.ProcNumOrig=proc.ProcNum; procTP.ItemOrder=itemNo; procTP.Priority=proc.Priority; procTP.ToothNumTP=Tooth.ToInternat(proc.ToothNum); if(ProcedureCodes.GetProcCode(proc.CodeNum).TreatArea==TreatmentArea.Surf){ procTP.Surf=Tooth.SurfTidyFromDbToDisplay(proc.Surf,proc.ToothNum); } else{ procTP.Surf=proc.Surf;//for UR, L, etc. } procTP.ProcCode=ProcedureCodes.GetStringProcCode(proc.CodeNum); procTP.Descript=RowsMain[gridMain.SelectedIndices[i]].Description; if(checkShowFees.Checked){ procTP.FeeAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].Fee.ToString()); } if(checkShowIns.Checked){ procTP.PriInsAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].PriIns.ToString()); procTP.SecInsAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].SecIns.ToString()); } if(checkShowDiscount.Checked){ procTP.Discount=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].Discount.ToString()); } if(checkShowIns.Checked){ procTP.PatAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].Pat.ToString()); } procTP.Prognosis=RowsMain[gridMain.SelectedIndices[i]].Prognosis; procTP.Dx=RowsMain[gridMain.SelectedIndices[i]].Dx; ProcTPs.InsertOrUpdate(procTP,true); itemNo++; #region Canadian Lab Fees /* proc=(Procedure)gridMain.Rows[gridMain.SelectedIndices[i]].Tag; procTP=new ProcTP(); procTP.TreatPlanNum=tp.TreatPlanNum; procTP.PatNum=PatCur.PatNum; procTP.ProcNumOrig=proc.ProcNum; procTP.ItemOrder=itemNo; procTP.Priority=proc.Priority; procTP.ToothNumTP=""; procTP.Surf=""; procTP.Code=proc.LabProcCode; procTP.Descript=gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Description"))].Text; if(checkShowFees.Checked) { procTP.FeeAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Fee"))].Text); } if(checkShowIns.Checked) { procTP.PriInsAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Pri Ins"))].Text); procTP.SecInsAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Sec Ins"))].Text); procTP.PatAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Pat"))].Text); } ProcTPs.InsertOrUpdate(procTP,true); itemNo++;*/ #endregion Canadian Lab Fees } //Send TP DFT HL7 message to ECW with embedded PDF when using tight or full integration only. if(Programs.UsingEcwTightOrFullMode() && Bridges.ECW.AptNum!=0){ PrepImageForPrinting(); MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer=new MigraDoc.Rendering.PdfDocumentRenderer(true,PdfFontEmbedding.Always); pdfRenderer.Document=CreateDocument(); 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); if(HL7Defs.IsExistingHL7Enabled()) { //DFT messages that are PDF's only and do not include FT1 segments, so proc list can be empty //MessageConstructor.GenerateDFT(procList,EventTypeHL7.P03,PatCur,Patients.GetPat(PatCur.Guarantor),Bridges.ECW.AptNum,"treatment",pdfDataStr); MessageHL7 messageHL7=MessageConstructor.GenerateDFT(new List<Procedure>(),EventTypeHL7.P03,PatCur,Patients.GetPat(PatCur.Guarantor),Bridges.ECW.AptNum,"treatment",pdfDataStr); if(messageHL7==null) { MsgBox.Show(this,"There is no DFT message type defined for the enabled HL7 definition."); return; } HL7Msg hl7Msg=new HL7Msg(); hl7Msg.AptNum=0;//Prevents the appt complete button from changing to the "Revise" button prematurely. hl7Msg.HL7Status=HL7MessageStatus.OutPending;//it will be marked outSent by the HL7 service. hl7Msg.MsgText=messageHL7.ToString(); hl7Msg.PatNum=PatCur.PatNum; HL7Msgs.Insert(hl7Msg); } else { Bridges.ECW.SendHL7(Bridges.ECW.AptNum,PatCur.PriProv,PatCur,pdfDataStr,"treatment",true); } } ModuleSelected(PatCur.PatNum); for(int i=0;i<PlanList.Length;i++){ if(PlanList[i].TreatPlanNum==tp.TreatPlanNum){ gridPlans.SetSelected(i+1,true); FillMain(); } } }
private void ToolBarMainEmail_Click() { if(PrefC.GetBool(PrefName.FuchsOptionsOn)) { if(checkShowDiscount.Checked || checkShowIns.Checked) { if(MessageBox.Show(this,string.Format(Lan.g(this,"Do you want to remove insurance estimates and PPO discounts from e-mailed treatment plan?")),"Open Dental",MessageBoxButtons.YesNo,MessageBoxIcon.Question) != DialogResult.No) { checkShowDiscount.Checked=false; checkShowIns.Checked=false; FillMain(); } } } PrepImageForPrinting(); string attachPath=EmailMessages.GetEmailAttachPath(); Random rnd=new Random(); string fileName=DateTime.Now.ToString("yyyyMMdd")+"_"+DateTime.Now.TimeOfDay.Ticks.ToString()+rnd.Next(1000).ToString()+".pdf"; string filePathAndName=ODFileUtils.CombinePaths(attachPath,fileName); MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer=new MigraDoc.Rendering.PdfDocumentRenderer(true,PdfFontEmbedding.Always); pdfRenderer.Document=CreateDocument(); pdfRenderer.RenderDocument(); pdfRenderer.PdfDocument.Save(filePathAndName); //Process.Start(filePathAndName); EmailMessage message=new EmailMessage(); message.PatNum=PatCur.PatNum; message.ToAddress=PatCur.Email; message.FromAddress=EmailAddresses.GetByClinic(PatCur.ClinicNum).SenderAddress; message.Subject=Lan.g(this,"Treatment Plan"); EmailAttach attach=new EmailAttach(); attach.DisplayedFileName="TreatmentPlan.pdf"; attach.ActualFileName=fileName; message.Attachments.Add(attach); FormEmailMessageEdit FormE=new FormEmailMessageEdit(message); FormE.IsNew=true; FormE.ShowDialog(); //if(FormE.DialogResult==DialogResult.OK) { // RefreshCurrentModule(); //} }
private void OnCreate_Click() { if(gridPlans.SelectedIndices[0]!=0){ MsgBox.Show(this,"The default TP must be selected before saving a TP. You can highlight some procedures in the default TP to save a TP with only those procedures in it."); return; } if(gridMain.SelectedIndices.Length==0){ gridMain.SetSelected(true); } TreatPlan tp=new TreatPlan(); tp.Heading=Lan.g(this,"Proposed Treatment Plan"); tp.DateTP=DateTime.Today; tp.PatNum=PatCur.PatNum; tp.Note=PrefC.GetString(PrefName.TreatmentPlanNote); tp.ResponsParty=PatCur.ResponsParty; TreatPlans.Insert(tp); ProcTP procTP; Procedure proc; int itemNo=0; for(int i=0;i<gridMain.SelectedIndices.Length;i++){ if(gridMain.Rows[gridMain.SelectedIndices[i]].Tag==null){ //user must have highlighted a subtotal row. continue; } proc=(Procedure)gridMain.Rows[gridMain.SelectedIndices[i]].Tag; procTP=new ProcTP(); procTP.TreatPlanNum=tp.TreatPlanNum; procTP.PatNum=PatCur.PatNum; procTP.ProcNumOrig=proc.ProcNum; procTP.ItemOrder=itemNo; procTP.Priority=proc.Priority; procTP.ToothNumTP=Tooth.ToInternat(proc.ToothNum); if(ProcedureCodes.GetProcCode(proc.CodeNum).TreatArea==TreatmentArea.Surf){ procTP.Surf=Tooth.SurfTidyFromDbToDisplay(proc.Surf,proc.ToothNum); } else{ procTP.Surf=proc.Surf;//for UR, L, etc. } procTP.ProcCode=ProcedureCodes.GetStringProcCode(proc.CodeNum); procTP.Descript=RowsMain[gridMain.SelectedIndices[i]].Description; if(checkShowFees.Checked){ procTP.FeeAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].Fee.ToString()); } if(checkShowIns.Checked){ procTP.PriInsAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].PriIns.ToString()); procTP.SecInsAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].SecIns.ToString()); } if(checkShowDiscount.Checked){ procTP.Discount=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].Discount.ToString()); } if(checkShowIns.Checked){ procTP.PatAmt=PIn.Double(RowsMain[gridMain.SelectedIndices[i]].Pat.ToString()); } procTP.Prognosis=RowsMain[gridMain.SelectedIndices[i]].Prognosis; procTP.Dx=RowsMain[gridMain.SelectedIndices[i]].Dx; ProcTPs.InsertOrUpdate(procTP,true); itemNo++; #region Canadian Lab Fees /* proc=(Procedure)gridMain.Rows[gridMain.SelectedIndices[i]].Tag; procTP=new ProcTP(); procTP.TreatPlanNum=tp.TreatPlanNum; procTP.PatNum=PatCur.PatNum; procTP.ProcNumOrig=proc.ProcNum; procTP.ItemOrder=itemNo; procTP.Priority=proc.Priority; procTP.ToothNumTP=""; procTP.Surf=""; procTP.Code=proc.LabProcCode; procTP.Descript=gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Description"))].Text; if(checkShowFees.Checked) { procTP.FeeAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Fee"))].Text); } if(checkShowIns.Checked) { procTP.PriInsAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Pri Ins"))].Text); procTP.SecInsAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Sec Ins"))].Text); procTP.PatAmt=PIn.PDouble(gridMain.Rows[gridMain.SelectedIndices[i]] .Cells[gridMain.Columns.GetIndex(Lan.g("TableTP","Pat"))].Text); } ProcTPs.InsertOrUpdate(procTP,true); itemNo++;*/ #endregion Canadian Lab Fees } //Send TP DFT HL7 message to ECW with embedded PDF when using tight integration only. if(Programs.UsingEcwTight()){ PrepImageForPrinting(); MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer=new MigraDoc.Rendering.PdfDocumentRenderer(true,PdfFontEmbedding.Always); pdfRenderer.Document=CreateDocument(); 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); Bridges.ECW.SendHL7(Bridges.ECW.AptNum,PatCur.PriProv,PatCur,pdfDataStr,"treatment",true); } ModuleSelected(PatCur.PatNum); for(int i=0;i<PlanList.Length;i++){ if(PlanList[i].TreatPlanNum==tp.TreatPlanNum){ gridPlans.SetSelected(i+1,true); FillMain(); } } }
private void btnDownloadQRCode_Click(object sender, EventArgs e) { if (fileDialog.ShowDialog() == DialogResult.OK) { var document = new MigraDoc.DocumentObjectModel.Document(); Style style = document.Styles["Normal"]; style.Font.Name = "Verdana"; style = document.Styles[StyleNames.Header]; style.ParagraphFormat.AddTabStop("16cm", MigraDoc.DocumentObjectModel.TabAlignment.Right); style = document.Styles[StyleNames.Footer]; style.ParagraphFormat.AddTabStop("8cm", MigraDoc.DocumentObjectModel.TabAlignment.Center); // Create a new style called Table based on style Normal style = document.Styles.AddStyle("Table", "Normal"); style.Font.Name = "Verdana"; style.Font.Name = "Arial"; style.Font.Size = 8; document.DefaultPageSetup.BottomMargin = Unit.FromInch(0.5); document.DefaultPageSetup.TopMargin = Unit.FromInch(0.5); document.DefaultPageSetup.RightMargin = Unit.FromInch(0.5); document.DefaultPageSetup.LeftMargin = Unit.FromInch(0.5); document.DefaultPageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape; // Each MigraDoc document needs at least one section. Section section = document.AddSection(); // Create header Paragraph paragraph1 = section.AddParagraph(); paragraph1.AddText("Read Only Connection Code"); paragraph1.Format.Font.Size = 24; paragraph1.Format.Font.Bold = true; paragraph1.Format.Alignment = ParagraphAlignment.Left; paragraph1.Format.SpaceAfter = new Unit(16.0); paragraph1.Format.SpaceBefore = new Unit(0.0); Paragraph paragraph2 = section.AddParagraph(); paragraph2.AddText("Use this code to share client, farm, and field lists with RFID Module Scan. Open the RFID Module Scan app, goto \"Settings\", tap \"Connect to Gin\", and then scan this code with the device camera."); paragraph2.Format.Font.Size = 8; paragraph2.Format.Font.Bold = true; paragraph2.Format.Alignment = ParagraphAlignment.Left; paragraph2.Format.SpaceAfter = new Unit(16.0); paragraph2.Format.SpaceBefore = new Unit(0.0); // Create footer /*Paragraph paragraph = section.Footers.Primary.AddParagraph(); * paragraph.AddText(string.Format("- Generated {0} {1} -", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString())); * paragraph.Format.Font.Size = 8; * paragraph.Format.Alignment = ParagraphAlignment.Center;*/ pictureBoxQRCode.Image.Save("connection_code.bmp"); var image = section.AddImage("connection_code.bmp"); image.Width = new Unit(2.0, UnitType.Inch); image.Height = new Unit(2.0, UnitType.Inch); var pdfRenderer = new MigraDoc.Rendering.PdfDocumentRenderer(false); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); pdfRenderer.PdfDocument.Save(fileDialog.FileName); System.Diagnostics.Process.Start(fileDialog.FileName); this.Close(); } }
public void Print() { var doc = new MigraDoc.DocumentObjectModel.Document(); var s = doc.AddSection(); s.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape; s.PageSetup.PageFormat = MigraDoc.DocumentObjectModel.PageFormat.A4; s.PageSetup.TopMargin = "2cm"; s.PageSetup.BottomMargin = "2cm"; s.PageSetup.LeftMargin = "2cm"; s.PageSetup.RightMargin = "3cm"; var tbl = s.AddTable(); tbl.Borders.Visible = true; // Footer var p = s.Footers.Primary.AddParagraph(); p.Format.Font.Size = 10; p.Format.AddTabStop("245mm", MigraDoc.DocumentObjectModel.TabAlignment.Right); p.AddText(DateTime.Today.ToShortDateString()); p.AddTab(); p.AddPageField(); p.AddText("/"); p.AddNumPagesField(); var cols = DisplayedColumns.Columns .Where(i => i.Type != ColumnDisplayModel.ColumnType.MethodModel) .ToList(); // TODO: Calc width more sophisticated var width = new MigraDoc.DocumentObjectModel.Unit(250.0 * (1.0 / (double)cols.Count), MigraDoc.DocumentObjectModel.UnitType.Millimeter); // Header for (int colIdx = 0; colIdx < cols.Count; colIdx++) { //var col = cols[colIdx]; tbl.AddColumn(width); } var row = tbl.AddRow(); row.HeadingFormat = true; for (int colIdx = 0; colIdx < cols.Count; colIdx++) { var col = cols[colIdx]; p = row.Cells[colIdx].AddParagraph(col.Header ?? string.Empty); p.Format.Font.Bold = true; } // Data foreach (var obj in Instances) { row = tbl.AddRow(); for (int colIdx = 0; colIdx < cols.Count; colIdx++) { string val = cols[colIdx].ExtractFormattedValue(obj); p = row.Cells[colIdx].AddParagraph(val ?? string.Empty); } } var filename = tmpService.Create("Export.pdf"); var pdf = new MigraDoc.Rendering.PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.None); pdf.Document = doc; pdf.RenderDocument(); pdf.Save(filename); fileOpener.ShellExecute(filename); }
private static MigraDoc.Rendering.PdfDocumentRenderer CreateHomeGroupAttendanceDocument(string groupName, List<AttendanceEventViewModel> attendees, Dictionary<int, string> comments) { // Create new MigraDoc document Document document = new Document(); document.Info.Title = groupName; document.Info.Author = "oikonomos"; document.Info.Subject = "Homegroup Attendance for " + groupName; Section sec = document.AddSection(); sec.PageSetup.TopMargin = Unit.FromCentimeter(1); sec.PageSetup.LeftMargin = Unit.FromCentimeter(1); document.DefaultPageSetup.TopMargin = Unit.FromCentimeter(1); document.DefaultPageSetup.LeftMargin = Unit.FromCentimeter(1); Paragraph p = sec.Headers.Primary.AddParagraph(); p.AddText("Homegroup Attendance for " + groupName); p.Format.Font.Size = 10.0; p.Format.Font.Bold = true; p.Format.Alignment = ParagraphAlignment.Center; Paragraph pf = new Paragraph(); pf.AddText("Date: " + DateTime.Now.ToString("dd MMM yyyy")); pf.Format.Font.Size = 6.0; sec.Footers.Primary.Add(pf); //Work out which distinct days there are in each month List<int> month1Events = new List<int>(); List<int> month2Events = new List<int>(); int month1 = DateTime.Now.AddMonths(-1).Month; int month2 = DateTime.Now.Month; GetAttendanceDays(attendees, month1Events, month2Events, month1, month2); if (month1Events.Count == 0) { month1Events.Add(1); } if (month2Events.Count == 0) { month2Events.Add(1); } MigraDoc.DocumentObjectModel.Tables.Table attendeesTable = new MigraDoc.DocumentObjectModel.Tables.Table(); int totalColumns = AddAttendanceHeaders(month1, month2, month1Events, month2Events, attendeesTable, "Members"); AddAttendanceData(attendees, document, month1Events, month2Events, month1, month2, attendeesTable, totalColumns, comments); sec.Add(attendeesTable); document.LastSection.PageSetup.TopMargin = Unit.FromMillimeter(20); MigraDoc.Rendering.PdfDocumentRenderer pdfRender = new MigraDoc.Rendering.PdfDocumentRenderer(false, PdfSharp.Pdf.PdfFontEmbedding.Always); pdfRender.Document = document; //document is where all of my info has been written to and is a MigraDoc type pdfRender.RenderDocument(); return pdfRender; }
private static MigraDoc.Rendering.PdfDocumentRenderer CreateHomeGroupListDocument(string groupName, List<PersonViewModel> personList) { // Create new MigraDoc document Document document = new Document(); document.Info.Title = groupName; document.Info.Author = "oikonomos"; document.Info.Subject = "Group List for " + groupName; Section sec = document.AddSection(); sec.PageSetup.TopMargin = Unit.FromCentimeter(1); sec.PageSetup.LeftMargin = Unit.FromCentimeter(1); document.DefaultPageSetup.TopMargin = Unit.FromCentimeter(1); document.DefaultPageSetup.LeftMargin = Unit.FromCentimeter(1); Paragraph p = sec.Headers.Primary.AddParagraph(); p.AddText("Group List for " + groupName); p.Format.Font.Size = 10.0; p.Format.Font.Bold = true; p.Format.Alignment = ParagraphAlignment.Center; Paragraph pf = new Paragraph(); pf.AddText("Date: " + DateTime.Now.ToString("dd MMM yyyy")); pf.Format.Font.Size = 6.0; sec.Footers.Primary.Add(pf); MigraDoc.DocumentObjectModel.Tables.Table membersTable = new MigraDoc.DocumentObjectModel.Tables.Table(); personList = personList.OrderBy(x => x.RoleName).ThenBy(x => x.Surname).ThenBy(x => x.PersonId).ToList(); AddHeaders(membersTable, null); AddHomegroupData(document, personList, membersTable); MigraDoc.DocumentObjectModel.Tables.Table visitorsTable = new MigraDoc.DocumentObjectModel.Tables.Table(); sec.Add(membersTable); document.LastSection.PageSetup.TopMargin = Unit.FromMillimeter(20); MigraDoc.Rendering.PdfDocumentRenderer pdfRender = new MigraDoc.Rendering.PdfDocumentRenderer(false, PdfSharp.Pdf.PdfFontEmbedding.Always); pdfRender.Document = document; //document is where all of my info has been written to and is a MigraDoc type pdfRender.RenderDocument(); return pdfRender; }
private static MigraDoc.Rendering.PdfDocumentRenderer CreatePeopleListDocument(Person currentUser, List<PersonListViewModel> churchList, string documentType) { // Create new MigraDoc document Document document = new Document(); document.Info.Title = documentType + " List for " + currentUser.Church.Name; document.Info.Author = "oikonomos"; document.Info.Subject = documentType + " List"; Section sec = document.AddSection(); sec.PageSetup.TopMargin = Unit.FromCentimeter(1); sec.PageSetup.LeftMargin = Unit.FromCentimeter(1); document.DefaultPageSetup.TopMargin = Unit.FromCentimeter(1); document.DefaultPageSetup.LeftMargin = Unit.FromCentimeter(1); Paragraph p = new Paragraph(); p.AddText(documentType + " List for " + currentUser.Church.Name); p.Format.Font.Size = 6.0; sec.Footers.Primary.Add(p); MigraDoc.DocumentObjectModel.Tables.Table table = new MigraDoc.DocumentObjectModel.Tables.Table(); AddHeaders(table, documentType + "s"); var style = document.Styles["Normal"]; style.Font.Size = 8.0; TextMeasurement tm = new TextMeasurement(style.Font.Clone()); int familyId = 0; foreach (PersonListViewModel person in churchList) { Row row=table.AddRow(); Cell cell = row.Cells[0]; if (familyId != person.FamilyId) { cell.Format.Font.Bold = true; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.Surname, tm)); } cell = row.Cells[1]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.Firstname, tm)); cell = row.Cells[2]; if (familyId != person.FamilyId) { cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.HomePhone ?? string.Empty, tm)); } cell = row.Cells[3]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.WorkPhone ?? string.Empty, tm)); cell = row.Cells[4]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.CellPhone ?? string.Empty, tm)); cell = row.Cells[5]; cell.AddParagraph(AdjustIfTooWideToFitIn(cell, person.Email ?? string.Empty, tm)); familyId = person.FamilyId; } sec.Add(table); MigraDoc.Rendering.PdfDocumentRenderer pdfRender = new MigraDoc.Rendering.PdfDocumentRenderer(false, PdfSharp.Pdf.PdfFontEmbedding.Always); pdfRender.Document = document; //document is where all of my info has been written to and is a MigraDoc type pdfRender.RenderDocument(); return pdfRender; }
///<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 ToolBarMainPrint_Click() { if(PrefC.GetBool(PrefName.FuchsOptionsOn)) { if(checkShowDiscount.Checked || checkShowIns.Checked) { if(MessageBox.Show(this,string.Format(Lan.g(this,"Do you want to remove insurance estimates and discounts from printed treatment plan?")),"Open Dental",MessageBoxButtons.YesNo,MessageBoxIcon.Question) != DialogResult.No) { checkShowDiscount.Checked=false; checkShowIns.Checked=false; FillMain(); } } } PrepImageForPrinting(); MigraDoc.DocumentObjectModel.Document doc=CreateDocument(); 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 pView = new FormRpPrintPreview(); pView.printPreviewControl2.Document=printdoc; pView.ShowDialog(); #else if(PrinterL.SetPrinter(pd2,PrintSituation.TPPerio,PatCur.PatNum,"Treatment plan for printed")){ printdoc.PrinterSettings=pd2.PrinterSettings; printdoc.Print(); } #endif long category=0; OpenDentBusiness.Document docSave = new OpenDentBusiness.Document(); MigraDoc.Rendering.PdfDocumentRenderer pdfRenderer = new MigraDoc.Rendering.PdfDocumentRenderer(false,PdfFontEmbedding.Always); pdfRenderer.Document=CreateDocument(); pdfRenderer.RenderDocument(); //Check if there are any image category definitions with "TreatPlans" for(int i=0;i<DefC.Short[(int)DefCat.ImageCats].Length;i++) { if((DefC.Short[(int)DefCat.ImageCats][i].ItemValue=="R" || DefC.Short[(int)DefCat.ImageCats][i].ItemValue=="XR") && PrefC.AtoZfolderUsed) { long docNum=Documents.Insert(docSave); category=DefC.Short[(int)DefCat.ImageCats][i].DefNum; string filePath=ImageStore.GetPatientFolder(PatCur,ImageStore.GetPreferredAtoZpath()); string fileName="TPArchive"+docSave.DocNum; //Then create a PDF and save it to the AtoZ folder if AtoZ pref is on. byte[] rawData= { }; if(PrefC.AtoZfolderUsed) { if(filePath.EndsWith("\\")) { } else { filePath+="\\"; } pdfRenderer.Save(filePath+fileName+".pdf"); } //Currently never going to get hit because of AtoZ folder check above. This is due to AxAcroPDF functionality. else {//saving to db using(MemoryStream stream=new MemoryStream()) { pdfRenderer.Save(stream,false); rawData=stream.ToArray(); stream.Close(); } } docSave.ImgType=ImageType.Document; docSave.DateCreated=DateTime.Today; docSave.PatNum=PatCur.PatNum; docSave.DocCategory=category; docSave.Description=fileName; if(!PrefC.AtoZfolderUsed) { docSave.RawBase64=Convert.ToBase64String(rawData); } else { docSave.FileName=fileName+".pdf"; } Documents.Update(docSave);//creates filename and saves to db } } }