private void CreateSignature(RadFlowDocumentEditor editor)
        {
            Table signatureTable = editor.InsertTable(1, 2);
            signatureTable.Rows[0].Cells[0].Borders = new TableCellBorders(
                new Border(BorderStyle.None),
                new Border(BorderStyle.None),
                new Border(4, BorderStyle.Single, GreenColor),
                new Border(BorderStyle.None));

            // Create paragraph with image
            signatureTable.Rows[0].Cells[0].PreferredWidth = new TableWidthUnit(140);
            Paragraph paragraphWithImage = signatureTable.Rows[0].Cells[0].Blocks.AddParagraph();
            paragraphWithImage.Spacing.SpacingAfter = 0;
            editor.MoveToParagraphStart(paragraphWithImage);
            using (Stream stream = FileHelper.GetSampleResourceStream("TelerikLogoSmall.png"))
            {
                editor.InsertImageInline(stream, "png", new Size(118, 42));
            }

            // Create cell with name and position
            signatureTable.Rows[0].Cells[1].PreferredWidth = new TableWidthUnit(140);
            signatureTable.Rows[0].Cells[1].Padding = new Documents.Primitives.Padding(12, 0, 0, 0);
            Paragraph cellParagraph = signatureTable.Rows[0].Cells[1].Blocks.AddParagraph();
            cellParagraph.Spacing.SpacingAfter = 0;
            editor.MoveToParagraphStart(cellParagraph);
            editor.CharacterFormatting.FontSize.LocalValue = 12;

            editor.InsertText("Jane Doe").FontWeight = FontWeights.Bold;
            editor.InsertParagraph().Spacing.SpacingAfter = 0;
            editor.InsertText("Support Officer");
        }
        private void CreateSignature(RadFlowDocumentEditor editor)
        {
            Table signatureTable = editor.InsertTable(1, 2);

            signatureTable.Rows[0].Cells[0].Borders = new TableCellBorders(
                new Border(BorderStyle.None),
                new Border(BorderStyle.None),
                new Border(4, BorderStyle.Single, greenColor),
                new Border(BorderStyle.None));

            // Create paragraph with image
            signatureTable.Rows[0].Cells[0].PreferredWidth = new TableWidthUnit(140);
            Paragraph paragraphWithImage = signatureTable.Rows[0].Cells[0].Blocks.AddParagraph();

            paragraphWithImage.Spacing.SpacingAfter = 0;
            editor.MoveToParagraphStart(paragraphWithImage);

            using (Stream stream = File.OpenRead(this.sampleDataFolder + "Telerik_logo.png"))
            {
                editor.InsertImageInline(stream, "png", new Size(118, 28));
            }

            // Create cell with name and position
            signatureTable.Rows[0].Cells[1].Padding = new Telerik.Windows.Documents.Primitives.Padding(12, 0, 0, 0);
            Paragraph cellParagraph = signatureTable.Rows[0].Cells[1].Blocks.AddParagraph();

            cellParagraph.Spacing.SpacingAfter = 0;
            editor.MoveToParagraphStart(cellParagraph);
            editor.CharacterFormatting.FontSize.LocalValue = 12;

            editor.InsertText("Jane Doe").FontWeight = FontWeights.Bold;
            editor.InsertParagraph().Spacing.SpacingAfter = 0;
            editor.InsertText("Support Officer");
        }
Пример #3
0
        private void CreateFields(RadFlowDocumentEditor editor)
        {
            #region radwordsprocessing-concepts-customcodefield_0
            editor.InsertField("PAGE  \\* ROMAN", "VII");
            #endregion

            #region radwordsprocessing-concepts-customcodefield_1
            editor.InsertText("Page ");
            editor.InsertField("PAGE", "3");
            editor.InsertText(" of ");
            editor.InsertField("NUMPAGES", "5");
            #endregion

            #region radwordsprocessing-concepts-customcodefield_2
            //editor.InsertField("DATE  \\@ \"M/d/yy\"", "17/2/14");
            #endregion

            #region radwordsprocessing-concepts-customcodefield_3
            editor.InsertField("AUTHOR  \\* Upper", "JOHN DOE");
            #endregion

            #region radwordsprocessing-concepts-customcodefield_4
            FieldInfo tocField = editor.InsertField("TOC \\o \"1-3\" \\h \\z \\u", "result");
            tocField.IsDirty = true;
            #endregion
        }
Пример #4
0
 private void InsertParagraph(RadFlowDocumentEditor editor)
 {
     #region radwordsprocessing-editing-radflowdocumenteditor_5
     editor.InsertText("First paragraph");
     editor.InsertParagraph();
     editor.InsertText("Second paragraph");
     #endregion
 }
Пример #5
0
        private void ImsertTable(RadFlowDocumentEditor editor, RadFlowDocument document)
        {
            #region radwordsprocessing-editing-radflowdocumenteditor_10
            document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.TableGridStyleId);
            editor.TableFormatting.StyleId = BuiltInStyleNames.TableGridStyleId;

            editor.InsertText("Before table.");
            editor.InsertTable(2, 4);
            editor.InsertText("After table.");
            #endregion
        }
Пример #6
0
        private void InsertFieldInFragment(RadFlowDocumentEditor editor, RadFlowDocument document)
        {
            #region radwordsprocessing-editing-radflowdocumenteditor_7
            // Create header and move the editor
            Header header = document.Sections[0].Headers.Add();
            editor.MoveToParagraphStart(header.Blocks.AddParagraph());

            editor.InsertText("Page ");
            editor.InsertField("PAGE", "1");
            editor.InsertText(" of ");
            editor.InsertField("NUMPAGES", "1");
            #endregion
        }
Пример #7
0
 private void CreateRadFlowDocument()
 {
     #region radwordsprocessing-getting-started_0
     RadFlowDocument       document = new RadFlowDocument();
     RadFlowDocumentEditor editor   = new RadFlowDocumentEditor(document);
     editor.InsertText("Hello world!");
     #endregion
 }
Пример #8
0
        private RadFlowDocument CreateDocument()
        {
            #region radwordsprocessing-editing-radflowdocumenteditor_3
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(new RadFlowDocument());
            editor.InsertText("Hello word!");
            return(editor.Document);

            #endregion
        }
