Beispiel #1
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            PrintDocument pd = new PrintDocument();          //TODO: Implement ODprintout pattern - MigraDoc

            if (!PrinterL.SetPrinter(pd, PrintSituation.Default, 0, "Reconcile list printed"))
            {
                return;                //User cancelled.
            }
            pd.DefaultPageSettings.Margins = new Margins(25, 25, 40, 40);
            if (pd.DefaultPageSettings.PrintableArea.Height == 0)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
            }
            MigraDoc.DocumentObjectModel.Document             doc      = CreatePrintDocument(pd);
            MigraDoc.Rendering.Printing.MigraDocPrintDocument printdoc = new MigraDoc.Rendering.Printing.MigraDocPrintDocument();
            MigraDoc.Rendering.DocumentRenderer renderer = new MigraDoc.Rendering.DocumentRenderer(doc);
            renderer.PrepareDocument();
            printdoc.PrinterSettings = pd.PrinterSettings;
            printdoc.Renderer        = renderer;
#if DEBUG
            FormRpPrintPreview pView = new FormRpPrintPreview(printdoc);
            pView.ShowDialog();
#else
            printdoc.Print();
#endif
        }
Beispiel #2
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 void butPrint_Click(object sender, EventArgs e)
        {
            MigraDoc.DocumentObjectModel.Document             doc      = CreatePrintDocument();
            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();
            pView.printPreviewControl2.Document = printdoc;
            pView.ShowDialog();
#else
            //Always prints to the Windows default printer.
            if (PrinterL.SetPrinter(pd2, PrintSituation.Default, 0, "Reconcile list printed"))
            {
                printdoc.Print();
            }
#endif
        }
Beispiel #4
0
        // ====================================================================================================
        // USEFULL MIGRADOC EXAMPLES ==========================================================================
        // ====================================================================================================

        static void SamplePage1(PdfDocument document)
        {
            PdfPage   page = document.AddPage();
            XGraphics gfx  = XGraphics.FromPdfPage(page);

            // HACK²
            gfx.MUH = PdfFontEncoding.Unicode;
            //gfx.MFEH = PdfFontEmbedding.Default;

            //XFont font = new XFont("Verdana", 13, XFontStyle.Bold);
            //gfx.DrawString("The following paragraph was rendered using MigraDoc:", font, XBrushes.Black,
            //    new XRect(100, 100, page.Width - 200, 300), XStringFormats.Center);

            // You always need a MigraDoc document for rendering.
            Document doc = new Document();
            Section  sec = doc.AddSection();
            // Add a single paragraph with some text and format information.
            Paragraph para = sec.AddParagraph();

            para.Format.Alignment  = ParagraphAlignment.Justify;
            para.Format.Font.Name  = "Times New Roman";
            para.Format.Font.Size  = 12;
            para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
            para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
            para.AddText("Duisism odigna acipsum delesenisl ");
            para.AddFormattedText("ullum in velenit", TextFormat.Bold);
            para.AddText(" ipit iurero dolum zzriliquisis nit wis dolore vel et nonsequipit, velendigna " +
                         "auguercilit lor se dipisl duismod tatem zzrit at laore magna feummod oloborting ea con vel " +
                         "essit augiati onsequat luptat nos diatum vel ullum illummy nonsent nit ipis et nonsequis " +
                         "niation utpat. Odolobor augait et non etueril landre min ut ulla feugiam commodo lortie ex " +
                         "essent augait el ing eumsan hendre feugait prat augiatem amconul laoreet. ≤≥≈≠");
            para.Format.Borders.Distance = "5pt";
            para.Format.Borders.Color    = Colors.Gold;

            // Create a renderer and prepare (=layout) the document
            MigraDoc.Rendering.DocumentRenderer docRenderer = new MigraDoc.Rendering.DocumentRenderer(doc);
            docRenderer.PrepareDocument();

            // Render the paragraph. You can render tables or shapes the same way.
            docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(10), "12cm", para);
        }
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
        }
