Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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");
        }
 public PageContent Render(MigraDoc.DocumentObjectModel.Section s, PageContent baseContent)
 {
     if (baseContent is Paragraph)
     {
         return(paragraph.Render(s, baseContent as Paragraph));
     }
     else
     {
         return(table.Render(s, baseContent as Table));
     }
 }
Ejemplo n.º 4
0
        public ExportDocument()
        {
            Document = new MigraDoc.DocumentObjectModel.Document();

            Style      = Document.Styles["Normal"];
            Style.Font = new MigraDoc.DocumentObjectModel.Font("Arial", 10);

            Style           = Document.Styles.AddStyle("Footer", "Normal");
            Style.Font.Size = 8;

            FirstSection = Document.AddSection();
        }
Ejemplo n.º 5
0
        public static MigraDoc.DocumentObjectModel.Paragraph ExportFormattedText(string Text, FontWeight fntwt, double FontSize, Brush textcolor, FontStyle fstyle)
        {
            bool isSignifCode = false;

            if (Text.Trim().StartsWith("Signif. codes:"))
            {
                isSignifCode = true;
            }


            string text = Text.Replace(Environment.NewLine, String.Empty).Replace("  ", String.Empty);

            //Font Weight
            MigraDoc.DocumentObjectModel.TextFormat txtformat;
            int                 fwt;
            FontWeight          fw     = fntwt;
            FontWeightConverter fwc    = new FontWeightConverter();
            string              fontwt = fwc.ConvertToString(fw);

            bool isItalic = false;

            if (fstyle != null)
            {
                string s = fwc.ConvertToString(fstyle);
                if (s != null && s.Equals("Italic"))
                {
                    isItalic = true;
                }
            }
            switch (fontwt)
            {
            case "SemiBold":
                if (isItalic)
                {
                    txtformat = MigraDoc.DocumentObjectModel.TextFormat.Bold | MigraDoc.DocumentObjectModel.TextFormat.Italic;
                }
                else
                {
                    txtformat = MigraDoc.DocumentObjectModel.TextFormat.Bold;
                }
                break;

            case "Normal":
                if (isItalic)
                {
                    txtformat = MigraDoc.DocumentObjectModel.TextFormat.NotBold | MigraDoc.DocumentObjectModel.TextFormat.Italic;
                }
                else
                {
                    txtformat = MigraDoc.DocumentObjectModel.TextFormat.NotBold;
                }
                break;

            default:
                if (isItalic)
                {
                    txtformat = MigraDoc.DocumentObjectModel.TextFormat.NotBold | MigraDoc.DocumentObjectModel.TextFormat.Italic;
                }
                else
                {
                    txtformat = MigraDoc.DocumentObjectModel.TextFormat.NotBold;
                }
                break;
            }


            //Font Color
            System.Windows.Media.Color         fcolor    = (textcolor as SolidColorBrush).Color;
            MigraDoc.DocumentObjectModel.Color fontcolor = new MigraDoc.DocumentObjectModel.Color(fcolor.A, fcolor.R, fcolor.G, fcolor.B);

            //Font Size
            if (FontSize == 0)
            {
                FontSize = 14;
            }

            // Create a new MigraDoc document
            MigraDoc.DocumentObjectModel.Document document = new MigraDoc.DocumentObjectModel.Document();

            // Add a section to the document
            MigraDoc.DocumentObjectModel.Section section = document.AddSection();

            // Add a paragraph to the section
            MigraDoc.DocumentObjectModel.Paragraph paragraph = section.AddParagraph();

            if (isSignifCode)//add 'Notes.' in italics before 'Signif. codes:'
            {
                paragraph.AddFormattedText("Note. ", MigraDoc.DocumentObjectModel.TextFormat.Italic);
            }

            // Add some text to the paragraph
            paragraph.AddFormattedText(Text, txtformat);
            paragraph.Format.Font.Name  = "Times New Roman";
            paragraph.Format.Font.Size  = FontSize;
            paragraph.Format.Font.Color = fontcolor;
            paragraph.AddLineBreak();
            if (isSignifCode)
            {
                paragraph.AddLineBreak(); //add extra linebreak if 'signif code' is printed
            }

            return(paragraph);
        }