Пример #9
0
        private void InsertComment2()
        {
            #region radwordsprocessing-model-comment_2
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(new RadFlowDocument());

            Run run = editor.InsertText("text");
            editor.InsertComment("My sample comment.", run, run);
            #endregion
        }
        private RadFlowDocument CreateDocument()
        {
            RadFlowDocument       document = new RadFlowDocument();
            RadFlowDocumentEditor editor   = new RadFlowDocumentEditor(document);

            editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;

            // Body
            editor.InsertLine("Dear Telerik User,");
            editor.InsertText("We’re happy to introduce the Telerik RadWordsProcessing component. High performance library that enables you to read, write and manipulate documents in DOCX, RTF and plain text format. The document model is independent from UI and ");
            Run run = editor.InsertText("does not require");

            run.Underline.Pattern = UnderlinePattern.Single;
            editor.InsertLine(" Microsoft Office.");

            editor.InsertText("The current community preview version comes with full rich-text capabilities including ");
            editor.InsertText("bold, ").FontWeight            = FontWeights.Bold;
            editor.InsertText("italic, ").FontStyle           = FontStyles.Italic;
            editor.InsertText("underline,").Underline.Pattern = UnderlinePattern.Single;
            editor.InsertText(" font sizes and ").FontSize    = Telerik.Windows.Documents.Media.Unit.PointToDip(20);
            Run coloredRun = editor.InsertText("colors ");

            coloredRun.ForegroundColor         = greenColor;
            coloredRun.Shading.BackgroundColor = yellowColor;

            editor.InsertLine("as well as text alignment and indentation. Other options include tables, hyperlinks, inline and floating images. Even more sweetness is added by the built-in styles and themes.");

            editor.InsertText("Here at Telerik we strive to provide the best services possible and fulfill all needs you as a customer may have. We would appreciate any feedback you send our way through the ");
            editor.InsertHyperlink("public forums", "http://www.telerik.com/forums", false, "Telerik Forums");
            editor.InsertLine(" or support ticketing system.");

            editor.InsertLine("We hope you’ll enjoy RadWordsProcessing as much as we do. Happy coding!");
            editor.InsertParagraph();
            editor.InsertText("Kind regards,");

            this.CreateSignature(editor);

            this.CreateHeader(editor);

            this.CreateFooter(editor);

            return(document);
        }
Пример #11
0
 private void InsertImage(RadFlowDocumentEditor editor)
 {
     #region radwordsprocessing-editing-radflowdocumenteditor_9
     editor.InsertText("Image:");
     using (Stream stream = this.GetResourceStream("Telerik_logo.png"))
     {
         editor.InsertImageInline(stream, "png", new Size(118, 28));
     }
     #endregion
 }
Пример #12
0
        private void NestedField()
        {
            #region radwordsprocessing-concepts-fields_4
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(new RadFlowDocument());

            // Create an outer field with empty code fragment
            FieldInfo outerFieldInfo = editor.InsertField(string.Empty, "if field result");

            // Move the editor after the field start character
            editor.MoveToInlineEnd(outerFieldInfo.Start);

            // Create the a code fragment with a nested TIME field
            editor.InsertText("IF ");
            editor.InsertField("TIME \\@ HH", "time field result");
            editor.InsertText(" < 12 \"Good morning!\" \"Good afternoon!\"");

            outerFieldInfo.UpdateField();
            Console.WriteLine(outerFieldInfo.GetResult()); // Output: Good afternoon!
            #endregion
        }
Пример #13
0
        private void CreateRunhWithRadFlowDocumentEditor()
        {
            #region radwordsprocessing-model-run_3
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(new RadFlowDocument());

            // Adds new run to the document
            Run run1 = editor.InsertText("First run ");

            // Adds new run and starts new paragraph
            Run run2 = editor.InsertLine("Second run");
            #endregion
        }
        private void CreateSignature(RadFlowDocumentEditor editor)
        {
            Table signatureTable = editor.InsertTable(1, 2);

            signatureTable.Rows[0].Cells[0].Borders = new TableCellBorders(
                new Border(BorderStyle.None),
                new Border(BorderStyle.None),
                new Border(4, BorderStyle.Single, GreenColor),
                new Border(BorderStyle.None));

            signatureTable.Rows[0].Cells[0].PreferredWidth = new TableWidthUnit(140);

            Paragraph paragraphWithImage = signatureTable.Rows[0].Cells[0].Blocks.AddParagraph();

            paragraphWithImage.Spacing.SpacingAfter = 0;

            editor.MoveToParagraphStart(paragraphWithImage);

            using (Stream stream = this.resourceService.GetResourceStream("telerikLogo.jpg"))
            {
                editor.InsertImageInline(stream, "png", new Telerik.Documents.Primitives.Size(93, 42));
            }

            signatureTable.Rows[0].Cells[1].PreferredWidth = new TableWidthUnit(140);
            signatureTable.Rows[0].Cells[1].Padding        = new Padding(12, 0, 0, 0);

            Paragraph cellParagraph = signatureTable.Rows[0].Cells[1].Blocks.AddParagraph();

            cellParagraph.Spacing.SpacingAfter = 0;

            editor.MoveToParagraphStart(cellParagraph);
            editor.CharacterFormatting.FontSize.LocalValue = 12;
            editor.InsertText("Jane Doe").FontWeight       = FontWeights.Bold;
            editor.InsertParagraph().Spacing.SpacingAfter = 0;
            editor.InsertText("Support Officer");
        }
Пример #15
0
 protected void btnExportXLSX_Click(object sender, EventArgs e)
 {
     /*
      * var document = new RadFlowDocument();
      * var editor = new RadFlowDocumentEditor(document);
      * editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;
      * editor.InsertLine("Dear Telerik User,");
      * editor.InsertText("We're happy to introduce the new Telerik RadWordsProcessing component for WPF. High performance library that enables you to read, write and manipulate documents in DOCX, RTF and plain text format. The document model is independent from UI and ");
      * Run run = editor.InsertText("does not require");
      * run.Underline.Pattern = UnderlinePattern.Single;
      * editor.InsertLine(" Microsoft Office.");
      * editor.InsertText("bold, ").FontWeight = System.Windows.FontWeights.Bold;
      * editor.InsertText("italic, ").FontStyle = System.Windows.FontStyles.Italic;
      * editor.InsertText("underline,").Underline.Pattern = UnderlinePattern.Single;
      * editor.InsertText(" font sizes and ").FontSize = 20;
      * editor.InsertText("colors ").ForegroundColor = new ThemableColor(System.Windows.Media.Colors.Green);
      * editor.InsertText("or ");
      * editor.InsertText("colors2 ").ForegroundColor = new ThemableColor(System.Windows.Media.Color.FromRgb(255,0,0));
      * editor.InsertLine("as well as text alignment and indentation. Other options include tables, hyperlinks, inline and floating images. Even more sweetness is added by the built-in styles and themes.");
      * editor.InsertText("Here at Telerik we strive to provide the best services possible and fulfill all needs you as a customer may have. We would appreciate any feedback you send our way through the ");
      * editor.InsertHyperlink("public forums", "http://www.telerik.com/forums", false, "Telerik Forums");
      * editor.InsertLine(" or support ticketing system.");
      * editor.InsertLine("We hope you'll enjoy RadWordsProcessing as much as we do. Happy coding!");
      * editor.InsertParagraph();
      * editor.InsertLine("Kind regards,");
      * editor.InsertLine("Telerik Admin");
      * exportDOCX(document);
      */
     try {
         DocumentReplacemetsController cont = new DocumentReplacemetsController();
         List <DocumentReplacemetB>    reps = new List <DocumentReplacemetB>();
         reps = cont.GetDocumentReplacemets("GLOBAL");
         DocumentReplacemetB curRep = reps.Find(o => o.Title == "Τίτλος Test");
         if (curRep != null)
         {
             RadFlowDocument       curDoc = LoadSampleDocument();
             RadFlowDocumentEditor editor = new RadFlowDocumentEditor(curDoc);
             //System.Text.RegularExpressions.Regex textRegex = new System.Text.RegularExpressions.Regex("ΣΑΟΥΣΟΠΟΥΛΟΥ ΑΝΝΑ");
             //editor.ReplaceText("ΣΑΟΥΣΟΠΟΥΛΟΥ ΑΝΝΑ", txtNew.Text, true, true);
             BookmarkRangeStart bookmarkRangeStart = editor.Document.EnumerateChildrenOfType <BookmarkRangeStart>().Where(rangeStart => rangeStart.Bookmark.Name == "Name2Change").FirstOrDefault();
             editor.MoveToInlineEnd(bookmarkRangeStart);
             editor.InsertText(curRep.Text);
             exportXLSX(curDoc);
         }
     }
     catch (Exception) { }
 }