Beispiel #6
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)){
             printdoc.PrinterSettings=pd2.PrinterSettings;
             printdoc.Print();
         }
     #endif
 }
Beispiel #7
0
        public override PdfDocument ToPdf()
        {
            var watch = new Stopwatch();

            watch.Start();
            //http://www.pdfsharp.net/wiki/Unicode-sample.ashx
            // Create new document
            var document = new PdfDocument();

            var pdfString = "eXPRS Plan of Care - Services Delivered Report Form\n\n" +
                            "Timesheet ID: " + Id + "\n" +
                            "Status of Timesheet: " + Status + "\n" +
                            "Customer Name: " + ClientName + "\n" +
                            "Prime: " + ClientPrime + "\n" +
                            "Provider Name: " + ProviderName + "\n" +
                            "Provider Num: " + ProviderId + "\n" +
                            "CM Organization: Multnomah Case Management\n" +
                            "Form Type: " + FormType + "\n\n" +
                            "Service Goal: " + ServiceGoal + "\n\n" +
                            "Progress Notes: " + ProgressNotes + "\n\n" +
                            "Submitted on: " + Submitted + "\n";

            // Set font encoding to unicode
            var options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            var font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);


            var page = document.AddPage();
            var gfx  = XGraphics.FromPdfPage(page);
            var tf   = new XTextFormatter(gfx)
            {
                Alignment = XParagraphAlignment.Left
            };

            tf.DrawString(pdfString, font, XBrushes.Black,
                          new XRect(100, 100, page.Width - 200, 600), XStringFormats.TopLeft);

            // TABLE
            var doc     = new Document();
            var section = doc.AddSection();
            var table   = section.AddTable();

            table.Style               = "Table";
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent     = 0;

            // Before you can add a row, you must define the columns
            var column = table.AddColumn("2.5cm");

            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn("2.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn("3.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = table.AddColumn("2cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            // Create the header of the table
            var row = table.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = Colors.LightGreen;
            row.Cells[0].AddParagraph("Date");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[1].AddParagraph("Start/Time IN");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[2].AddParagraph("End/Time OUT");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[3].AddParagraph("Total hours for entry");
            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[4].AddParagraph("Group? (yes/no)");
            row.Cells[4].Format.Alignment = ParagraphAlignment.Left;

            double totalHours = 0;

            foreach (var entry in TimeEntries)
            {
                row = table.AddRow();
                row.HeadingFormat    = true;
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Format.Font.Bold = true;
                row.Cells[0].AddParagraph(entry.Date.ToShortDateString());
                row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
                row.Cells[1].AddParagraph(entry.In.ToShortTimeString());
                row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                row.Cells[2].AddParagraph(entry.Out.ToShortTimeString());
                row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
                totalHours += entry.Hours;
                row.Cells[3].AddParagraph(entry.Hours.ToString(CultureInfo.CurrentCulture));
                row.Cells[3].Format.Alignment = ParagraphAlignment.Left;

                row.Cells[4].AddParagraph(entry.Group ? "Yes" : "No");
                row.Cells[4].Format.Alignment = ParagraphAlignment.Left;
            }

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Cells[0].AddParagraph("Total");
            row.Cells[0].MergeRight       = 2;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[3].AddParagraph(totalHours + " Hours");
            row.Cells[3].MergeRight       = 1;
            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;

            table.SetEdge(0, 0, 5, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);

            // Create a renderer and prepare (=layout) the document
            var docRenderer = new MigraDoc.Rendering.DocumentRenderer(doc);

            docRenderer.PrepareDocument();

            // Render the paragraph. You can render tables or shapes the same way.
            docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(13), "12cm", table);

            //END OF TABLE

            //This code section will add new pages with images.
            foreach (var uri in UriList)
            {
                using var wc       = new WebClient();
                using var objImage = XImage.FromStream(wc.OpenRead(uri));
                //do stuff with the image
                var newPage = document.AddPage();
                var gfx2    = XGraphics.FromPdfPage(newPage);
                gfx2.DrawImage(objImage, 0, 0, newPage.Width, newPage.Height);
            }

            watch.Stop();
            Console.WriteLine("Time to Generate PDF: " + watch.Elapsed.Seconds + "." + watch.Elapsed.Milliseconds + " seconds");
            return(document);
        }
