private MigraDoc.DocumentObjectModel.Document CreateDocument()
 {
     MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();
     doc.DefaultPageSetup.PageWidth   = MigraDoc.DocumentObjectModel.Unit.FromInch(8.5);
     doc.DefaultPageSetup.PageHeight  = MigraDoc.DocumentObjectModel.Unit.FromInch(11);
     doc.DefaultPageSetup.TopMargin   = MigraDoc.DocumentObjectModel.Unit.FromInch(.5);
     doc.DefaultPageSetup.LeftMargin  = MigraDoc.DocumentObjectModel.Unit.FromInch(.5);
     doc.DefaultPageSetup.RightMargin = MigraDoc.DocumentObjectModel.Unit.FromInch(.5);
     MigraDoc.DocumentObjectModel.Section section        = doc.AddSection();
     MigraDoc.DocumentObjectModel.Font    headingFont    = MigraDocHelper.CreateFont(13, true);
     MigraDoc.DocumentObjectModel.Font    subHeadingFont = MigraDocHelper.CreateFont(10, true);
     #region printHeading
     //Heading---------------------------------------------------------------------------------------------------------------
     MigraDoc.DocumentObjectModel.Paragraph       par       = section.AddParagraph();
     MigraDoc.DocumentObjectModel.ParagraphFormat parformat = new MigraDoc.DocumentObjectModel.ParagraphFormat();
     parformat.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
     par.Format          = parformat;
     string text = Lans.g(this, "Service Date View");
     par.AddFormattedText(text, headingFont);
     par.AddLineBreak();
     //SubHeading---------------------------------------------------------------------------------------------------------------
     text = (IsFamily ? Lans.g(this, "Entire Family:") + " " : "") + $"{_fam.GetNameInFamFL(PatNum)}";
     par.AddFormattedText(text, subHeadingFont);
     par.AddLineBreak();
     text = Lans.g(this, "Date") + " " + DateTime.Now.ToShortDateString();
     par.AddFormattedText(text, subHeadingFont);
     #endregion
     MigraDocHelper.InsertSpacer(section, 10);
     section.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape;
     MigraDocHelper.DrawGrid(section, gridMain);
     return(doc);
 }
Beispiel #2
0
        private MigraDoc.DocumentObjectModel.Document CreatePrintDocument(PrintDocument pd)
        {
            string text;

            MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();
            doc.DefaultPageSetup.PageWidth    = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Width / 100);
            doc.DefaultPageSetup.PageHeight   = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Height / 100);
            doc.DefaultPageSetup.TopMargin    = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Top / 100);
            doc.DefaultPageSetup.LeftMargin   = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Left / 100);
            doc.DefaultPageSetup.RightMargin  = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Right / 100);
            doc.DefaultPageSetup.BottomMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Bottom / 100);
            MigraDoc.DocumentObjectModel.Section section = doc.AddSection();
            section.PageSetup.StartingNumber = 1;
            MigraDoc.DocumentObjectModel.Font headingFont = MigraDocHelper.CreateFont(13, true);
            MigraDoc.DocumentObjectModel.Font bodyFontx   = MigraDocHelper.CreateFont(9, false);
            MigraDoc.DocumentObjectModel.Font nameFontx   = MigraDocHelper.CreateFont(9, true);
            MigraDoc.DocumentObjectModel.Font totalFontx  = MigraDocHelper.CreateFont(9, true);
            Paragraph pageNumParag = new Paragraph();

            pageNumParag.AddText(Lan.g(this, "Page") + " ");
            pageNumParag.AddPageField();
            pageNumParag.AddText(" " + Lan.g(this, "of") + " ");
            pageNumParag.AddNumPagesField();
            section.Footers.Primary.Add(pageNumParag);
            Paragraph       par       = section.AddParagraph();
            ParagraphFormat parformat = new ParagraphFormat();

            parformat.Alignment = ParagraphAlignment.Center;
            parformat.Font      = MigraDocHelper.CreateFont(14, true);
            par.Format          = parformat;
            //Render the reconcile grid.
            par = section.AddParagraph();
            par.Format.Alignment = ParagraphAlignment.Center;
            par.AddFormattedText(Lan.g(this, "RECONCILE"), totalFontx);
            par.AddLineBreak();
            text = Accounts.GetAccount(ReconcileCur.AccountNum).Description.ToUpper();
            par.AddFormattedText(text, totalFontx);
            par.AddLineBreak();
            text = PrefC.GetString(PrefName.PracticeTitle);
            par.AddText(text);
            par.AddLineBreak();
            text = PrefC.GetString(PrefName.PracticePhone);
            if (text.Length == 10 && Application.CurrentCulture.Name == "en-US")
            {
                text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6);
            }
            par.AddText(text);
            par.AddLineBreak();
            par.AddText(MiscData.GetNowDateTime().ToShortDateString());
            par.AddLineBreak();
            par.AddText(Lan.g(this, "Reconcile Date") + ": " + PIn.Date(textDate.Text).ToShortDateString());
            par.AddLineBreak();
            par.AddText(labelStart.Text + ": " + PIn.Double(textStart.Text).ToString("n"));
            par.AddLineBreak();
            par.AddText(labelEnd.Text + ": " + PIn.Double(textEnd.Text).ToString("n"));
            MigraDocHelper.InsertSpacer(section, 10);
            MigraDocHelper.DrawGrid(section, gridMain);
            return(doc);
        }