Пример #16
0
        private RadFlowDocument CreateDocument()
        {
            RadFlowDocument       document = new RadFlowDocument();
            RadFlowDocumentEditor editor   = new RadFlowDocumentEditor(document);

            editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;

            Table bodyTable = editor.InsertTable(1, 2);

            Paragraph paragraphWithText = bodyTable.Rows[0].Cells[0].Blocks.AddParagraph();

            editor.MoveToParagraphStart(paragraphWithText);

            editor.InsertLine("Dear Telerik User,");
            editor.InsertLine("We're happy to introduce the Telerik RadWordsProcessing component. High performance library that enables you to read, write and manipulate documents in DOCX, RTF, HTML and plain text format.");

            editor.InsertText("The current beta version comes with full rich-text capabilities including ");
            editor.InsertText("bold, ").FontWeight  = FontWeights.Bold;
            editor.InsertText("italic, ").FontStyle = FontStyles.Italic;
            Run underlined = editor.InsertText("underline,");

            underlined.Underline.Pattern = UnderlinePattern.Dotted;
            underlined.Underline.Color   = new ThemableColor(Colors.Black);
            editor.InsertText(" font sizes and ").FontSize = 20;
            editor.InsertText("colors ").ForegroundColor   = GreenColor;
            editor.InsertLine("as well as text alignment and indentation. Other options include tables, lists, hyperlinks, bookmarks and comments, inline and floating images. Even more sweetness is added by the built-in styles and themes.");

            editor.InsertLine("We hope you'll enjoy RadWordsProcessing as much as we do. Happy coding!");

            editor.InsertParagraph().Spacing.SpacingAfter = 0;
            editor.InsertLine("Regards,");
            editor.InsertHyperlink("Telerik Team ", "http://www.telerik.com", false, "Telerik Site");

            Paragraph paragraphWithImage = bodyTable.Rows[0].Cells[1].Blocks.AddParagraph();

            editor.MoveToParagraphStart(paragraphWithImage);

#if NETCOREAPP
            using (Stream stream = File.OpenRead(SampleDataFolder + "WordsProcessing.jpg"))
            {
                editor.InsertImageInline(stream, "jpg", new Size(470, 261));
            }
#else
            using (Stream stream = File.OpenRead(SampleDataFolder + "WordsProcessing.png"))
            {
                editor.InsertImageInline(stream, "png", new Size(470, 261));
            }
#endif

            return(document);
        }
Пример #17
0
 private void InsertRun(RadFlowDocumentEditor editor)
 {
     #region radwordsprocessing-editing-radflowdocumenteditor_4
     editor.InsertText("First" + Environment.NewLine + "Second");
     #endregion
 }
        private RadFlowDocument CreateDocument()
        {
            RadFlowDocument document = new RadFlowDocument();
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
            editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;

            // Body
            editor.InsertLine("Dear Telerik User,");
            editor.InsertText("We’re happy to introduce the new Telerik RadWordsProcessing component for WPF. High performance library that enables you to read, write and manipulate documents in DOCX, RTF and plain text format. The document model is independent from UI and ");
            Run run = editor.InsertText("does not require");
            run.Underline.Pattern = UnderlinePattern.Single;
            editor.InsertLine(" Microsoft Office.");

            editor.InsertText("The current community preview version comes with full rich-text capabilities including ");
            editor.InsertText("bold, ").FontWeight = FontWeights.Bold;
            editor.InsertText("italic, ").FontStyle = FontStyles.Italic;
            editor.InsertText("underline,").Underline.Pattern = UnderlinePattern.Single;
            editor.InsertText(" font sizes and ").FontSize = 20;
            editor.InsertText("colors ").ForegroundColor = GreenColor;

            editor.InsertLine("as well as text alignment and indentation. Other options include tables, hyperlinks, inline and floating images. Even more sweetness is added by the built-in styles and themes.");

            editor.InsertText("Here at Telerik we strive to provide the best services possible and fulfill all needs you as a customer may have. We would appreciate any feedback you send our way through the ");
            editor.InsertHyperlink("public forums", "http://www.telerik.com/forums", false, "Telerik Forums");
            editor.InsertLine(" or support ticketing system.");

            editor.InsertLine("We hope you’ll enjoy RadWordsProcessing as much as we do. Happy coding!");
            editor.InsertParagraph();
            editor.InsertText("Kind regards,");

            this.CreateSignature(editor);

            this.CreateHeader(editor);

            this.CreateFooter(editor);

            return document;
        }