Beispiel #8
0
        public void GenerateReceipt(string filepath)
        {
            var document = new PdfDocument();

            PdfPage        page = document.AddPage();
            XGraphics      gfx  = XGraphics.FromPdfPage(page);
            XTextFormatter tf   = new XTextFormatter(gfx);

            Document doc = new Document();
            Section  s   = doc.AddSection();
            Table    receipt;
            Column   c;
            Row      r;

            receipt = s.AddTable();
            receipt.Format.Font.Name = "Arial";
            receipt.Format.Font.Size = new Unit(12, UnitType.Point);
            receipt.Borders.Width    = 0;
            receipt.Style            = "Table";
            receipt.BottomPadding    = new Unit(10, UnitType.Point);

            c = receipt.AddColumn(new Unit(60, UnitType.Point));
            c = receipt.AddColumn(new Unit(125, UnitType.Point));
            c.Format.Alignment = ParagraphAlignment.Right;
            c = receipt.AddColumn(new Unit(225, UnitType.Point));
            c.Format.Alignment = ParagraphAlignment.Left;
            c = receipt.AddColumn(new Unit(60, UnitType.Point));
            c.Format.Alignment = ParagraphAlignment.Right;

            r = receipt.AddRow();
            r.BottomPadding             = 0;
            r.Cells[2].MergeRight       = 1;
            r.Cells[2].Format.Font.Size = new Unit(7, UnitType.Point);
            r.Cells[2].Format.Alignment = ParagraphAlignment.Right;
            r.Cells[2].AddParagraph(string.Format("Gerado em: {0}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")));

            r = receipt.AddRow();
            r.Borders.Top.Width            = 1;
            r.Cells[0].Borders.Left.Width  = 1;
            r.Cells[3].Borders.Right.Width = 1;
            r.TopPadding = new Unit(10, UnitType.Point);
            var krav_maga_moema_logo = r.Cells[0].AddImage(AppDomain.CurrentDomain.BaseDirectory + "logo_krav_maga_moema.jpg");

            krav_maga_moema_logo.Height          = new Unit(40, UnitType.Point);
            krav_maga_moema_logo.LockAspectRatio = true;

            var krav_maga_sa_logo = r.Cells[3].AddImage(AppDomain.CurrentDomain.BaseDirectory + "logo_kravmaga.png");

            krav_maga_sa_logo.Height          = new Unit(40, UnitType.Point);
            krav_maga_sa_logo.LockAspectRatio = true;

            r.Format.Font.Bold             = true;
            r.Cells[0].Borders.Left.Width  = 1;
            r.Cells[3].Borders.Right.Width = 1;
            r.Format.Alignment             = ParagraphAlignment.Center;
            r.Format.Font.Size             = new Unit(15, UnitType.Point);
            r.Cells[1].MergeRight          = 1;
            r.Cells[1].AddParagraph("RECIBO DE PAGAMENTO");

            r = receipt.AddRow();
            r.Cells[0].Borders.Left.Width  = 1;
            r.Cells[3].Borders.Right.Width = 1;
            r.Cells[1].AddParagraph("Nome do Aluno:");
            r.Cells[2].MergeRight = 1;
            r.Cells[2].AddParagraph(receiptInfo.StudentName.ToUpper());

            r = receipt.AddRow();
            r.Cells[0].Borders.Left.Width  = 1;
            r.Cells[3].Borders.Right.Width = 1;
            r.Cells[1].AddParagraph("Valor do Pagamento:");
            r.Cells[2].AddParagraph(receiptInfo.PaymentValue.ToString("R$ 0,0.00"));

            r = receipt.AddRow();
            r.Cells[0].Borders.Left.Width  = 1;
            r.Cells[3].Borders.Right.Width = 1;
            r.Cells[1].AddParagraph("Data do Pagamento:");
            r.Cells[2].AddParagraph(receiptInfo.PaymentDate.ToString("dd/MM/yyyy"));

            r = receipt.AddRow();
            r.Cells[0].Borders.Left.Width  = 1;
            r.Cells[3].Borders.Right.Width = 1;
            r.Cells[1].AddParagraph("Tipo do Pagamento:");
            r.Cells[2].AddParagraph(receiptInfo.PaymentType.ToUpper());
            r.Borders.Bottom.Width = 1;

            MigraDoc.Rendering.DocumentRenderer docRender = new MigraDoc.Rendering.DocumentRenderer(doc);
            docRender.PrepareDocument();

            docRender.RenderObject(gfx, XUnit.FromPoint(50), XUnit.FromPoint(30), XUnit.FromPoint(470), receipt);

            document.Save(filepath);
        }