Beispiel #3
0
        private void PrintReceipt(string receiptStr)
        {
            string[] receiptLines = receiptStr.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();
            doc.DefaultPageSetup.PageWidth   = Unit.FromInch(3.0);
            doc.DefaultPageSetup.PageHeight  = Unit.FromInch(0.181 * receiptLines.Length + 0.56);     //enough to print receipt text plus 9/16 inch (0.56) extra space at bottom.
            doc.DefaultPageSetup.TopMargin   = Unit.FromInch(0.25);
            doc.DefaultPageSetup.LeftMargin  = Unit.FromInch(0.25);
            doc.DefaultPageSetup.RightMargin = Unit.FromInch(0.25);
            MigraDoc.DocumentObjectModel.Font bodyFontx = MigraDocHelper.CreateFont(8, false);
            bodyFontx.Name = FontFamily.GenericMonospace.Name;
            MigraDoc.DocumentObjectModel.Section section = doc.AddSection();
            Paragraph       par       = section.AddParagraph();
            ParagraphFormat parformat = new ParagraphFormat();

            parformat.Alignment = ParagraphAlignment.Left;
            parformat.Font      = bodyFontx;
            par.Format          = parformat;
            par.AddFormattedText(receiptStr, bodyFontx);
            MigraDoc.Rendering.Printing.MigraDocPrintDocument printdoc = new MigraDoc.Rendering.Printing.MigraDocPrintDocument();
            MigraDoc.Rendering.DocumentRenderer renderer = new MigraDoc.Rendering.DocumentRenderer(doc);
            renderer.PrepareDocument();
            printdoc.Renderer = renderer;
#if DEBUG
            FormRpPrintPreview pView = new FormRpPrintPreview(printdoc);
            pView.ShowDialog();
#else
            try {
                ODprintout printout = PrinterL.CreateODprintout(
                    printSit: PrintSituation.Receipt,
                    auditPatNum: _patCur.PatNum,
                    auditDescription: Lans.g(this, "PayConnect receipt printed")
                    );
                if (PrinterL.TrySetPrinter(printout))
                {
                    printdoc.PrinterSettings = printout.PrintDoc.PrinterSettings;
                    printdoc.Print();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(Lan.g(this, "Printer not available.") + "\r\n" + Lan.g(this, "Original error") + ": " + ex.Message);
            }
#endif
        }
        private MigraDoc.DocumentObjectModel.Document CreatePrintDocument()
        {
            string text;

            MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();
            doc.DefaultPageSetup.PageWidth   = Unit.FromInch(8.5);
            doc.DefaultPageSetup.PageHeight  = Unit.FromInch(11);
            doc.DefaultPageSetup.TopMargin   = Unit.FromInch(.5);
            doc.DefaultPageSetup.LeftMargin  = Unit.FromInch(.5);
            doc.DefaultPageSetup.RightMargin = Unit.FromInch(.5);
            MigraDoc.DocumentObjectModel.Section section     = doc.AddSection();
            MigraDoc.DocumentObjectModel.Font    headingFont = MigraDocHelper.CreateFont(13, true);
            MigraDoc.DocumentObjectModel.Font    bodyFontx   = MigraDocHelper.CreateFont(9, false);
            MigraDoc.DocumentObjectModel.Font    nameFontx   = MigraDocHelper.CreateFont(9, true);
            MigraDoc.DocumentObjectModel.Font    totalFontx  = MigraDocHelper.CreateFont(9, true);
            Paragraph       par       = section.AddParagraph();
            ParagraphFormat parformat = new ParagraphFormat();

            parformat.Alignment = ParagraphAlignment.Center;
            parformat.Font      = MigraDocHelper.CreateFont(14, true);
            par.Format          = parformat;
            //Render the reconcile grid.
            par = section.AddParagraph();
            par.Format.Alignment = ParagraphAlignment.Center;
            par.AddFormattedText(Lan.g(this, "RECONCILE"), totalFontx);
            par.AddLineBreak();
            text = Accounts.GetAccount(ReconcileCur.AccountNum).Description.ToUpper();
            par.AddFormattedText(text, totalFontx);
            par.AddLineBreak();
            text = PrefC.GetString(PrefName.PracticeTitle);
            par.AddText(text);
            par.AddLineBreak();
            text = PrefC.GetString(PrefName.PracticePhone);
            if (text.Length == 10 && Application.CurrentCulture.Name == "en-US")
            {
                text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6);
            }
            par.AddText(text);
            MigraDocHelper.InsertSpacer(section, 10);
            MigraDocHelper.DrawGrid(section, gridMain);
            return(doc);
        }
