Пример #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);
 }
        public static MigraDoc.DocumentObjectModel.Paragraph  ExportToPDF(string imagefulpathname)
        {
            // Add a paragraph to the section
            MigraDoc.DocumentObjectModel.Paragraph paragraph = new MigraDoc.DocumentObjectModel.Paragraph();

            MigraDoc.DocumentObjectModel.Shapes.Image img1 = paragraph.AddImage(imagefulpathname);
            img1.LockAspectRatio = true;
            return(paragraph);
        }
Пример #3
0
 /// <summary>
 /// Adds the text to an existing paragraph without special format
 /// </summary>
 public void AddTo(MigraDoc.DocumentObjectModel.Paragraph paragrapgh)
 {
     paragrapgh.AddText(this.text);
 }
Пример #4
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);
        }
Пример #5
0
        private static void ExportFlexgrid(MigraDoc.DocumentObjectModel.Document Doc, string TblTitle, AUXGrid fgrid)
        {
            if ((fgrid) != null)
            {
                AUXGrid xgrid = fgrid;     //31Aug2012

                ////////// Printing Header //////////  <fgheader> means flexgrid header
                string      header  = xgrid.Header.Text;
                AUParagraph FGTitle = new AUParagraph();
                FGTitle.Text       = header;
                FGTitle.FontWeight = FontWeights.SemiBold;
                if (APAStyle)
                {
                    FGTitle.FontStyle = FontStyles.Italic;
                }

                MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FGTitle.Text, FGTitle.FontWeight, FGTitle.FontSize, FGTitle.textcolor, FGTitle.FontStyle);     //FGTitle.ExportPDFParagraph();
                PDFpara.AddLineBreak();
                Doc.LastSection.Add(PDFpara.Clone());

                //////////////// Printing Errors ///////////
                if (xgrid.Metadata != null)    //// <errhd> means error heading
                {
                    // Error/Warning Title
                    AUParagraph ErrWarnTitle = new AUParagraph();
                    ErrWarnTitle.Text       = "Errors/Warnings: ";;
                    ErrWarnTitle.FontWeight = FontWeights.SemiBold;

                    MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnTitle.Text, ErrWarnTitle.FontWeight, ErrWarnTitle.FontSize, ErrWarnTitle.textcolor, ErrWarnTitle.FontStyle);     //ErrWarnTitle.ExportPDFParagraph();
                    PDFparaErrWarnTitle.AddLineBreak();
                    Doc.LastSection.Add(PDFparaErrWarnTitle.Clone());

                    // Error/Warning Messages
                    AUParagraph ErrWarnMsgPara = null;
                    foreach (KeyValuePair <char, string> keyval in xgrid.Metadata)
                    {
                        ErrWarnMsgPara      = new AUParagraph();
                        ErrWarnMsgPara.Text = keyval.Key.ToString() + ":" + keyval.Value;
                        MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnMsgPara.Text, ErrWarnMsgPara.FontWeight, ErrWarnMsgPara.FontSize, ErrWarnMsgPara.textcolor, ErrWarnMsgPara.FontStyle);     //ErrWarnMsgPara.ExportPDFParagraph();
                        PDFparaErrWarnMsg.AddLineBreak();
                        Doc.LastSection.Add(PDFparaErrWarnMsg.Clone());
                    }
                }

                //////// Printing  Grid ////////////

                AUGrid grid = xgrid.Grid;
                float  remainingpagesize = 0.0f;   //remaining page height
                float  currentTblHt      = 0.0f;
                float  PDFpageHeight     = Doc.DefaultPageSetup.PageHeight;
                BSky.ExportToPDF.ExportAUXGrid.APAStyle = APAStyle;
                List <MigraDoc.DocumentObjectModel.Tables.Table> TablePortions = BSky.ExportToPDF.ExportAUXGrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight, grid, strMaxTblCol, strMaxTblRow, strPDFfontsize);     //xgrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight);
                                                                                                                                                                                                                     // MigraDoc.DocumentObjectModel.Section sec = Doc.AddSection();

                foreach (MigraDoc.DocumentObjectModel.Tables.Table ptbl in TablePortions)
                {
                    if (ptbl == null)
                    {
                        continue;
                    }

                    //Add Partial Table ID (so that printouts can be arranged in proper order)
                    if (ptbl.Tag != null)
                    {
                        Doc.LastSection.AddParagraph(ptbl.Tag.ToString());
                    }

                    //add table part to doc
                    Doc.LastSection.Add(ptbl);     //table.Format.KeepWithNext = true;
                    //sec.AddParagraph();
                    Doc.LastSection.AddParagraph().AddLineBreak();
                }

                /////////////////Printing Footer  ///////////////
                string starfootnotes   = string.Empty;
                bool   templatedDialog = false;
                if (templatedDialog)
                {
                    //I think this works for templated dialogs
                    if (xgrid.FootNotes != null)
                    {
                        // Printing Foonotes Title
                        if (xgrid.FootNotes.Count > 0)
                        {
                            AUParagraph FooterTitle = new AUParagraph();
                            FooterTitle.Text       = "Footnotes: "; //Footnote Title
                            FooterTitle.FontWeight = FontWeights.SemiBold;
                            //FooterTitle.textcolor =
                            MigraDoc.DocumentObjectModel.Paragraph PDFparaFooterTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FooterTitle.Text, FooterTitle.FontWeight, FooterTitle.FontSize, FooterTitle.textcolor, FooterTitle.FontStyle);     //FooterTitle.ExportPDFParagraph();
                            PDFparaFooterTitle.AddLineBreak();
                            Doc.LastSection.Add(PDFparaFooterTitle.Clone());
                        }
                        AUParagraph footnote = null;
                        foreach (KeyValuePair <char, string> keyval in xgrid.FootNotes)
                        {
                            footnote      = new AUParagraph();
                            footnote.Text = keyval.Key.ToString() + ":" + keyval.Value;
                            MigraDoc.DocumentObjectModel.Paragraph PDFparaFootnotesMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(footnote.Text, footnote.FontWeight, footnote.FontSize, footnote.textcolor, footnote.FontStyle);     //footnote.ExportPDFParagraph();
                            PDFparaFootnotesMsg.AddLineBreak();
                            Doc.LastSection.Add(PDFparaFootnotesMsg.Clone());
                        }
                    }
                }
                else     //This works for non-templated dialogs
                {
                    AUParagraph starfootnote = new AUParagraph();
                    starfootnote.Text     = xgrid.StarFootNotes;
                    starfootnote.FontSize = 9;                                                                                                                                                                                                                //table cell text(& R syntax) looks size 12. So I want it to be smaller than other text.

                    MigraDoc.DocumentObjectModel.Paragraph PDFparaStarFooterText = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(starfootnote.Text, starfootnote.FontWeight, starfootnote.FontSize, starfootnote.textcolor, starfootnote.FontStyle); //FooterTitle.ExportPDFParagraph();
                    PDFparaStarFooterText.AddLineBreak();
                    Doc.LastSection.Add(PDFparaStarFooterText.Clone());
                }
            }
        }