Beispiel #9
0
		private void butPrint_Click(object sender,EventArgs e) {
			PrintDocument pd=new PrintDocument();
			if(!PrinterL.SetPrinter(pd,PrintSituation.Default,0,"Reconcile list printed")) {
				return;//User cancelled.
			}
			pd.DefaultPageSettings.Margins=new Margins(25,25,40,40);
			if(pd.DefaultPageSettings.PrintableArea.Height==0) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("default",850,1100);
			}
			MigraDoc.DocumentObjectModel.Document doc=CreatePrintDocument(pd);
			MigraDoc.Rendering.Printing.MigraDocPrintDocument printdoc=new MigraDoc.Rendering.Printing.MigraDocPrintDocument();
			MigraDoc.Rendering.DocumentRenderer renderer=new MigraDoc.Rendering.DocumentRenderer(doc);
			renderer.PrepareDocument();
			printdoc.PrinterSettings=pd.PrinterSettings;
			printdoc.Renderer=renderer;
#if DEBUG
			FormRpPrintPreview pView=new FormRpPrintPreview();
			pView.printPreviewControl2.Document=printdoc;
			pView.ShowDialog();
#else
			printdoc.Print();
#endif
		}
		///<summary>Prints one statement.  Does not generate pdf or print from existing pdf.</summary>
		public void PrintStatement(Statement stmt,bool previewOnly,PrintDocument pd,DataSet dataSet,Family fam,Patient pat) {
			Stmt=stmt;
			//dataSet=AccountModuleL.GetStatement(stmt.PatNum,stmt.SinglePatient,stmt.DateRangeFrom,stmt.DateRangeTo,
			//	stmt.Intermingled);
			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;
			if(pd.DefaultPageSettings.PaperSize.Height==0) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("default",850,1100);
			}
			MigraDoc.DocumentObjectModel.Document doc=CreateDocument(pd,fam,pat,dataSet);
			MigraDoc.Rendering.Printing.MigraDocPrintDocument printdoc=new MigraDoc.Rendering.Printing.MigraDocPrintDocument();
			MigraDoc.Rendering.DocumentRenderer renderer=new MigraDoc.Rendering.DocumentRenderer(doc);
			renderer.PrepareDocument();
			totalPages=renderer.FormattedDocument.PageCount;
			labelTotPages.Text="1 / "+totalPages.ToString();
			printdoc.Renderer=renderer;
			printdoc.PrinterSettings=pd.PrinterSettings;
			if(previewOnly) {
				printPreviewControl2.Document=printdoc;
			}
			else {
				try {
					printdoc.Print();
				}
				catch {
					MessageBox.Show(Lan.g(this,"Printer not available"));
				}
			}
		}