Пример #19
0
 protected void gridMain_ItemCommand(object sender, GridCommandEventArgs e)
 {
     if (e.CommandName == "invPrint")
     {
         GridDataItem        item          = (GridDataItem)e.Item;
         int                 orderID       = (int)((GridDataItem)e.Item).GetDataKeyValue("ID");
         OrdersController    oCont         = new OrdersController();
         OrderB              curOrder      = oCont.GetOrder(orderID);
         TasksController     lCont         = new TasksController();
         List <TaskB>        tasksForOrder = lCont.GetTasksForOrder(orderID);
         CustomersController cCont         = new CustomersController();
         CustomerB           curCust       = cCont.GetCustomer(curOrder.Customer1.ID);
         try {
             DocumentReplacemetsController cont = new DocumentReplacemetsController();
             List <DocumentReplacemetB>    reps = new List <DocumentReplacemetB>();
             reps = cont.GetDocumentReplacemets(sqlUniqueName);
             DocumentReplacemetB curRep;
             string                imgFolderPath = Server.MapPath(fileUploadFolder);
             RadFlowDocument       curDoc        = LoadTemplateDocument(docTemplate);
             RadFlowDocumentEditor editor        = new RadFlowDocumentEditor(curDoc);
             Run       currRun;
             Paragraph currPar;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             currRun = editor.InsertText("ATHENS " + DateTime.Now.ToString("dd/MM/yyyy"));
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             string regNo = curOrder.RegNo == null ? "" : curOrder.RegNo;
             currRun = editor.InsertText("REF. " + regNo);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table infoTable = editor.InsertTable(4, 2);
             infoTable.Borders            = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar                      = infoTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun                      = currPar.Inlines.AddRun("Information:");
             currPar                      = infoTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Πληροφορίες").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = infoTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Phone:");
             currPar = infoTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Τηλέφωνο").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = infoTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("FAX:");
             currPar = infoTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "FAX").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = infoTable.Rows[3].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Email:");
             currPar = infoTable.Rows[3].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Email").FirstOrDefault();
             if (curRep != null)
             {
                 Run currRun2 = currPar.Inlines.AddRun();
                 editor.MoveToInlineEnd(currRun2);
                 editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
                 editor.MoveToTableEnd(infoTable);
             }
             currPar = insertParagraph(editor);
             editor.MoveToParagraphStart(currPar);
             Telerik.Windows.Documents.Flow.Model.Table toTable = editor.InsertTable(3, 2);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = toTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("ATT.:");
             currPar = toTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             if (!string.IsNullOrEmpty(tasksForOrder[0].Customer.NameEN))
             {
                 currRun = currPar.Inlines.AddRun(tasksForOrder[0].Customer.NameEN);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = toTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Phone:");
             currPar = toTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             if (!string.IsNullOrEmpty(tasksForOrder[0].Customer.Telephone1))
             {
                 currRun = currPar.Inlines.AddRun(tasksForOrder[0].Customer.Telephone1);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = toTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("FAX:");
             currPar = toTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             if (!string.IsNullOrEmpty(tasksForOrder[0].Customer.FAX1))
             {
                 currRun = currPar.Inlines.AddRun(tasksForOrder[0].Customer.FAX1);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("SUBJECT:  TEMPORARΥ TELEPHONE LINES");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Justified;
             currRun = editor.InsertText("You are kindly requested to provide " + tasksForOrder.Count.ToString() + " temporary telephone lines.");
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table eventTable = editor.InsertTable(2, 2);
             eventTable.Borders           = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar                      = eventTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun                      = currPar.Inlines.AddRun("in:");
             currPar                      = eventTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curP = curOrder.Event.Place.NameEN == null ? "" : curOrder.Event.Place.NameEN;
             currRun = currPar.Inlines.AddRun(curP);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = eventTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("event:");
             currPar = eventTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curE = curOrder.Event.NameEN == null ? "" : curOrder.Event.NameEN;
             currRun = currPar.Inlines.AddRun(curE);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             int tRows = tasksForOrder.Count + 1;
             Telerik.Windows.Documents.Flow.Model.Table contentTable = editor.InsertTable(tRows, 5);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = contentTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currRun         = currPar.Inlines.AddRun("Customer Name");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("From");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[2].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("To");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[3].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Place of Instal.");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[4].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             int curRow = 1;
             foreach (TaskB curTask in tasksForOrder)
             {
                 currPar = contentTable.Rows[curRow].Cells[0].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curCust.NameEN);
                 currPar = contentTable.Rows[curRow].Cells[1].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeStartOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[2].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeEndOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[3].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.RequestedPosition.NameEN);
                 currPar = contentTable.Rows[curRow].Cells[4].Blocks.AddParagraph();
                 string LineType2Print = curTask.LineType.Name;
                 if (curTask.Internet == true)
                 {
                     LineType2Print += " + WIFI ROUTER";
                 }
                 currRun = currPar.Inlines.AddRun(LineType2Print);
                 curRow++;
             }
             var    distinctTasksLT = tasksForOrder.Select(m => new { m.LineTypeID, m.Internet, m.MSN }).Distinct().ToList();
             string concatString    = "";
             int    distinctItems   = 0;
             foreach (var dItem in distinctTasksLT)
             {
                 if (distinctItems > 0 && distinctItems < distinctTasksLT.Count - 1)
                 {
                     concatString += ", ";
                 }
                 else if (distinctItems > 0 && distinctItems == distinctTasksLT.Count - 1)
                 {
                     concatString += " & ";
                 }
                 TaskB demoTask  = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).FirstOrDefault();
                 int   itemCount = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).Count();
                 concatString += itemCount.ToString() + " " + demoTask.LineType.Name;
                 if (demoTask.Internet == true && demoTask.MSN == true)
                 {
                     concatString += " with router and MSN";
                 }
                 else if (demoTask.Internet == true)
                 {
                     concatString += " with router";
                 }
                 else if (demoTask.MSN == true)
                 {
                     concatString += " with MSN";
                 }
                 distinctItems++;
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Please provide " + concatString);
             currRun.Properties.FontSize.LocalValue   = Telerik.Windows.Documents.Media.Unit.PointToDip(9);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Contact Person: " + reps.Where(o => o.Title == "Contact Person").FirstOrDefault().Text + "  Mob:" + reps.Where(o => o.Title == "Κινητό C.P.").FirstOrDefault().Text);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Please advise on allocated numbers A.S.A.P. to the e-mail address: ");
             editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("HELLENIC TELECOMMUNICATIONS ORGANIZATION SA (OTE GROUP OF COMPANIES)");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("VAT Number: ");
             currRun = editor.InsertText("EL 094019245");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Responsible for the payments is our company:");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("HELLENIC TELECOMMUNICATIONS ORGANIZATION SA (OTE GROUP OF COMPANIES) via its Billing department bellow");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Delivery invoice address for the original invoice (Post mail):");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("OTE INTERNATIONAL SOLUTION SA (OTEGLOBE)");
             curRep  = reps.Where(o => o.Title == "OTEGlobe Διεύθυνση 1").FirstOrDefault();
             currPar = insertParagraph(editor);
             if (curRep != null)
             {
                 //currPar = insertParagraph(editor);
                 //currRun = editor.InsertText(curRep.Text);
                 currRun = editor.InsertLine(curRep.Text);
             }
             curRep = reps.Where(o => o.Title == "OTEGlobe Διεύθυνση 2").FirstOrDefault();
             if (curRep != null)
             {
                 //currPar = insertParagraph(editor);
                 //currRun = editor.InsertText(curRep.Text);
                 currRun = editor.InsertLine(curRep.Text);
             }
             curRep = reps.Where(o => o.Title == "OTEGlobe Site").FirstOrDefault();
             if (curRep != null)
             {
                 //currPar = insertParagraph(editor);
                 editor.InsertHyperlink(curRep.Text, "http://" + curRep.Text, false);
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             string rep = "";
             curRep = reps.Where(o => o.Title == "Person In Charge").FirstOrDefault();
             if (curRep != null)
             {
                 rep += curRep.Text;
             }
             curRep = reps.Where(o => o.Title == "Person In Charge (Phone)").FirstOrDefault();
             if (curRep != null)
             {
                 rep += curRep.Text;
             }
             if (!string.IsNullOrEmpty(rep))
             {
                 currRun = editor.InsertText("(Person in charge " + rep + ")");
                 currPar = insertParagraph(editor);
             }
             curRep = reps.Where(o => o.Title == "Person In Charge (Email)").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = editor.InsertText("Email: ");
                 editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
                 currPar = insertParagraph(editor);
             }
             currRun = editor.InsertText("Email: ");
             editor.InsertHyperlink("*****@*****.**", "mailto:[email protected]", false);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             curRep  = reps.Where(o => o.Title == "Email").FirstOrDefault();
             if (curRep != null)
             {
                 currPar = insertParagraph(editor);
                 currRun = editor.InsertText("You could notify a copy of the invoice (as a pdf) to this e-mail: ");
                 editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("The charges will be settled via Bank transfer.");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Best regards,");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("SAOUSOPOULOU ANNA");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("MANAGER OF GENTRANS, ATHENS");
             curDoc.UpdateFields();
             exportDOCX(curDoc);
         }
         catch (Exception ex) { }
     }
 }