Beispiel #5
0
        private void PrintReceipt(string receiptStr)
        {
            string[] receiptLines = receiptStr.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();
            doc.DefaultPageSetup.PageWidth   = Unit.FromInch(3.0);
            doc.DefaultPageSetup.PageHeight  = Unit.FromInch(0.181 * receiptLines.Length + 0.56);     //enough to print receipt text plus 9/16 inch (0.56) extra space at bottom.
            doc.DefaultPageSetup.TopMargin   = Unit.FromInch(0.25);
            doc.DefaultPageSetup.LeftMargin  = Unit.FromInch(0.25);
            doc.DefaultPageSetup.RightMargin = Unit.FromInch(0.25);
            MigraDoc.DocumentObjectModel.Font bodyFontx = MigraDocHelper.CreateFont(8, false);
            bodyFontx.Name = FontFamily.GenericMonospace.Name;
            MigraDoc.DocumentObjectModel.Section section = doc.AddSection();
            Paragraph       par       = section.AddParagraph();
            ParagraphFormat parformat = new ParagraphFormat();

            parformat.Alignment = ParagraphAlignment.Left;
            parformat.Font      = bodyFontx;
            par.Format          = parformat;
            par.AddFormattedText(receiptStr, bodyFontx);
            MigraDoc.Rendering.Printing.MigraDocPrintDocument printdoc = new MigraDoc.Rendering.Printing.MigraDocPrintDocument();
            MigraDoc.Rendering.DocumentRenderer renderer = new MigraDoc.Rendering.DocumentRenderer(doc);
            renderer.PrepareDocument();
            printdoc.Renderer = renderer;
            //we might want to surround some of this with a try-catch
#if DEBUG
            FormRpPrintPreview pView = new FormRpPrintPreview();
            pView.printPreviewControl2.Document = printdoc;
            pView.ShowDialog();
#else
            if (PrinterL.SetPrinter(pd2, PrintSituation.Receipt, PatCur.PatNum, "PayConnect receipt printed"))
            {
                printdoc.PrinterSettings = pd2.PrinterSettings;
                printdoc.Print();
            }
#endif
        }