Beispiel #11
0
		private void ToolBarMainSign_Click() {
			if(gridPlans.SelectedIndices[0]==0) {
				MsgBox.Show(this,"You may only sign a saved TP, not the default TP.");
				return;
			}
			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;
			FormTPsign FormT=new FormTPsign();
			FormT.Document=printdoc;
			FormT.TotalPages=renderer.FormattedDocument.PageCount;
			FormT.TPcur=PlanList[gridPlans.SelectedIndices[0]-1];
			FormT.ShowDialog();
			long tpNum=PlanList[gridPlans.SelectedIndices[0]-1].TreatPlanNum;
			ModuleSelected(PatCur.PatNum);
			for(int i=0;i<PlanList.Length;i++) {
				if(PlanList[i].TreatPlanNum==tpNum) {
					gridPlans.SetSelected(i+1,true);
				}
			}
			FillMain();
		}
Beispiel #12
0
		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 PPO 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
		}
Beispiel #13
0
		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
				}
			}
		}
Beispiel #14
0
        //Se houverem dúvidas, há duas páginas de exemplo oficial do PDFSHarp após esse método.
        protected void ReportPage1(PdfDocument document)
        {
            PdfPage   page = document.AddPage();
            XGraphics gfx  = XGraphics.FromPdfPage(page);

            gfx.MUH = PdfFontEncoding.Unicode;

            // You always need a MigraDoc document for rendering.
            Document doc = new Document();

            Section sec = doc.AddSection();

            Paragraph image = sec.AddParagraph();

            image.Format.Alignment = ParagraphAlignment.Right;
            Image imagem = image.AddImage("logo.png");

            imagem.Height          = "1.5cm";
            imagem.LockAspectRatio = true;

            Paragraph para1 = sec.AddParagraph();

            para1.Format.Alignment  = ParagraphAlignment.Center;
            para1.Format.Font.Name  = "Arial";
            para1.Format.Font.Size  = 14;
            para1.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.Black;
            para1.AddFormattedText("RELATÓRIO FINAL DA AVALIAÇÃO DE EXEMPLO DE USO DO MIGRADOC", TextFormat.Bold);
            para1.Format.Borders.Distance = "5pt";

            // Tabela da Fase I
            Table table1 = sec.AddTable();

            table1.Style                  = "Table";
            table1.Format.Font.Size       = 9;
            table1.Borders.Color          = MigraDoc.DocumentObjectModel.Color.FromRgb(100, 100, 100);
            table1.Borders.Width          = 0.5;
            table1.Borders.Left.Width     = 0.5;
            table1.Borders.Right.Width    = 0.5;
            table1.Rows.LeftIndent        = 0;
            table1.BottomPadding          = Unit.FromCentimeter(0.1);
            table1.TopPadding             = Unit.FromCentimeter(0.1);
            table1.LeftPadding            = Unit.FromCentimeter(0.2);
            table1.RightPadding           = Unit.FromCentimeter(0.2);
            table1.Rows.Alignment         = RowAlignment.Left;
            table1.Rows.VerticalAlignment = VerticalAlignment.Top;

            // Before you can add a row, you must define the columns
            Column column = table1.AddColumn("4.25cm");

            column = table1.AddColumn("4.25cm");
            column = table1.AddColumn("4.25cm");
            column = table1.AddColumn("4.25cm");

            // Create the header of the table
            Row row = table1.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("I - IDENTIFICAÇÃO DO FUNCIONÁRIO");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 3;

            row = table1.AddRow();
            row.Cells[0].AddParagraph("Nome");
            row.Cells[0].AddParagraph(this.Model.Nome);
            row.Cells[0].MergeRight = 1;
            row.Cells[2].AddParagraph("Cargo");
            row.Cells[2].AddParagraph(this.Model.Cargo);
            row.Cells[3].AddParagraph("Matrícula");
            row.Cells[3].AddParagraph(this.Model.Matricula);

            row = table1.AddRow();
            row.Cells[0].AddParagraph("Filial");
            row.Cells[0].AddParagraph(this.Model.Filial);
            row.Cells[0].MergeRight = 1;
            row.Cells[2].AddParagraph("Setor");
            row.Cells[2].AddParagraph(this.Model.Setor);
            row.Cells[3].AddParagraph("Data Admissão");
            row.Cells[3].AddParagraph(this.Model.DataAdmissao);

            row = table1.AddRow();
            row.Cells[0].AddParagraph(" ");
            row.Cells[0].MergeRight = 3;
            row.Borders.Visible     = false;

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("II - RESULTADO FINAL");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 3;

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("ETAPA");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeDown         = 1;
            row.Cells[1].AddParagraph("PERÍODO");
            row.Cells[1].Format.Font.Bold  = false;
            row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[1].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[1].MergeRight        = 1;
            row.Cells[3].AddParagraph("RESULTADO DA AVALIAÇÃO (RA)");
            row.Cells[3].Format.Font.Bold  = false;
            row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[3].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[3].MergeDown         = 1;

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[1].AddParagraph("DATA INÍCIO");
            row.Cells[1].Format.Font.Bold  = false;
            row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[1].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[2].AddParagraph("DATA FIM");
            row.Cells[2].Format.Font.Bold  = false;
            row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[2].VerticalAlignment = VerticalAlignment.Center;

            foreach (var item in this.Model.ResultadosAvaliacao)
            {
                row = table1.AddRow();
                row.Cells[0].AddParagraph(item.NomeEtapa);
                row.Cells[1].AddParagraph(item.DataInicioEtapa);
                row.Cells[1].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[2].AddParagraph(item.DataFimEtapa);
                row.Cells[2].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[3].AddParagraph(item.ResultadoEtapa);
                row.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            }

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("RESULTADO FINAL = [(RAE1) + (RAE2) + (RAE3) + (RAE4)]/4");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 2;
            row.Cells[3].AddParagraph(this.Model.ResultadoFinal);
            row.Cells[3].Format.Font.Bold  = false;
            row.Cells[3].Format.Alignment  = ParagraphAlignment.Right;
            row.Cells[3].VerticalAlignment = VerticalAlignment.Center;

            row = table1.AddRow();
            row.Cells[0].AddParagraph(" ");
            row.Cells[0].MergeRight = 3;
            row.Borders.Visible     = false;

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("III - CONCLUSÃO");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 3;

            row = table1.AddRow();
            row.Format.Alignment = ParagraphAlignment.Justify;
            row.Cells[0].AddParagraph("ipit iurero dolum zzriliquisis nit wis dolore vel et nonsequipit, velendigna " +
                                      "auguercilit lor se dipisl duismod tatem zzrit at laore magna feummod oloborting ea con vel " +
                                      "essit augiati onsequat luptat nos diatum vel ullum illummy nonsent nit ipis et nonsequis " +
                                      "essent augait el ing eumsan hendre feugait prat augiatem amconul laoreet.");
            row.Cells[0].AddParagraph(" ");
            row.Cells[0].AddParagraph((this.Model.Conclusao ? "APTO" : "INAPTO") + " a ser efetivado no serviço público.");
            row.Cells[0].MergeRight = 3;

            row = table1.AddRow();
            row.Cells[0].AddParagraph(" ");
            row.Cells[0].MergeRight = 3;
            row.Borders.Visible     = false;

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("IV - MEMBROS AVALIADORES");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 3;

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("NOME");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 1;
            row.Cells[2].AddParagraph("MATRÍCULA");
            row.Cells[2].Format.Font.Bold  = false;
            row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[2].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[3].AddParagraph("ASSINATURA");
            row.Cells[3].Format.Font.Bold  = false;
            row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[3].VerticalAlignment = VerticalAlignment.Center;

            foreach (var item in this.Model.MembrosComissao)
            {
                row = table1.AddRow();
                row.Cells[0].AddParagraph(item.NomeMembroComissao);
                row.Cells[0].MergeRight = 1;
                row.Cells[2].AddParagraph(item.MatriculaMembroComissao);
                row.Cells[2].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[3].AddParagraph(" ");
            }

            row = table1.AddRow();
            row.Cells[0].AddParagraph(" ");
            row.Cells[0].MergeRight = 3;
            row.Borders.Visible     = false;

            row = table1.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200);
            row.Cells[0].AddParagraph("V - DE ACORDO GERENTE");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 3;

            row = table1.AddRow();
            row.Cells[0].AddParagraph("DE ACORDO.");
            row.Cells[0].AddParagraph("AO RH, PARA PROVIDÊNCIAS.");
            row.Cells[0].AddParagraph(" ");
            row.Cells[0].Format.Borders.Bottom.Color = MigraDoc.DocumentObjectModel.Color.FromRgb(255, 255, 255);
            row.Cells[0].MergeRight = 3;

            row = table1.AddRow();
            row.Cells[0].AddParagraph("_______________________________");
            row.Cells[0].AddParagraph("Data");
            row.Cells[0].Format.Alignment           = ParagraphAlignment.Center;
            row.Cells[0].Format.Borders.Top.Color   = MigraDoc.DocumentObjectModel.Color.FromRgb(255, 255, 255);
            row.Cells[0].Format.Borders.Right.Color = MigraDoc.DocumentObjectModel.Color.FromRgb(255, 255, 255);
            row.Cells[0].MergeRight = 1;
            row.Cells[2].AddParagraph("_______________________________");
            row.Cells[2].AddParagraph("Assinatura");
            row.Cells[2].Format.Alignment          = ParagraphAlignment.Center;
            row.Cells[0].Format.Borders.Top.Color  = MigraDoc.DocumentObjectModel.Color.FromRgb(255, 255, 255);
            row.Cells[0].Format.Borders.Left.Color = MigraDoc.DocumentObjectModel.Color.FromRgb(255, 255, 255);
            row.Cells[2].MergeRight = 1;


            table1.SetEdge(0, 0, 3, 3, Edge.Box, BorderStyle.Single, 0.75, MigraDoc.DocumentObjectModel.Color.FromRgb(200, 200, 200));

            // Create footer
            Paragraph paragraph = sec.Footers.Primary.AddParagraph();

            paragraph.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.Black;
            paragraph.AddText("_____________________________ \n");
            paragraph.AddText("Av. XYZ, 23 - CEP 60.000-000 \n");
            paragraph.AddText("Fortaleza, Ceará, Brasil \n");
            paragraph.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
            paragraph.AddText("(85) 0101.0101 - FAX: (85) 3232.3232");
            paragraph.Format.Font.Size = 8;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Render the paragraph. You can render tables or shapes the same way.
            MigraDoc.Rendering.DocumentRenderer docRenderer = new MigraDoc.Rendering.DocumentRenderer(doc);
            docRenderer.PrepareDocument();

            docRenderer.RenderObject(gfx, XUnit.FromCentimeter(2), XUnit.FromCentimeter(1.5), "17cm", image);
            docRenderer.RenderObject(gfx, XUnit.FromCentimeter(2), XUnit.FromCentimeter(3), "17cm", para1);
            docRenderer.RenderObject(gfx, XUnit.FromCentimeter(2), XUnit.FromCentimeter(5), "17cm", table1);
            docRenderer.RenderObject(gfx, XUnit.FromCentimeter(2), XUnit.FromCentimeter(27.5), "17cm", paragraph);
        }