Пример #20
0
        private RadFlowDocument CreateDocument()
        {
            RadFlowDocument document = new RadFlowDocument();
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
            editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;

            Table bodyTable = editor.InsertTable(1, 2);

            Paragraph paragraphWithText = bodyTable.Rows[0].Cells[0].Blocks.AddParagraph();
            editor.MoveToParagraphStart(paragraphWithText);

            editor.InsertLine("Dear Telerik User,");
            editor.InsertLine("We're happy to introduce the new Telerik RadWordsProcessing component for WPF. High performance library that enables you to read, write and manipulate documents in DOCX, RTF, HTML and plain text format.");

            editor.InsertText("The current beta version comes with full rich-text capabilities including ");
            editor.InsertText("bold, ").FontWeight = FontWeights.Bold;
            editor.InsertText("italic, ").FontStyle = FontStyles.Italic;
            Run underlined = editor.InsertText("underline,");
            underlined.Underline.Pattern = UnderlinePattern.Dotted;
            underlined.Underline.Color = new ThemableColor(Colors.Black);
            editor.InsertText(" font sizes and ").FontSize = 20;
            editor.InsertText("colors ").ForegroundColor = GreenColor;
            editor.InsertLine("as well as text alignment and indentation. Other options include tables, lists, hyperlinks, bookmarks and comments, inline and floating images. Even more sweetness is added by the built-in styles and themes.");

            editor.InsertLine("We hope you'll enjoy RadWordsProcessing as much as we do. Happy coding!");

            editor.InsertParagraph().Spacing.SpacingAfter = 0;
            editor.InsertLine("Regards,");
            editor.InsertHyperlink("Telerik Team ", "http://www.telerik.com", false, "Telerik Site");

            Paragraph paragraphWithImage = bodyTable.Rows[0].Cells[1].Blocks.AddParagraph();
            editor.MoveToParagraphStart(paragraphWithImage);

            using (Stream stream = FileHelper.GetSampleResourceStream("WordsProcessing.png"))
            {
                editor.InsertImageInline(stream, "png", new Size(470, 261));
            }

            return document;
        }
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            try {
                DocumentReplacemetsController cont = new DocumentReplacemetsController();
                List <DocumentReplacemetB>    reps = new List <DocumentReplacemetB>();
                reps = cont.GetDocumentReplacemets(sqlUniqueName);
                string imgFolderPath = Server.MapPath(fileUploadFolder);
                DocumentReplacemetB curRep;
                BookmarkRangeStart  bookmarkRangeStart;
                RadFlowDocument     curDoc = LoadSampleDocument(sqlUniqueName);

                RadFlowDocumentEditor editor = new RadFlowDocumentEditor(curDoc);
                //System.Text.RegularExpressions.Regex textRegex = new System.Text.RegularExpressions.Regex("ΣΑΟΥΣΟΠΟΥΛΟΥ ΑΝΝΑ");
                //editor.ReplaceText("ΣΑΟΥΣΟΠΟΥΛΟΥ ΑΝΝΑ", txtNew.Text, true, true);
                List <BookmarkRangeStart> test = editor.Document.EnumerateChildrenOfType <BookmarkRangeStart>().ToList();
                Telerik.Windows.Documents.Flow.Model.TableCell currCell;
                Run currRun;

                Header defaultHeader = editor.Document.Sections.First().Headers.Default;
                Footer defaultFooter = editor.Document.Sections.First().Footers.Default;
                //Telerik.Windows.Documents.Flow.Model.Table headerTable = defaultHeader.Blocks.OfType<Telerik.Windows.Documents.Flow.Model.Table>().First();
                //Telerik.Windows.Documents.Flow.Model.TableCell firstCell = headerTable.Rows[0].Cells[0];

                Telerik.Windows.Documents.Flow.Model.Styles.Style tableStyle = new Telerik.Windows.Documents.Flow.Model.Styles.Style("TableStyle", StyleType.Table);
                tableStyle.Name = "Table Style";
                tableStyle.TableProperties.Borders.LocalValue               = new TableBorders(new Border(1, Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.Single, new ThemableColor(System.Windows.Media.Colors.Black)));
                tableStyle.TableProperties.Alignment.LocalValue             = Alignment.Left;
                tableStyle.TableCellProperties.VerticalAlignment.LocalValue = VerticalAlignment.Center;
                tableStyle.TableCellProperties.PreferredWidth.LocalValue    = new TableWidthUnit(TableWidthUnitType.Percent, 100);
                tableStyle.TableCellProperties.Padding.LocalValue           = new Telerik.Windows.Documents.Primitives.Padding(8);
                editor.Document.StyleRepository.Add(tableStyle);

                curRep   = reps.Find(o => o.UniqueName == "KET_Header_OTELogo");
                currCell = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                using (Stream firstImage = File.OpenRead(imgFolderPath + curRep.Text)) {
                    var inImage = ((Paragraph)currCell.Blocks.First()).Inlines.AddImageInline();
                    inImage.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(firstImage, curRep.Text.Split('.').Last());
                    if (curRep.ImageHeight != null && curRep.ImageWidth != null)
                    {
                        inImage.Image.Height = curRep.ImageHeight.Value;
                        inImage.Image.Width  = curRep.ImageWidth.Value;
                    }
                }

                curRep       = reps.Find(o => o.UniqueName == "KET_Header_OTEMoto");
                currCell     = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                currRun      = ((Paragraph)currCell.Blocks.First()).Inlines.AddRun();
                currRun.Text = curRep.Text;
                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                currRun.Properties.FontSize.LocalValue   = 13.0;
                currRun.Properties.FontWeight.LocalValue = FontWeights.Normal;
                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;

                curRep       = reps.Find(o => o.UniqueName == "KET_Header_Title");
                currCell     = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                currRun      = ((Paragraph)currCell.Blocks.First()).Inlines.AddRun();
                currRun.Text = curRep.Text;
                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                currRun.Properties.FontSize.LocalValue   = 15.0;
                currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;

                curRep   = reps.Find(o => o.UniqueName == "KET_Header_Department");
                currCell = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                string[]  arrText = curRep.Text.Replace("\r\n", "#").Replace("\n", "#").Split(new char[] { '#' });
                Paragraph newPar  = (Paragraph)currCell.Blocks.First();
                newPar.Properties.TextAlignment.LocalValue = Alignment.Center;
                editor.MoveToInlineStart(((Paragraph)currCell.Blocks.First()).Inlines.First());
                for (int i = 0; i < arrText.Length; i++)
                {
                    currRun = editor.InsertLine(arrText[i]);
                    currRun.Paragraph.Properties.TextAlignment.LocalValue = Alignment.Center;
                    currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Times New Roman");
                    currRun.Properties.FontSize.LocalValue   = 15.0;
                    currRun.Properties.FontWeight.LocalValue = FontWeights.Normal;
                    currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;
                }
                currCell.Blocks.Remove(currCell.Blocks.Last());

                curRep       = reps.Find(o => o.UniqueName == "KET_Header_EDEPPOI");
                currCell     = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                currRun      = ((Paragraph)currCell.Blocks.First()).Inlines.AddRun();
                currRun.Text = curRep.Text;
                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                currRun.Properties.FontSize.LocalValue   = 15.0;
                currRun.Properties.FontWeight.LocalValue = FontWeights.Normal;
                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;

                curRep   = reps.Find(o => o.UniqueName == "KET_Header_PageNo");
                currCell = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                editor.MoveToParagraphStart((Paragraph)currCell.Blocks.First());
                editor.InsertText("ΣΕΛΙΔΑ ");
                editor.InsertField("PAGE", "3");
                if (curRep.Text == "Σελίδα Χ από Υ")
                {
                    editor.InsertText(" ΑΠΟ ");
                    editor.InsertField("NUMPAGES", "5");
                }

                curRep             = reps.Find(o => o.UniqueName == "KET_Header_Date");
                bookmarkRangeStart = defaultHeader.EnumerateChildrenOfType <BookmarkRangeStart>().Where(rangeStart => rangeStart.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault();
                editor.MoveToInlineEnd(bookmarkRangeStart);
                editor.InsertText(DateTime.Now.ToString(curRep.Text, new System.Globalization.CultureInfo("el-GR")));

                curRep             = reps.Find(o => o.UniqueName == "KET_Header_To");
                bookmarkRangeStart = defaultHeader.EnumerateChildrenOfType <BookmarkRangeStart>().Where(rangeStart => rangeStart.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault();
                editor.MoveToInlineEnd(bookmarkRangeStart);
                editor.InsertText(curRep.Text);

                curRep   = reps.Find(o => o.UniqueName == "KET_Footer_OTELogo");
                currCell = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                using (Stream firstImage = File.OpenRead(imgFolderPath + curRep.Text)) {
                    var inImage = ((Paragraph)currCell.Blocks.First()).Inlines.AddImageInline();
                    inImage.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(firstImage, curRep.Text.Split('.').Last());
                    if (curRep.ImageHeight != null && curRep.ImageWidth != null)
                    {
                        inImage.Image.Height = curRep.ImageHeight.Value;
                        inImage.Image.Width  = curRep.ImageWidth.Value;
                    }
                }

                curRep   = reps.Find(o => o.UniqueName == "KET_Footer_ELOT");
                currCell = (Telerik.Windows.Documents.Flow.Model.TableCell)test.Where(o => o.Bookmark.Name == curRep.BookmarkTitle).FirstOrDefault().Paragraph.BlockContainer;
                using (Stream firstImage = File.OpenRead(imgFolderPath + curRep.Text)) {
                    var inImage = ((Paragraph)currCell.Blocks.First()).Inlines.AddImageInline();
                    inImage.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(firstImage, curRep.Text.Split('.').Last());
                    if (curRep.ImageHeight != null && curRep.ImageWidth != null)
                    {
                        inImage.Image.Height = curRep.ImageHeight.Value;
                        inImage.Image.Width  = curRep.ImageWidth.Value;
                    }
                }

                List <TaskForH> lstDummy = createDummyList();
                bookmarkRangeStart = editor.Document.EnumerateChildrenOfType <BookmarkRangeStart>().Where(rangeStart => rangeStart.Bookmark.Name == "Body_Main").FirstOrDefault();
                editor.MoveToInlineEnd(bookmarkRangeStart);
                Telerik.Windows.Documents.Flow.Model.Table tblContent = editor.InsertTable();
                tblContent.StyleId    = "TableStyle";
                tblContent.LayoutType = TableLayoutType.AutoFit;
                ThemableColor cellBackground = new ThemableColor(System.Windows.Media.Colors.Beige);
                for (int i = 0; i < lstDummy.Count; i++)
                {
                    Telerik.Windows.Documents.Flow.Model.TableRow row = tblContent.Rows.AddTableRow();
                    for (int j = 0; j < 5; j++)
                    {
                        Telerik.Windows.Documents.Flow.Model.TableCell cell = row.Cells.AddTableCell();
                        if (i == 0)
                        {
                            if (j == 0)
                            {
                                currRun = cell.Blocks.AddParagraph().Inlines.AddRun("A/A");
                                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                                currRun.Properties.FontSize.LocalValue   = 15.0;
                                currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
                                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;
                                cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 5);
                            }
                            else if (j == 1)
                            {
                                currRun = cell.Blocks.AddParagraph().Inlines.AddRun("ΑΙΤΩΝ");
                                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                                currRun.Properties.FontSize.LocalValue   = 15.0;
                                currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
                                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;
                                cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 20);
                            }
                            else if (j == 2)
                            {
                                currRun = cell.Blocks.AddParagraph().Inlines.AddRun("ΑΠΟ");
                                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                                currRun.Properties.FontSize.LocalValue   = 15.0;
                                currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
                                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;
                                cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 20);
                            }
                            else if (j == 3)
                            {
                                currRun = cell.Blocks.AddParagraph().Inlines.AddRun("ΩΡΑ");
                                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                                currRun.Properties.FontSize.LocalValue   = 15.0;
                                currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
                                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;
                                cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 20);
                            }
                            else if (j == 4)
                            {
                                currRun = cell.Blocks.AddParagraph().Inlines.AddRun("ΠΑΡΑΤΗΡΗΣΕΙΣ");
                                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                                currRun.Properties.FontSize.LocalValue   = 15.0;
                                currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
                                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;
                                cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 35);
                            }
                        }
                        else
                        {
                            if (j == 0)
                            {
                                currRun = cell.Blocks.AddParagraph().Inlines.AddRun(lstDummy.Where(o => o.Count == i).FirstOrDefault().Count.ToString());
                                currRun.Properties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
                                currRun.Properties.FontSize.LocalValue   = 15.0;
                                currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
                                currRun.Properties.FontStyle.LocalValue  = FontStyles.Normal;
                            }
                            else if (j == 1)
                            {
                                cell.Blocks.AddParagraph().Inlines.AddRun(lstDummy.Where(o => o.Count == i).FirstOrDefault().Customer);
                            }
                            else if (j == 2)
                            {
                                cell.Blocks.AddParagraph().Inlines.AddRun(lstDummy.Where(o => o.Count == i).FirstOrDefault().FromPlace);
                            }
                            else if (j == 3)
                            {
                                cell.Blocks.AddParagraph().Inlines.AddRun(lstDummy.Where(o => o.Count == i).FirstOrDefault().FromTime + " - " + lstDummy.Where(o => o.Count == i).FirstOrDefault().ToTime);
                            }
                            else if (j == 4)
                            {
                                cell.Blocks.AddParagraph().Inlines.AddRun(lstDummy.Where(o => o.Count == i).FirstOrDefault().Comments);
                            }
                        }
                    }
                }
                curDoc.UpdateFields();
                exportDOCX(curDoc);
            }
            catch (Exception ex) { }
        }