Пример #6
0
        private static void ExportOutputPDF(CommandOutput output, MigraDoc.DocumentObjectModel.Document Doc, bool extratags, List <string> filelist, bool issessionout = false)//csv of excel
        {
            if (output.NameOfAnalysis == null)
            {
                output.NameOfAnalysis = string.Empty;
            }

            foreach (DependencyObject obj in output)
            {
                FrameworkElement element = obj as FrameworkElement;
                //31Aug2012 AUXGrid xgrid = element as AUXGrid;
                if ((element as AUParagraph) != null)
                {
                    AUParagraph aup = element as AUParagraph;

                    if (!aup.IsVisible)
                    {
                        continue;
                    }

                    if (aup.Text != null)                                                                                                                                                              ///// <aup> means AUParagraph
                    {
                        MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(aup.Text, aup.FontWeight, aup.FontSize, aup.textcolor, aup.FontStyle); //aup.ExportPDFParagraph();
                        PDFpara.AddLineBreak();
                        Doc.LastSection.Add(PDFpara.Clone());
                    }
                }
                else if ((element as AUXGrid) != null)
                {
                    AUXGrid xgrid = element as AUXGrid; //31Aug2012


                    if (!xgrid.IsVisible)
                    {
                        continue;
                    }
                    ////////// Printing Header //////////  <fgheader> means flexgrid header
                    string      header  = xgrid.Header.Text;
                    AUParagraph FGTitle = new AUParagraph();
                    FGTitle.Text       = header;
                    FGTitle.FontWeight = FontWeights.SemiBold;
                    if (APAStyle)
                    {
                        FGTitle.FontStyle = FontStyles.Italic;
                    }
                    //FGTitle.textcolor =
                    MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FGTitle.Text, FGTitle.FontWeight, FGTitle.FontSize, FGTitle.textcolor, FGTitle.FontStyle); //FGTitle.ExportPDFParagraph();
                    PDFpara.AddLineBreak();
                    Doc.LastSection.Add(PDFpara.Clone());

                    //////////////// Printing Errors ///////////
                    if (xgrid.Metadata != null)//// <errhd> means error heading
                    {
                        // Error/Warning Title
                        AUParagraph ErrWarnTitle = new AUParagraph();
                        ErrWarnTitle.Text       = "Errors/Warnings: ";;
                        ErrWarnTitle.FontWeight = FontWeights.SemiBold;
                        //ErrWarnTitle.FontStyle = FontStyles.Normal;
                        //ErrWarnTitle.textcolor =
                        MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnTitle.Text, ErrWarnTitle.FontWeight, ErrWarnTitle.FontSize, ErrWarnTitle.textcolor, ErrWarnTitle.FontStyle); //ErrWarnTitle.ExportPDFParagraph();
                        PDFparaErrWarnTitle.AddLineBreak();
                        Doc.LastSection.Add(PDFparaErrWarnTitle.Clone());

                        // Error/Warning Messages
                        AUParagraph ErrWarnMsgPara = null;
                        foreach (KeyValuePair <char, string> keyval in xgrid.Metadata)
                        {
                            ErrWarnMsgPara      = new AUParagraph();
                            ErrWarnMsgPara.Text = keyval.Key.ToString() + ":" + keyval.Value;

                            MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnMsgPara.Text, ErrWarnMsgPara.FontWeight, ErrWarnMsgPara.FontSize, ErrWarnMsgPara.textcolor, ErrWarnMsgPara.FontStyle); //ErrWarnMsgPara.ExportPDFParagraph();
                            PDFparaErrWarnMsg.AddLineBreak();
                            Doc.LastSection.Add(PDFparaErrWarnMsg.Clone());
                        }
                    }

                    //////// Printing  Grid ////////////
                    AUGrid grid = xgrid.Grid;
                    float  remainingpagesize = 0.0f;//remaining page height
                    float  currentTblHt      = 0.0f;
                    float  PDFpageHeight     = Doc.DefaultPageSetup.PageHeight;

                    BSky.ExportToPDF.ExportAUXGrid.APAStyle = APAStyle;
                    List <MigraDoc.DocumentObjectModel.Tables.Table> TablePortions = BSky.ExportToPDF.ExportAUXGrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight, grid, strMaxTblCol, strMaxTblRow, strPDFfontsize);  //xgrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight);

                    foreach (MigraDoc.DocumentObjectModel.Tables.Table ptbl in TablePortions)
                    {
                        if (ptbl == null)
                        {
                            continue;
                        }

                        //Add Partial Table ID (so that printouts can be arranged in proper order)
                        if (ptbl.Tag != null)
                        {
                            Doc.LastSection.AddParagraph(ptbl.Tag.ToString());
                        }

                        //add table part to doc
                        Doc.LastSection.Add(ptbl);

                        Doc.LastSection.AddParagraph().AddLineBreak();
                    }

                    /////////////////Printing Footer  ///////////////
                    string starfootnotes   = string.Empty;
                    bool   templatedDialog = false;
                    if (templatedDialog)
                    {
                        //I think this works for templated dialogs
                        if (xgrid.FootNotes != null)
                        {
                            // Printing Foonotes Title
                            if (xgrid.FootNotes.Count > 0)
                            {
                                AUParagraph FooterTitle = new AUParagraph();
                                FooterTitle.Text       = "Footnotes: ";                                                                                                                                                                                           //Footnote Title
                                FooterTitle.FontWeight = FontWeights.SemiBold;
                                MigraDoc.DocumentObjectModel.Paragraph PDFparaFooterTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FooterTitle.Text, FooterTitle.FontWeight, FooterTitle.FontSize, FooterTitle.textcolor, FooterTitle.FontStyle); //FooterTitle.ExportPDFParagraph();
                                PDFparaFooterTitle.AddLineBreak();
                                Doc.LastSection.Add(PDFparaFooterTitle.Clone());
                            }
                            AUParagraph footnote = null;
                            foreach (KeyValuePair <char, string> keyval in xgrid.FootNotes)
                            {
                                footnote      = new AUParagraph();
                                footnote.Text = keyval.Key.ToString() + ":" + keyval.Value;

                                MigraDoc.DocumentObjectModel.Paragraph PDFparaFootnotesMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(footnote.Text, footnote.FontWeight, footnote.FontSize, footnote.textcolor, footnote.FontStyle); //footnote.ExportPDFParagraph();
                                PDFparaFootnotesMsg.AddLineBreak();
                                Doc.LastSection.Add(PDFparaFootnotesMsg.Clone());
                            }
                        }
                    }
                    else //This works for non-templated dialogs
                    {
                        AUParagraph starfootnote = new AUParagraph();
                        starfootnote.Text     = xgrid.StarFootNotes;
                        starfootnote.FontSize = 9;                                                                                                                                                                                                                //table cell text(& R syntax) looks size 12. So I want it to be smaller than other text.

                        MigraDoc.DocumentObjectModel.Paragraph PDFparaStarFooterText = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(starfootnote.Text, starfootnote.FontWeight, starfootnote.FontSize, starfootnote.textcolor, starfootnote.FontStyle); //FooterTitle.ExportPDFParagraph();
                        PDFparaStarFooterText.AddLineBreak();
                        Doc.LastSection.Add(PDFparaStarFooterText.Clone());
                    }
                }
                else if ((element as BSkyGraphicControl) != null)//Graphics 31Aug2012
                {
                    BSkyGraphicControl bsgc = element as BSkyGraphicControl;

                    //To only Export Graphics those are visible (checked in the left navigation tree, in output window)
                    if (!bsgc.IsVisible)
                    {
                        continue;
                    }
                    //Create image filename
                    string imgfilename = "PDF" + bsgc.ImageName + ".png";

                    string synedtimg = Path.Combine(tempDir, imgfilename);

                    //Saving Image separately
                    BSkyGraphicControlToImageFile(bsgc, synedtimg);                                                          //not imgfilename

                    MigraDoc.DocumentObjectModel.Paragraph imgPara = BSky.ExportToPDF.ExportGraphics.ExportToPDF(synedtimg); //bsgc.ExportToPDF(synedtimg);// not imgfilename

                    //finally add image to the PDF doc.
                    Doc.LastSection.Add(imgPara);
                }
                else if ((element as BSkyNotes) != null) // Notes Control 05Nov2012.
                {
                    BSkyNotes bsn = element as BSkyNotes;
                    //To only Export Notes those are visible (checked in the left navigation tree, in output window)
                    if (!bsn.IsVisible)
                    {
                        continue;
                    }

                    //Put a title
                    AUParagraph NotesTitle = new AUParagraph();
                    NotesTitle.Text       = "Notes"; //Footnote Title
                    NotesTitle.FontWeight = FontWeights.SemiBold;

                    MigraDoc.DocumentObjectModel.Paragraph PDFparaNotesTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(NotesTitle.Text, NotesTitle.FontWeight, NotesTitle.FontSize, NotesTitle.textcolor, NotesTitle.FontStyle); //NotesTitle.ExportPDFParagraph();
                    PDFparaNotesTitle.AddLineBreak();
                    Doc.LastSection.Add(PDFparaNotesTitle.Clone());

                    //Now Notes data in PdfPTable
                    MigraDoc.DocumentObjectModel.Tables.Table notestable = BSky.ExportToPDF.ExportNotes.ExportToPDF(bsn.NotesData, strPDFfontsize);// bsn.ExportToPDF();
                    Doc.LastSection.Add(notestable);
                    Doc.LastSection.AddParagraph().AddLineBreak();
                }
            }

            ////for export to excel////E
        }