Beispiel #15
0
 private void butPrint_Click(object sender,EventArgs e)
 {
     MigraDoc.DocumentObjectModel.Document doc=CreatePrintDocument();
     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();
     pView.printPreviewControl2.Document=printdoc;
     pView.ShowDialog();
     #else
     //Always prints to the Windows default printer.
     if(PrinterL.SetPrinter(pd2,PrintSituation.Default)){
         printdoc.Print();
     }
     #endif
 }
Beispiel #16
0
        public override PdfDocument ToPdf()
        {
            //http://www.pdfsharp.net/wiki/Unicode-sample.ashx
            // Create new document
            var document = new PdfDocument();

            var pdfString = "eXPRS Plan of Care - Services Delivered Report Form\n\n" +
                            "Timesheet ID: " + Id + "\n" +
                            "Status of Timesheet: " + Status + "\n" +
                            "Customer Name: " + ClientName + "\n" +
                            "Prime: " + ClientPrime + "\n" +
                            "Provider Name: " + ProviderName + "\n" +
                            "Provider Num: " + ProviderId + "\n" +
                            "CM Organization: Multnomah Case Management\n" +
                            "Form Type: " + FormType + "\n\n" +
                            "Service Goal: " + ServiceGoal + "\n\n" +
                            "Progress Notes: " + ProgressNotes + "\n\n" +
                            "Submitted on: " + Submitted + "\n";

            // Set font encoding to unicode
            var options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            var font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);


            var page = document.AddPage();
            var gfx  = XGraphics.FromPdfPage(page);
            var tf   = new XTextFormatter(gfx)
            {
                Alignment = XParagraphAlignment.Left
            };

            tf.DrawString(pdfString, font, XBrushes.Black,
                          new XRect(100, 100, page.Width - 200, 600), XStringFormats.TopLeft);

            // TABLE
            var doc     = new Document();
            var section = doc.AddSection();
            var table   = section.AddTable();

            table.Style               = "Table";
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent     = 0;

            // Before you can add a row, you must define the columns
            var column = table.AddColumn("2.5cm");

            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn("2.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn("2.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn("8cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            // Create the header of the table
            var row = table.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = Colors.LightGreen;
            row.Cells[0].AddParagraph("Date");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[1].AddParagraph("Total Miles for Date");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Center;
            row.Cells[2].AddParagraph("Group? Yes/No");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Center;
            row.Cells[3].AddParagraph("Purpose of Trip/Service Goal");
            row.Cells[3].Format.Alignment = ParagraphAlignment.Center;

            double totalMiles = 0;

            foreach (var entry in MileageEntries)
            {
                row = table.AddRow();
                row.HeadingFormat    = true;
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Format.Font.Bold = true;
                row.Cells[0].AddParagraph(entry.Date.ToShortDateString());
                row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[1].AddParagraph(entry.Miles.ToString(CultureInfo.CurrentCulture));
                row.Cells[1].Format.Alignment = ParagraphAlignment.Center;
                totalMiles += entry.Miles;
                row.Cells[2].AddParagraph(entry.Group ? "Yes" : "No");
                row.Cells[2].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[3].AddParagraph(entry.PurposeOfTrip);
                row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
            }

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Cells[0].AddParagraph("Total");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[1].AddParagraph(totalMiles + " Miles");
            row.Cells[1].MergeRight       = 2;
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;

            table.SetEdge(0, 0, 4, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);

            // Create a renderer and prepare (=layout) the document
            var docRenderer = new MigraDoc.Rendering.DocumentRenderer(doc);

            docRenderer.PrepareDocument();

            // Render the paragraph. You can render tables or shapes the same way.
            docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(13), "12cm", table);

            //END OF TABLE

            // TODO: Adding images takes far too long. It takes about ~0.7s per image
            // This means download ~1,600 PDFs with 2 images each takes ~45 minutes just to render : (
            // Make this faster
            //This code section will add new pages with images.
            foreach (var uri in UriList)
            {
                using var wc       = new WebClient();
                using var objImage = XImage.FromStream(new MemoryStream(wc.DownloadData(uri)));
                //do stuff with the image
                var newPage = document.AddPage();
                var gfx2    = XGraphics.FromPdfPage(newPage);
                gfx2.DrawImage(objImage, 0, 0, newPage.Width, newPage.Height);
            }
            return(document);
        }