Пример #22
0
        private RadFlowDocument CreateMailMergeDocumentTemplate()
        {
            RadFlowDocument       document = new RadFlowDocument();
            RadFlowDocumentEditor editor   = new RadFlowDocumentEditor(document);

            editor.InsertText("Hello ");
            editor.InsertField("MERGEFIELD FirstName ", "«FirstName»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD LastName ", "«LastName»");
            editor.InsertText(",");

            editor.InsertParagraph();
            editor.InsertParagraph();
            editor.InsertText("On behalf of ");
            editor.InsertField("MERGEFIELD CompanyName ", "«CompanyName»");
            editor.InsertText(", ");
            editor.InsertText("I would like to thank you for the purchase of ");
            editor.InsertField("MERGEFIELD PurchasedItemsCount ", "«PurchasedItemsCount»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD ProductName ", "«ProductName»");
            editor.InsertText(" done by you from us.");

            editor.InsertParagraph();
            editor.InsertText("We are committed to provide you with the highest level of customer satisfaction possible. ");
            editor.InsertText("If for any reasons you have questions or comments please call ");
            editor.InsertField("MERGEFIELD ProductSupportPhone ", "«ProductSupportPhone»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD ProductSupportPhoneAvailability ", "«ProductSupportPhoneAvailability»");
            editor.InsertText(", or email us at ");
            editor.InsertField("MERGEFIELD ProductSupportEmail ", "«ProductSupportEmail»");
            editor.InsertText(".");

            editor.InsertParagraph();
            editor.InsertText("Once again thank you for choosing ");
            editor.InsertField("MERGEFIELD CompanyName ", "«CompanyName»");
            editor.InsertText(".");

            editor.InsertParagraph();
            editor.InsertParagraph();
            editor.InsertText("Sincerely yours,");
            editor.InsertParagraph();
            editor.InsertField("MERGEFIELD SalesRepFirstName ", "«SalesRepFirstName»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD SalesRepLastName ", "«SalesRepLastName»");
            editor.InsertText(",");

            Paragraph paragraph = editor.InsertParagraph();

            FieldInfo fieldInfo = new FieldInfo(document);

            paragraph.Inlines.Add(fieldInfo.Start);
            paragraph.Inlines.AddRun("MERGEFIELD SalesRepTitle ");
            paragraph.Inlines.Add(fieldInfo.Separator);
            paragraph.Inlines.AddRun("«SalesRepTitle» ");
            paragraph.Inlines.Add(fieldInfo.End);

            return(document);
        }
Пример #23
0
 protected void gridMain_ItemCommand(object sender, GridCommandEventArgs e)
 {
     if (e.CommandName == "invPrint")
     {
         GridDataItem        item          = (GridDataItem)e.Item;
         int                 orderID       = (int)((GridDataItem)e.Item).GetDataKeyValue("ID");
         OrdersController    oCont         = new OrdersController();
         OrderB              curOrder      = oCont.GetOrder(orderID);
         TasksController     lCont         = new TasksController();
         List <TaskB>        tasksForOrder = lCont.GetTasksForOrder(orderID);
         CustomersController cCont         = new CustomersController();
         CustomerB           curCust       = cCont.GetCustomer(curOrder.Customer1.ID);
         try {
             DocumentReplacemetsController cont = new DocumentReplacemetsController();
             List <DocumentReplacemetB>    reps = new List <DocumentReplacemetB>();
             reps = cont.GetDocumentReplacemets(sqlUniqueName);
             DocumentReplacemetB curRep;
             string                imgFolderPath = Server.MapPath(fileUploadFolder);
             RadFlowDocument       curDoc        = LoadTemplateDocument(docTemplate);
             RadFlowDocumentEditor editor        = new RadFlowDocumentEditor(curDoc);
             Run       currRun;
             Paragraph currPar;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             currRun = editor.InsertText("ΑΘΗΝΑ " + DateTime.Now.ToString("dd/MM/yyyy"));
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             string regNo = curOrder.RegNo == null ? "" : curOrder.RegNo;
             currRun = editor.InsertText("ΑΡΙΘ. ΠΡΩΤ. " + regNo);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("ΟΡΓAΝΙΣΜΟΣ ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΤΗΣ ΕΛΛΑΔΟΣ ΑΕ");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("GENTRANS ATHENS");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table infoTable = editor.InsertTable(3, 2);
             infoTable.Borders            = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar                      = infoTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun                      = currPar.Inlines.AddRun("Πληροφορίες:");
             currPar                      = infoTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Πληροφορίες").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
             }
             currPar = infoTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Τηλέφωνο:");
             currPar = infoTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Τηλέφωνο").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
             }
             currPar = infoTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("FAX:");
             currPar = infoTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "FAX").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("ΘΕΜΑ:	ΠΡΟΣΩΡΙΝΕΣ ΤΗΛΕΦΩΝΙΚΕΣ ΣΥΝΔΕΣΕΙΣ");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table toTable = editor.InsertTable(3, 2);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = toTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Αιτηθείσα χώρα:");
             currPar = toTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curC = curCust.Country.NameGR == null ? "" : toUpperGR(curCust.Country.NameGR);
             currRun = currPar.Inlines.AddRun(curC);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = toTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Χώρος διεξαγωγής:");
             currPar = toTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curP = curOrder.Event.Place.NameGR == null ? "" : toUpperGR(curOrder.Event.Place.NameGR);
             currRun = currPar.Inlines.AddRun(curP);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = toTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Κάλυψη γεγονότος:");
             currPar = toTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curE = curOrder.Event.NameGR == null ? "" : toUpperGR(curOrder.Event.NameGR);
             currRun = currPar.Inlines.AddRun(curE);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Justified;
             var    distinctTasksLT = tasksForOrder.Select(m => new { m.LineTypeID, m.Internet, m.MSN }).Distinct().ToList();
             string concatString    = "";
             int    distinctItems   = 0;
             foreach (var dItem in distinctTasksLT)
             {
                 if (distinctItems > 0)
                 {
                     concatString += ", ";
                 }
                 TaskB demoTask  = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).FirstOrDefault();
                 int   itemCount = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).Count();
                 concatString += itemCount.ToString() + " " + demoTask.LineType.Name;
                 if (demoTask.Internet == true && demoTask.MSN == true)
                 {
                     concatString += " με ασύρματο ρούτερ και με MSN";
                 }
                 else if (demoTask.Internet == true)
                 {
                     concatString += " με ασύρματο ρούτερ";
                 }
                 else if (demoTask.MSN == true)
                 {
                     concatString += " με MSN";
                 }
                 distinctItems++;
             }
             currRun = editor.InsertText("Παρακαλούμε για την παροχή των εξής Προσωρινών Τηλεφωνικών Συνδέσεων για λογαριασμό του πιο κάτω πελάτη στη αντίστοιχη θέση: " + concatString + ".");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             int tRows = tasksForOrder.Count + 1;
             Telerik.Windows.Documents.Flow.Model.Table contentTable = editor.InsertTable(tRows, 5);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = contentTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currRun         = currPar.Inlines.AddRun("Πελάτης Εξωτερικού:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Από");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[2].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Έως:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[3].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Θέση:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[4].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Σύνδεση:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             int curRow = 1;
             foreach (TaskB curTask in tasksForOrder)
             {
                 currPar = contentTable.Rows[curRow].Cells[0].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curCust.NameGR);
                 currPar = contentTable.Rows[curRow].Cells[1].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeStartOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[2].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeEndOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[3].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.RequestedPosition.NameGR);
                 currPar = contentTable.Rows[curRow].Cells[4].Blocks.AddParagraph();
                 string LineType2Print = curTask.LineType.Name;
                 if (curTask.Internet == true)
                 {
                     LineType2Print += " + WIFI ROUTER";
                 }
                 currRun = currPar.Inlines.AddRun(LineType2Print);
                 curRow++;
             }
             var distinctTasksC = tasksForOrder.Select(m => new { m.Comments }).Distinct().ToList();
             if (distinctTasksC.Count > 0)
             {
                 currPar = insertParagraph(editor);
                 currPar = insertParagraph(editor);
                 currRun = editor.InsertText("ΣΗΜΕΙΩΣΕΙΣ ΠΕΛΑΤΗ:");
                 currRun.Properties.FontWeight.LocalValue      = FontWeights.Bold;
                 currRun.Properties.ForegroundColor.LocalValue = new ThemableColor(System.Windows.Media.Color.FromRgb(255, 0, 0));
                 foreach (var dItem in distinctTasksC)
                 {
                     if (!string.IsNullOrEmpty(dItem.Comments))
                     {
                         TaskB demoTask = tasksForOrder.Where(k => k.Comments == dItem.Comments).FirstOrDefault();
                         currPar = insertParagraph(editor);
                         currPar.Indentation.LeftIndent = Telerik.Windows.Documents.Media.Unit.InchToDip(1);
                         currRun = editor.InsertText(demoTask.LineType.Name + "  -  " + demoTask.Comments);
                         currRun.Properties.FontWeight.LocalValue      = FontWeights.Bold;
                         currRun.Properties.ForegroundColor.LocalValue = new ThemableColor(System.Windows.Media.Color.FromRgb(255, 0, 0));
                     }
                 }
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Εγκατάσταση στο  OB VAN/TV COMPOUND");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Ανταποκριτής: Mr. Leo Giovanni  +393357415070");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Παρακαλούμε να μας γνωρίσετε τον αριθμό κλήσης που θα διαθέσετε.");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("H χρέωση θα γίνει από το Τμήμα Ρ/Τ Μεταδόσεων.");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.Indentation.LeftIndent = Telerik.Windows.Documents.Media.Unit.InchToDip(3);
             //currPar.TextAlignment = Alignment.Center;
             curRep = reps.Where(o => o.Title == "Προϊστάμενος").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = editor.InsertText(curRep.Text);
             }
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar.Indentation.LeftIndent      = Telerik.Windows.Documents.Media.Unit.InchToDip(3);
             currPar.Indentation.HangingIndent   = Telerik.Windows.Documents.Media.Unit.InchToDip(0);
             currPar.Indentation.RightIndent     = Telerik.Windows.Documents.Media.Unit.InchToDip(0);
             currPar.Indentation.FirstLineIndent = Telerik.Windows.Documents.Media.Unit.InchToDip(0);
             currPar.TextAlignment = Alignment.Left;
             curRep = reps.Where(o => o.Title == "Τίτλος").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = editor.InsertText(curRep.Text);
             }
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             curDoc.UpdateFields();
             exportDOCX(curDoc);
         }
         catch (Exception ex) { }
     }
 }
Пример #24
0
        private RadFlowDocument CreateMailMergeDocumentTemplate()
        {
            RadFlowDocument document = new RadFlowDocument();
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);

            editor.InsertText("Hello ");
            editor.InsertField("MERGEFIELD FirstName ", "«FirstName»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD LastName ", "«LastName»");
            editor.InsertText(",");

            editor.InsertParagraph();
            editor.InsertParagraph();
            editor.InsertText("On behalf of ");
            editor.InsertField("MERGEFIELD CompanyName ", "«CompanyName»");
            editor.InsertText(", ");
            editor.InsertText("I would like to thank you for the purchase of ");
            editor.InsertField("MERGEFIELD PurchasedItemsCount ", "«PurchasedItemsCount»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD ProductName ", "«ProductName»");
            editor.InsertText(" done by you from us.");

            editor.InsertParagraph();
            editor.InsertText("We are committed to provide you with the highest level of customer satisfaction possible. ");
            editor.InsertText("If for any reasons you have questions or comments please call ");
            editor.InsertField("MERGEFIELD ProductSupportPhone ", "«ProductSupportPhone»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD ProductSupportPhoneAvailability ", "«ProductSupportPhoneAvailability»");
            editor.InsertText(", or email us at ");
            editor.InsertField("MERGEFIELD ProductSupportEmail ", "«ProductSupportEmail»");
            editor.InsertText(".");

            editor.InsertParagraph();
            editor.InsertText("Once again thank you for choosing ");
            editor.InsertField("MERGEFIELD CompanyName ", "«CompanyName»");
            editor.InsertText(".");

            editor.InsertParagraph();
            editor.InsertParagraph();
            editor.InsertText("Sincerely yours,");
            editor.InsertParagraph();
            editor.InsertField("MERGEFIELD SalesRepFirstName ", "«SalesRepFirstName»");
            editor.InsertText(" ");
            editor.InsertField("MERGEFIELD SalesRepLastName ", "«SalesRepLastName»");
            editor.InsertText(",");

            Paragraph paragraph = editor.InsertParagraph();

            FieldInfo fieldInfo = new FieldInfo(document);
            paragraph.Inlines.Add(fieldInfo.Start);
            paragraph.Inlines.AddRun("MERGEFIELD SalesRepTitle ");
            paragraph.Inlines.Add(fieldInfo.Separator);
            paragraph.Inlines.AddRun("«SalesRepTitle» ");
            paragraph.Inlines.Add(fieldInfo.End);

            return document;
        }