Represents a document paragraph.
Inheritance: InsertBeforeOrAfter
        internal static Paragraph DocumentDependencies(this DocX body, string input, Paragraph parent = null)
        {
            if (string.IsNullOrEmpty(input))
                return null;

            Paragraph paragraph = parent ?? body.InsertParagraph();
            paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore + 1;

            paragraph.InsertText("Dependent activities: ", false, new Formatting
            {
                Bold = true,
                Size = 10,
            });

            paragraph.InsertText(input, false, new Formatting
            {
                FontColor = Color.Black,
                FontFamily = new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif),
                Size = 9,
            });

            body.InsertParagraph();

            return paragraph;
        }
Example #2
0
        public Models.Paragraph Views(Novacode.Paragraph p, DocumentFormat.OpenXml.Wordprocessing.Paragraph p2)
        {
            var par = new Models.Paragraph();

            par.Alignment = p.Alignment.ToString();
            par.Text      = p.Text;

            foreach (var m in p.MagicText)
            {
                var mt = new MagicText();

                if (m.formatting.FontFamily != null)
                {
                    mt.Font.Family = m.formatting.FontFamily.Name;
                }
                if (m.formatting.Size != null)
                {
                    mt.Font.Size = (float)m.formatting.Size;
                }
                if (m.formatting.Bold != null)
                {
                    mt.Font.Bold = m.formatting.Bold.Value;
                }
                if (m.formatting.Italic != null)
                {
                    mt.Font.Italic = m.formatting.Italic.Value;
                }

                par.MagicText[m.text] = mt;
            }

            return(par);
        }
Example #3
0
        private bool ReplaceBday(Paragraph pg, string code, DirectoryInfo di)
        {
            if (!bdayre.IsMatch(code))
            {
                return(false);
            }
            if (di.Person.BirthDate.HasValue)
            {
                var m   = bdayre.Match(code);
                var txt = m.Groups["text"].Value;

                if (!txt.HasValue())
                {
                    pg.ReplaceText(code, di.Person.BirthDate.ToString2("MMM d"));
                }
                else
                {
                    txt = txt.Replace("_first_", di.Person.PreferredName);
                    m   = dtfmtre.Match(txt);
                    var repl = m.Value;
                    var mfmt = m.Groups["fmt"].Value;
                    txt = txt.Replace(repl, di.Person.BirthDate.ToString2(Util.PickFirst(mfmt, "MMM d")));
                    pg.ReplaceText(code, txt);
                }
            }
            else
            {
                pg.ReplaceText(code, "");
            }
            return(true);
        }
Example #4
0
 public BaseConverter( DocX d, Paragraph p ) {
   _paragraph = p;
   _document = d;
   _text = Sanitize( _paragraph.Text );
   CheckHiperlinks();
   CheckPictures();
 }
        /// <summary>
        /// Method that creates a Microsoft Word Document full of the QR code images that are associated with each question
        /// of the current treasure hunt and passes to the Print view the location of where this new file is stored.
        /// </summary>
        public void ExecutePrintQRCodesCommand()
        {
            PopupMessage   = "Preparing...";
            PopupDisplayed = true;
            NewQuestion    = null;

            //-http://cathalscorner.blogspot.co.uk/2009/04/docx-version-1002-released.html

            //The location of where this word document will be stored.
            String newDocumentFileLocation = myFileDirectory + "Documents\\" + this.currentTreasureHunt.HuntName + " QR Codes Sheet.docx";

            //The creation of this new Word Document for the file location supplied
            using (DocX documentOfQRCodes = DocX.Create(newDocumentFileLocation))
            {
                Novacode.Paragraph p = documentOfQRCodes.InsertParagraph(this.currentTreasureHunt.HuntName);

                documentOfQRCodes.InsertParagraph();

                //For every question associated with the current treasure hunt
                using (var currentQuestionQRCode = this.questions.GetEnumerator())
                {
                    while (currentQuestionQRCode.MoveNext())
                    {
                        if (currentQuestionQRCode.Current.URL != null && currentQuestionQRCode.Current.URL != "empty URL")
                        {
                            //Insert into the document the QR associated with the current question
                            documentOfQRCodes.InsertParagraph(currentQuestionQRCode.Current.Question1);
                            documentOfQRCodes.InsertParagraph();
                            Novacode.Paragraph q = documentOfQRCodes.InsertParagraph();

                            string         locationOfImage = myFileDirectory + "QRCodes\\" + CurrentTreasureHunt.HuntId + " " + currentQuestionQRCode.Current.Question1 + ".png";
                            Novacode.Image img             = documentOfQRCodes.AddImage(@locationOfImage);

                            Picture pic1 = img.CreatePicture();
                            q.InsertPicture(pic1, 0);
                            pic1.Width  = 200;
                            pic1.Height = 200;

                            documentOfQRCodes.InsertParagraph();
                        }
                    }
                }

                documentOfQRCodes.Save();
                PopupDisplayed = false;
            }

            Messenger.Default.Send <UpdateViewMessage>(new UpdateViewMessage()
            {
                UpdateViewTo = "PrintViewModel"
            });
            Messenger.Default.Send <PrintMessage>(new PrintMessage()
            {
                FileLocation = newDocumentFileLocation
            });
            Messenger.Default.Send <SelectedHuntMessage>(new SelectedHuntMessage()
            {
                CurrentHunt = this.currentTreasureHunt
            });
        }
Example #6
0
 private void _Create(string file, IEnumerable<OXmlElement> elements)
 {
     using (_document = DocX.Create(file))
     {
         foreach (OXmlElement element in elements)
         {
             switch (element.Type)
             {
                 //case zDocXElementType.BeginParagraph:
                 //    _paragraph = _document.InsertParagraph();
                 //    break;
                 //case zDocXElementType.EndParagraph:
                 //    _paragraph = null;
                 //    break;
                 case OXmlElementType.Paragraph:
                     _paragraph = _document.InsertParagraph();
                     break;
                 case OXmlElementType.Text:
                     AddText(element);
                     break;
                 case OXmlElementType.Line:
                     AddLine();
                     break;
                 case OXmlElementType.Picture:
                     AddPicture(element);
                     break;
             }
         }
         _document.Save();
     }
 }
Example #7
0
 private bool ReplaceCell(Paragraph pg, string code, DirectoryInfo di)
 {
     if (!cellre.IsMatch(code))
     {
         return(false);
     }
     if (di.CellPhone.HasValue())
     {
         var m   = cellre.Match(code);
         var txt = m.Groups["text"].Value;
         if (!txt.HasValue())
         {
             pg.ReplaceText(code, di.CellPhone);
         }
         else
         {
             txt = txt.Replace("_number_", di.CellPhone)
                   .Replace("_first_", di.Person.PreferredName);
             pg.ReplaceText(code, txt);
         }
     }
     else
     {
         pg.ReplaceText(code, "");
     }
     return(true);
 }
Example #8
0
 private bool ReplaceEmail(Paragraph pg, string code, DirectoryInfo di)
 {
     if (!emailre.IsMatch(code))
     {
         return(false);
     }
     if (di.Person.EmailAddress.HasValue())
     {
         var m   = emailre.Match(code);
         var txt = m.Groups["text"].Value;
         if (!txt.HasValue())
         {
             pg.ReplaceText(code, di.Person.EmailAddress);
         }
         else
         {
             txt = txt.Replace("_addr_", di.Person.EmailAddress)
                   .Replace("_first_", di.Person.PreferredName);
             pg.ReplaceText(code, txt);
         }
     }
     else
     {
         pg.ReplaceText(code, "");
     }
     return(true);
 }
Example #9
0
    private BaseConverter createForParagraph( DocX doc, Paragraph paragraph ) {
      var isList = paragraph.IsListItem;
      if( isList ) return createConverterForList( doc, paragraph );

      var type = Type.GetType( "DocXToMarkdown.Converter." + _converters[paragraph.StyleName] );
      return (BaseConverter)Activator.CreateInstance( type, new object[] { doc, paragraph } );
    }
Example #10
0
        private void BuildDocumentIndexStyle(List <DirectoryInfo> list)
        {
            var templatetbl = docx.Tables[0];
            var c           = 0;

            var       templaterow    = templatetbl.Rows[0];
            var       ncols          = templaterow.ColumnCount;
            Row       row            = null;
            Table     tbl            = null;
            Paragraph alphaParagraph = null;

            foreach (var pg in docx.Paragraphs)
            {
                if (pg.Text.Contains("{lastnamestartswith}"))
                {
                    alphaParagraph = pg;
                    break;
                }
            }

            var alphaindex = "@";

            foreach (var m in list)
            {
                if (m.Person.LastName[0] != alphaindex[0])
                {
                    tbl?.RemoveRow(0);
                    var pg = docx.InsertParagraph(alphaParagraph);
                    pg.KeepWithNext();
                    alphaindex = m.Person.LastName.Substring(0, 1);
                    pg.ReplaceText("{lastnamestartswith}", alphaindex);
                    tbl = docx.InsertTable(templatetbl);
                    c   = 0;
                }
                Debug.Assert(tbl != null, "tbl != null");
                if (c == 0) // start a new row
                {
                    row = tbl.InsertRow(templaterow);
                    row.BreakAcrossPages = false;
                    tbl.Rows.Add(row);
                }
                Debug.Assert(row != null, "row != null");
                var cell = row.Cells[c];
                DoCellReplacements(cell, m);
                if (++c == ncols)
                {
                    c = 0; // start a new row
                }
            }
            while (c > 0 && c < ncols && row != null)
            {
                DoEmptyCell(row.Cells[c++]);
            }

            tbl?.RemoveRow(0);                              // remove first row from last table worked on
            docx.RemoveParagraph(alphaParagraph);           // remove the alphaParagraph template
            docx.Tables[0].Remove();                        // remove the template table
            docx.Paragraphs[0].Remove(trackChanges: false); // remove the empty paragraph after the template table
        }
Example #11
0
 public void AddItemWithStartValue(Paragraph paragraph, int start)
 {
     //TODO: Update the numbering
     UpdateNumberingForLevelStartNumber(int.Parse(paragraph.IndentLevel.ToString()), start);
     if (ContainsLevel(start))
         throw new InvalidOperationException("Cannot add a paragraph with a start value if another element already exists in this list with that level.");
     AddItem(paragraph);
 }
Example #12
0
        internal Cell(DocX document, XElement xml)
        {
            this.document = document;
            this.xml = xml;

            XElement properties = xml.Element(XName.Get("tcPr", DocX.w.NamespaceName));

            p = new Paragraph(document, 0, xml.Element(XName.Get("p", DocX.w.NamespaceName)));
        }
Example #13
0
        public virtual Paragraph InsertParagraphBeforeSelf(Paragraph p)
        {
            Xml.AddBeforeSelf(p.Xml);
            XElement newlyInserted = Xml.ElementsBeforeSelf().First();

            p.Xml = newlyInserted;

            return p;
        }
Example #14
0
        public static void CreateTestReport(Patient patient, MedicalTest test, string file_path)
        {
            if (file_path == null)
            {
                return;
            }
            Type test_type = test.GetType();

            using (DocX document = DocX.Create(file_path))
            {
                Novacode.Paragraph header = document.InsertParagraph(
                    //selected_procedure.ProcedureType.First().ToString().ToUpper() + String.Join("", selected_procedure.ProcedureType.Skip(1)).ToLower(),
                    test_type.GetCustomAttribute <DisplayNameAttribute>().DisplayName,
                    false,
                    new Formatting()
                {
                    FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                    Size       = 16D
                }
                    );
                header.Alignment = Alignment.center;
                header.Bold();
                document.InsertParagraph(" ");
                Novacode.Table patient_info = document.AddTable(5, 2);
                patient_info.Rows[0].Cells[0].Paragraphs.First().Append("ФИО пациента").Bold();
                patient_info.Rows[0].Cells[1].Paragraphs.First().Append(patient.LastName + " " + patient.FirstName + " " + patient.Patronym);
                patient_info.Rows[1].Cells[0].Paragraphs.First().Append("Пол").Bold();
                patient_info.Rows[1].Cells[1].Paragraphs.First().Append(patient.Sex == Sex.мужской ? "мужской" : "женский");
                patient_info.Rows[2].Cells[0].Paragraphs.First().Append("Дата рождения").Bold();
                patient_info.Rows[2].Cells[1].Paragraphs.First().Append(patient.Birthdate.ToShortDateString());
                patient_info.Rows[3].Cells[0].Paragraphs.First().Append("Адрес проживания").Bold();
                patient_info.Rows[3].Cells[1].Paragraphs.First().Append(
                    patient.PostIndex + ", " + patient.Country + ", " + patient.Region +
                    ", " + patient.City + ", " + patient.Address
                    );
                patient_info.Rows[4].Cells[0].Paragraphs.First().Append("Номер карты").Bold();
                patient_info.Rows[4].Cells[1].Paragraphs.First().Append(patient.CardNumber.ToString());
                patient_info.Alignment = Alignment.left;
                patient_info.AutoFit   = AutoFit.Window;
                PropertyInfo[] indicators = test_type.GetProperties().Where(x => x.IsDefined(typeof(TestInfo))).ToArray();
                Novacode.Table test_info  = document.AddTable(indicators.Count(), 2);
                int            k          = 0;
                foreach (var indicator in indicators)
                {
                    test_info.Rows[k].Cells[0].Paragraphs.First().Append(indicator.GetCustomAttribute <TestInfo>().DisplayName);
                    object property_value = indicator.GetValue(test);
                    test_info.Rows[k].Cells[1].Paragraphs.First().Append(property_value != null ? property_value.ToString() : "");
                    k++;
                }
                test_info.Alignment = Alignment.left;
                test_info.AutoFit   = AutoFit.Window;
                document.InsertTable(patient_info);
                document.InsertParagraph(" ");
                document.InsertTable(test_info);
                document.Save();
            }
        }
Example #15
0
        private DocX GetDoc()
        {
            // Adjust the path so suit your machine:
            string fileName = @"C:\Users\tyho\Desktop\1.docx";

            // Set up our paragraph contents:
            string headerText     = "Rejection Letter";
            string letterBodyText = DateTime.Now.ToShortDateString();
            string paraTwo        = ""
                                    + "Dear %APPLICANT%" + Environment.NewLine + Environment.NewLine
                                    + "I am writing to thank you for your resume. Unfortunately, your skills and "
                                    + "experience do not match our needs at the present time. We will keep your "
                                    + "resume in our circular file for future reference. Don't call us, "
                                    + "we'll call you. "

                                    + Environment.NewLine + Environment.NewLine
                                    + "Sincerely, "
                                    + Environment.NewLine + Environment.NewLine
                                    + "Jim Smith, Corporate Hiring Manager";

            // Title Formatting:
            var titleFormat = new Formatting();

            titleFormat.FontFamily = new System.Drawing.FontFamily("Arial Black");
            titleFormat.Size       = 18D;
            titleFormat.Position   = 12;

            // Body Formatting
            var paraFormat = new Formatting();

            paraFormat.FontFamily = new System.Drawing.FontFamily("Calibri");
            paraFormat.Size       = 10D;
            titleFormat.Position  = 12;

            // Create the document in memory:
            var doc = DocX.Create(fileName);

            // Insert each prargraph, with appropriate spacing and alignment:
            Novacode.Paragraph title = doc.InsertParagraph(headerText, false, titleFormat);
            title.Alignment = Alignment.center;

            doc.InsertParagraph(Environment.NewLine);
            Novacode.Paragraph letterBody = doc.InsertParagraph(letterBodyText, false, paraFormat);
            letterBody.Alignment = Alignment.both;

            doc.InsertParagraph(Environment.NewLine);
            doc.InsertParagraph(paraTwo, false, paraFormat);

            return(doc);
        }
Example #16
0
        private bool ReplacePic(Paragraph pg, string code, DirectoryInfo di)
        {
            if (!picre.IsMatch(code))
            {
                return(false);
            }
            var m      = picre.Match(code);
            var pic    = m.Groups["pic"].Value;
            var height = m.Groups["height"].Value.ToDouble();
            var width  = m.Groups["width"].Value.ToDouble();

            pg.ReplaceText(code, "");
            AddPicture(pg, width, height, pic == "pic" ? di.ImageId : di.FamImageId);
            return(true);
        }
Example #17
0
        /// <summary>
        /// Adds an item to the list.
        /// </summary>
        /// <param name="paragraph"></param>
        /// <exception cref="InvalidOperationException">
        /// Throws an InvalidOperationException if the item cannot be added to the list.
        /// </exception>
        public void AddItem(Paragraph paragraph)
        {
            if (paragraph.IsListItem)
            {
                var numIdNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "numId");
                var numId = Int32.Parse(numIdNode.Attribute(DocX.w + "val").Value);

                if (CanAddListItem(paragraph))
                {
                    NumId = numId;
                    Items.Add(paragraph);
                }
                else
                    throw new InvalidOperationException("New list items can only be added to this list if they are have the same numId.");
            }
        }
Example #18
0
        /// <summary>
        /// Determine if it is able to add the item to the list
        /// </summary>
        /// <param name="paragraph"></param>
        /// <returns>
        /// Return true if AddItem(...) will succeed with the given paragraph.
        /// </returns>
        public bool CanAddListItem(Paragraph paragraph)
        {
            if (paragraph.IsListItem)
            {
                //var lvlNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "ilvl");
                var numIdNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "numId");
                var numId = Int32.Parse(numIdNode.Attribute(DocX.w + "val").Value);

                //Level = Int32.Parse(lvlNode.Attribute(DocX.w + "val").Value);
                if (NumId == 0 || (numId == NumId && numId > 0))
                {
                    return true;
                }
            }
            return false;
        }
        internal static Paragraph DocumentDescription(this DocX body, string input, Paragraph parent = null)
        {
            if (string.IsNullOrEmpty(input))
                return null;

            Paragraph paragraph = parent ?? body.InsertParagraph();
            paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore + 1;
            paragraph.InsertText(input, false, new Formatting
            {
                FontColor = Color.Black,
                Size = 10,
            });

            body.InsertParagraph();

            return paragraph;
        }
        internal static Paragraph DocumentLeafActivity(this DocX body, string input, Paragraph parent = null)
        {
            if (string.IsNullOrEmpty(input))
                return null;

            Paragraph paragraph = parent ?? body.InsertParagraph();
            paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore;

            paragraph.InsertText(input, false, new Formatting
            {
                FontColor = Color.Green,
                Size = 12,
            });

            body.InsertParagraph();

            return paragraph;
        }
Example #21
0
 private bool ReplacePhone(Paragraph pg, string code, DirectoryInfo di)
 {
     if (!phonere.IsMatch(code))
     {
         return(false);
     }
     if (!di.HomePhone.HasValue() || di.SpouseDoNotPublishPhone == true)
     {
         pg.ReplaceText(code, "");
     }
     else
     {
         var m   = phonere.Match(code);
         var txt = m.Groups["text"].Value;
         pg.ReplaceText(code, txt.HasValue()
             ? txt.Replace("_number_", di.HomePhone)
             : di.HomePhone);
     }
     return(true);
 }
Example #22
0
        private void AddPicture(Paragraph pg, double width, double height, int?imageid)
        {
            const int oversizedpixelsinch = 310;
            const int pixelsinch          = 96;
            var       largewidth          = (oversizedpixelsinch * width).ToInt();
            var       largeheight         = (oversizedpixelsinch * height).ToInt();
            var       widthpixels         = (width * pixelsinch).ToInt();
            var       heightpixels        = (height * pixelsinch).ToInt();

            var img = ImageData.Image.ImageFromId(imageid);

            if (img != null)
            {
                using (var os = img.ResizeToStream(largewidth, largeheight, "pad"))
                {
                    var pic = docx.AddImage(os).CreatePicture(heightpixels, widthpixels);
                    pg.AppendPicture(pic);
                }
            }
        }
Example #23
0
 private bool ReplaceSpouse(Paragraph pg, string code, DirectoryInfo di)
 {
     if (!spousere.IsMatch(code))
     {
         return(false);
     }
     if (di.SpouseName.HasValue())
     {
         var m   = spousere.Match(code);
         var txt = m.Groups["text"].Value;
         pg.ReplaceText(code, txt.HasValue()
             ? txt.Replace("_name_", di.SpouseName)
             : di.SpouseName);
     }
     else
     {
         pg.ReplaceText(code, "");
     }
     return(true);
 }
Example #24
0
 private bool ReplaceKids(Paragraph pg, string code, DirectoryInfo di)
 {
     if (!kidsre.IsMatch(code))
     {
         return(false);
     }
     if (di.Children.HasValue())
     {
         var m   = kidsre.Match(code);
         var txt = m.Groups["text"].Value;
         pg.ReplaceText(code, txt.HasValue()
             ? txt.Replace("_names_", di.Children)
             : di.Children);
     }
     else
     {
         pg.ReplaceText(code, "");
     }
     return(true);
 }
        internal static Paragraph DocumentCompositeActivity(this DocX body, string input, Paragraph parent = null)
        {
            if (string.IsNullOrEmpty(input))
                return null;

            Paragraph paragraph = parent ?? body.InsertParagraph();
            paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore + 1;

            paragraph.InsertText(input, false, new Formatting
            {
                FontColor = Color.Black,
                Size = 16,
                Bold = false,
                Italic = false,
                UnderlineStyle = UnderlineStyle.dash,
                UnderlineColor = Color.Gray
            });

            body.InsertParagraph();

            return paragraph;
        }
Example #26
0
 private bool ReplaceAnniversary(Paragraph pg, string code, DirectoryInfo di)
 {
     if (!anniversaryre.IsMatch(code))
     {
         return(false);
     }
     if (di.Person.WeddingDate.HasValue)
     {
         var m   = anniversaryre.Match(code);
         var txt = m.Groups["text"].Value;
         m = dtfmtre.Match(txt);
         var repl = m.Value;
         var mfmt = m.Groups["fmt"].Value;
         pg.ReplaceText(code, txt.HasValue()
             ? txt.Replace(repl, di.Person.WeddingDate.ToString2(Util.PickFirst(mfmt, "MMM d")))
             : di.Person.WeddingDate.ToString2("MMM d"));
     }
     else
     {
         pg.ReplaceText(code, "");
     }
     return(true);
 }
Example #27
0
 /// <summary>
 /// Insert a Paragraph after this Table, this Paragraph may have come from the same or another document.
 /// </summary>
 /// <param name="p">The Paragraph to insert.</param>
 /// <returns>The Paragraph now associated with this document.</returns>
 /// <example>
 /// Take a Paragraph from document a, and insert it into document b after this Table.
 /// <code>
 /// // Place holder for a Paragraph.
 /// Paragraph p;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"a.docx"))
 /// {
 ///     // Get the first paragraph from this document.
 ///     p = documentA.Paragraphs[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"b.docx"))
 /// {
 ///     // Get the first Table in document b.
 ///     Table t = documentB.Tables[0];
 ///
 ///     // Insert the Paragraph from document a after this Table.
 ///     Paragraph newParagraph = t.InsertParagraphAfterSelf(p);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code> 
 /// </example>
 public override Paragraph InsertParagraphAfterSelf(Paragraph p)
 {
     return base.InsertParagraphAfterSelf(p);
 }
Example #28
0
 /// <summary>
 /// Insert a Paragraph before this Table, this Paragraph may have come from the same or another document.
 /// </summary>
 /// <param name="p">The Paragraph to insert.</param>
 /// <returns>The Paragraph now associated with this document.</returns>
 /// <example>
 /// Take a Paragraph from document a, and insert it into document b before this Table.
 /// <code>
 /// // Place holder for a Paragraph.
 /// Paragraph p;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"a.docx"))
 /// {
 ///     // Get the first paragraph from this document.
 ///     p = documentA.Paragraphs[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"b.docx"))
 /// {
 ///     // Get the first Table in document b.
 ///     Table t = documentB.Tables[0];
 ///
 ///     // Insert the Paragraph from document a before this Table.
 ///     Paragraph newParagraph = t.InsertParagraphBeforeSelf(p);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code> 
 /// </example>
 public override Paragraph InsertParagraphBeforeSelf(Paragraph p)
 {
     return base.InsertParagraphBeforeSelf(p);
 }
        public virtual Paragraph InsertParagraphAfterSelf(Paragraph p)
        {
            Xml.AddAfterSelf(p.Xml);
            XElement newlyInserted = Xml.ElementsAfterSelf().First();

            //Dmitchern
            if (this as Paragraph != null)
            {
                return new Paragraph(Document, newlyInserted, (this as Paragraph).endIndex);
            }
            else
            {
                p.Xml = newlyInserted; //IMPORTANT: I think we have return new paragraph in any case, but I dont know what to put as startIndex parameter into Paragraph constructor
                return p;
            }
        }
Example #30
0
        private bool ReplaceCode(Paragraph pg, string code, DirectoryInfo di)
        {
            if (code.Equal("{altname}"))
            {
                pg.ReplaceText(code, di.Person.AltName);
            }
            else if (code.Equal("{name}"))
            {
                pg.ReplaceText(code, di.Person.Name);
            }
            else if (code.Equal("{name2}"))
            {
                pg.ReplaceText(code, di.Person.Name2);
            }
            else if (code.Equal("{familyname}"))
            {
                pg.ReplaceText(code, di.FamilyName);
            }
            else if (code.Equal("{familytitle}"))
            {
                pg.ReplaceText(code, di.FamilyTitle);
            }
            else if (code.Equal("{lastname}"))
            {
                pg.ReplaceText(code, di.Person.LastName);
            }
            else if (code.Equal("{firstnames}"))
            {
                pg.ReplaceText(code, di.FirstNames);
            }
            else if (code.Equal("{addr}"))
            {
                pg.ReplaceText(code, di.Address);
            }

            else if (ReplaceBday(pg, code, di))
            {
                return(true);
            }
            else if (ReplaceAnniversary(pg, code, di))
            {
                return(true);
            }
            else if (ReplaceEmail(pg, code, di))
            {
                return(true);
            }
            else if (ReplaceSpEmail(pg, code, di))
            {
                return(true);
            }
            else if (ReplacePhone(pg, code, di))
            {
                return(true);
            }
            else if (ReplaceCell(pg, code, di))
            {
                return(true);
            }
            else if (ReplaceSpCell(pg, code, di))
            {
                return(true);
            }
            else if (ReplaceSpouse(pg, code, di))
            {
                return(true);
            }
            else if (ReplaceKids(pg, code, di))
            {
                return(true);
            }
            else if (ReplacePic(pg, code, di))
            {
                return(true);
            }
            else
            {
                return(false);
            }
            return(true);
        }
Example #31
0
        public virtual Paragraph InsertParagraph(string text, bool trackChanges, Formatting formatting)
        {
            XElement newParagraph = new XElement
            (
                XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml)
            );

            if (trackChanges)
                newParagraph = HelperFunctions.CreateEdit(EditType.ins, DateTime.Now, newParagraph);
            Xml.Add(newParagraph);
            var paragraphAdded = new Paragraph(Document, newParagraph, 0);
            if (this is Cell)
            {
                var cell = this as Cell;
                paragraphAdded.PackagePart = cell.mainPart;
            }
            else if (this is DocX)
            {
                paragraphAdded.PackagePart = Document.mainPart;
            }
            else if (this is Footer)
            {
                var f = this as Footer;
                paragraphAdded.mainPart = f.mainPart;
            }
            else if (this is Header)
            {
                var h = this as Header;
                paragraphAdded.mainPart = h.mainPart;
            }
            else
            {
                Console.WriteLine("No idea what we are {0}", this);
                paragraphAdded.PackagePart = Document.mainPart;
            }

            GetParent(paragraphAdded);

            return paragraphAdded;
        }
Example #32
0
        private void GetListItemType(Paragraph p)
        {
            var ilvlNode = p.ParagraphNumberProperties.Descendants().FirstOrDefault(el => el.Name.LocalName == "ilvl");
            var ilvlValue = ilvlNode.Attribute(DocX.w + "val").Value;

            var numIdNode = p.ParagraphNumberProperties.Descendants().FirstOrDefault(el => el.Name.LocalName == "numId");
            var numIdValue = numIdNode.Attribute(DocX.w + "val").Value;

            //find num node in numbering
            var numNodes = Document.numbering.Descendants().Where(n => n.Name.LocalName == "num");
            XElement numNode = numNodes.FirstOrDefault(node => node.Attribute(DocX.w + "numId").Value.Equals(numIdValue));

            if (numNode != null)
            {
               //Get abstractNumId node and its value from numNode
                var abstractNumIdNode = numNode.Descendants().First(n => n.Name.LocalName == "abstractNumId");
                var abstractNumNodeValue = abstractNumIdNode.Attribute(DocX.w + "val").Value;

                var abstractNumNodes = Document.numbering.Descendants().Where(n => n.Name.LocalName == "abstractNum");
                XElement abstractNumNode =
                  abstractNumNodes.FirstOrDefault(node => node.Attribute(DocX.w + "abstractNumId").Value.Equals(abstractNumNodeValue));

                //Find lvl node
                var lvlNodes = abstractNumNode.Descendants().Where(n => n.Name.LocalName == "lvl");
                XElement lvlNode = null;
                foreach (XElement node in lvlNodes)
                {
                    if (node.Attribute(DocX.w + "ilvl").Value.Equals(ilvlValue))
                    {
                        lvlNode = node;
                        break;
                    }
                }

               	var numFmtNode = lvlNode.Descendants().First(n => n.Name.LocalName == "numFmt");
              		p.ListItemType = GetListItemType(numFmtNode.Attribute(DocX.w + "val").Value);
            }
        }
Example #33
0
 /// <summary>
 /// Inserts at TOC into the current document before the provided <see cref="reference"/>
 /// </summary>
 /// <param name="reference">The paragraph to use as reference</param>
 /// <param name="title">The title of the TOC</param>
 /// <param name="switches">Switches to be applied, see: http://officeopenxml.com/WPtableOfContents.php </param>
 /// <param name="headerStyle">Lets you set the style name of the TOC header</param>
 /// <param name="maxIncludeLevel">Lets you specify how many header levels should be included - default is 1-3</param>
 /// <param name="rightTabPos">Lets you override the right tab position - this is not common</param>
 /// <returns>The inserted TableOfContents</returns>
 public TableOfContents InsertTableOfContents(Paragraph reference, string title, TableOfContentsSwitches switches, string headerStyle = null, int maxIncludeLevel = 3, int? rightTabPos = null)
 {
     var toc = TableOfContents.CreateTableOfContents(this, title, switches, headerStyle, maxIncludeLevel, rightTabPos);
     reference.Xml.AddBeforeSelf(toc.Xml);
     return toc;
 }
Example #34
0
        public virtual Paragraph InsertParagraph(Paragraph p)
        {
            #region Styles
            XDocument style_document;

            if (p.styles.Count() > 0)
            {
                Uri style_package_uri = new Uri("/word/styles.xml", UriKind.Relative);
                if (!Document.package.PartExists(style_package_uri))
                {
                    PackagePart style_package = Document.package.CreatePart(style_package_uri, "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", CompressionOption.Maximum);
                    using (TextWriter tw = new StreamWriter(style_package.GetStream()))
                    {
                        style_document = new XDocument
                        (
                            new XDeclaration("1.0", "UTF-8", "yes"),
                            new XElement(XName.Get("styles", DocX.w.NamespaceName))
                        );

                        style_document.Save(tw);
                    }
                }

                PackagePart styles_document = Document.package.GetPart(style_package_uri);
                using (TextReader tr = new StreamReader(styles_document.GetStream()))
                {
                    style_document = XDocument.Load(tr);
                    XElement styles_element = style_document.Element(XName.Get("styles", DocX.w.NamespaceName));

                    var ids = from d in styles_element.Descendants(XName.Get("style", DocX.w.NamespaceName))
                              let a = d.Attribute(XName.Get("styleId", DocX.w.NamespaceName))
                              where a != null
                              select a.Value;

                    foreach (XElement style in p.styles)
                    {
                        // If styles_element does not contain this element, then add it.

                        if (!ids.Contains(style.Attribute(XName.Get("styleId", DocX.w.NamespaceName)).Value))
                            styles_element.Add(style);
                    }
                }

                using (TextWriter tw = new StreamWriter(styles_document.GetStream()))
                    style_document.Save(tw);
            }
            #endregion

            XElement newXElement = new XElement(p.Xml);

            Xml.Add(newXElement);

            int index = 0;
            if (Document.paragraphLookup.Keys.Count() > 0)
            {
                index = Document.paragraphLookup.Last().Key;

                if (Document.paragraphLookup.Last().Value.Text.Length == 0)
                    index++;
                else
                    index += Document.paragraphLookup.Last().Value.Text.Length;
            }

            Paragraph newParagraph = new Paragraph(Document, newXElement, index);
            Document.paragraphLookup.Add(index, newParagraph);

            GetParent(newParagraph);

            return newParagraph;
        }
Example #35
0
 public override Paragraph InsertParagraph(Paragraph p)
 {
     p.PackagePart = mainPart;
     return base.InsertParagraph(p);
 }
Example #36
0
 public override Paragraph InsertParagraph(int index, Paragraph p)
 {
     p.PackagePart = mainPart;
     return base.InsertParagraph(index, p);
 }
Example #37
0
        public static void CreateDynamicsReport(Patient patient, IEnumerable <MedicalTest> test_list, Type test_type, PropertyInfo indicator, string file_path)
        {
            if (file_path == null)
            {
                return;
            }
            else
            {
                var norms = PatientDB.Instance.GetTestNorms(test_type)[indicator.Name];
                using (DocX document = DocX.Create(file_path))
                {
                    Novacode.Paragraph header_test = document.InsertParagraph(
                        test_type.GetCustomAttribute <DisplayNameAttribute>().DisplayName,
                        false,
                        new Formatting()
                    {
                        FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                        Size       = 18D
                    }
                        );
                    header_test.Alignment = Alignment.center;
                    header_test.Bold();
                    Novacode.Paragraph header_indicator = document.InsertParagraph(
                        indicator.GetCustomAttribute <TestInfo>().DisplayName,
                        false,
                        new Formatting()
                    {
                        FontFamily = new System.Drawing.FontFamily("Times New Roman"),
                        Size       = 16D
                    }
                        );
                    header_indicator.Alignment = Alignment.center;
                    header_indicator.Bold();
                    document.InsertParagraph(" ");
                    Novacode.Table patient_info = document.AddTable(5, 2);
                    patient_info.Rows[0].Cells[0].Paragraphs.First().Append("ФИО пациента").Bold();
                    patient_info.Rows[0].Cells[1].Paragraphs.First().Append(patient.LastName + " " + patient.FirstName + " " + patient.Patronym);
                    patient_info.Rows[1].Cells[0].Paragraphs.First().Append("Пол").Bold();
                    patient_info.Rows[1].Cells[1].Paragraphs.First().Append(patient.Sex == Sex.мужской ? "мужской" : "женский");
                    patient_info.Rows[2].Cells[0].Paragraphs.First().Append("Дата рождения").Bold();
                    patient_info.Rows[2].Cells[1].Paragraphs.First().Append(patient.Birthdate.ToShortDateString());
                    patient_info.Rows[3].Cells[0].Paragraphs.First().Append("Адрес проживания").Bold();
                    patient_info.Rows[3].Cells[1].Paragraphs.First().Append(
                        patient.PostIndex + ", " + patient.Country + ", " + patient.Region +
                        ", " + patient.City + ", " + patient.Address
                        );
                    patient_info.Rows[4].Cells[0].Paragraphs.First().Append("Номер карты").Bold();
                    patient_info.Rows[4].Cells[1].Paragraphs.First().Append(patient.CardNumber.ToString());
                    patient_info.Alignment = Alignment.left;
                    patient_info.AutoFit   = AutoFit.Window;
                    Novacode.Table dynamics = document.AddTable(test_list.Count() + 1, 2);
                    dynamics.Rows[0].Cells[0].Paragraphs.First().Append("Дата сдачи анализов").Bold();
                    dynamics.Rows[0].Cells[1].Paragraphs.First().Append("Значение показателя (" + indicator.GetCustomAttribute <TestInfo>().Unity.GetDescription() + ")").Bold();
                    int k = 1;
                    foreach (var test_ in test_list.OrderBy(x => x.Date))
                    {
                        double value_ = (double)indicator.GetValue(test_);
                        dynamics.Rows[k].Cells[0].Paragraphs.First().Append(test_.Date.ToShortDateString());
                        if (value_ >= norms.Min - norms.MinError && value_ <= norms.Max + norms.MaxError)
                        {
                            dynamics.Rows[k].Cells[1].Paragraphs.First().Append(value_.ToString()).Highlight(Highlight.green);
                        }
                        else
                        {
                            dynamics.Rows[k].Cells[1].Paragraphs.First().Append(value_.ToString()).Highlight(Highlight.red);
                        }
                        k++;
                    }
                    dynamics.Alignment = Alignment.left;
                    dynamics.AutoFit   = AutoFit.Window;
                    document.InsertTable(patient_info);
                    document.InsertParagraph(" ");
                    document.InsertTable(dynamics);

                    /*
                     * bitmap_encoder = new PngBitmapEncoder();
                     * using (MemoryStream pic_stream = new MemoryStream())
                     * {
                     *  bitmap_encoder.Frames.Add(BitmapFrame.Create(rtb));
                     *  bitmap_encoder.Save(pic_stream);
                     *  pic_stream.Seek(0, SeekOrigin.Begin);
                     *  document.InsertParagraph(" ");
                     *  Novacode.Picture graph = document.AddImage(pic_stream).CreatePicture();
                     *  graph.SetPictureShape(Novacode.RectangleShapes.rect);
                     *  Novacode.Paragraph graph_paragraph = document.InsertParagraph();
                     *  graph_paragraph.InsertPicture(graph);
                     * }
                     */
                    document.Save();
                }
            }
        }
Example #38
0
 private void ExportWord()
 {
     if (Tables != null)
     {
         var columns = Columns;
         using (Docx.DocX doc = Docx.DocX.Create(FileName))
         {
             //表格的边框样式
             Docx.Border border = new Docx.Border();
             border.Tcbs = Docx.BorderStyle.Tcbs_single;
             int n = 0;
             foreach (TableEntity tableEntity in Tables)
             {
                 string tableId = tableEntity.ID.ToString();
                 //插入表名
                 Docx.Paragraph title = doc.InsertParagraph();
                 title.Append(tableEntity.TableName + "(" + tableEntity.Attr + ")");
                 title.Alignment = Docx.Alignment.center;
                 title.FontSize(15);
                 title.Bold();
                 title.SetLineSpacing(Docx.LineSpacingType.After, 1);
                 title.SetLineSpacing(Docx.LineSpacingType.Before, 1);
                 DataTable fields   = service.GetColumnDataTable(tableId);
                 int       rowCount = (fields == null ? 0 : fields.Rows.Count) + 1;
                 //计算表格多少行,多少列
                 Docx.Table table = doc.InsertTable(rowCount, columns.Count);
                 //先生成列头
                 Docx.Row colRow = table.Rows[0];
                 int      k      = 0;
                 foreach (string colKey in columns.Keys)
                 {
                     Docx.Cell colCell = colRow.Cells[k];
                     colCell.Paragraphs[0].Append(columns[colKey]).Alignment = Docx.Alignment.center;
                     colCell.SetBorder(Docx.TableCellBorderType.Top, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Bottom, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Left, border);
                     colCell.SetBorder(Docx.TableCellBorderType.Right, border);
                     k++;
                 }
                 for (int i = 0; i < fields.Rows.Count; i++)
                 {
                     //一个属性为一行
                     Docx.Row row = table.Rows[i + 1];
                     //循环每列
                     int j = 0;
                     foreach (string key in columns.Keys)
                     {
                         Docx.Cell cell = row.Cells[j];
                         string    text = fields.Rows[i][key].ToString();
                         if (key == requiredKey)
                         {
                             text = text.ToLower() == "true" ? "是" : "";
                         }
                         cell.Paragraphs[0].Append(text).Alignment = Docx.Alignment.center;
                         cell.Paragraphs[0].FontSize(10);
                         cell.SetBorder(Docx.TableCellBorderType.Top, border);
                         cell.SetBorder(Docx.TableCellBorderType.Bottom, border);
                         cell.SetBorder(Docx.TableCellBorderType.Left, border);
                         cell.SetBorder(Docx.TableCellBorderType.Right, border);
                         j++;
                     }
                 }
                 n++;
                 if (OnProgress != null)
                 {
                     OnProgress(this, new ProgressEventArgs()
                     {
                         Max = Tables.Count, Value = n
                     });
                 }
             }
             doc.Save();
         }
     }
 }
Example #39
0
        /// <summary>
        /// Insert a chart in document after paragraph
        /// </summary>
        public void InsertChartAfterParagraph(Chart chart, Paragraph paragraph)
        {
            // Create a new chart part uri.
            String chartPartUriPath = String.Empty;
            Int32 chartIndex = 1;
            do {
                chartPartUriPath = String.Format
                (
                    "/word/charts/chart{0}.xml",
                    chartIndex
                );
                chartIndex++;
            } while (package.PartExists(new Uri(chartPartUriPath, UriKind.Relative)));

            // Create chart part.
            PackagePart chartPackagePart = package.CreatePart(new Uri(chartPartUriPath, UriKind.Relative), "application/vnd.openxmlformats-officedocument.drawingml.chart+xml", CompressionOption.Normal);

            // Create a new chart relationship
            String relID = GetNextFreeRelationshipID();
            PackageRelationship rel = mainPart.CreateRelationship(chartPackagePart.Uri, TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", relID);

            // Save a chart info the chartPackagePart
            using (TextWriter tw = new StreamWriter(chartPackagePart.GetStream(FileMode.Create, FileAccess.Write)))
                chart.Xml.Save(tw);

            // Insert a new chart into a paragraph.
            Paragraph p = paragraph;
            XElement chartElement = new XElement(
                XName.Get("r", DocX.w.NamespaceName),
                new XElement(
                    XName.Get("drawing", DocX.w.NamespaceName),
                    new XElement(
                        XName.Get("inline", DocX.wp.NamespaceName),
                        new XElement(XName.Get("extent", DocX.wp.NamespaceName), new XAttribute("cx", "5486400"), new XAttribute("cy", "3200400")),
                        new XElement(XName.Get("effectExtent", DocX.wp.NamespaceName), new XAttribute("l", "0"), new XAttribute("t", "0"), new XAttribute("r", "19050"), new XAttribute("b", "19050")),
                        new XElement(XName.Get("docPr", DocX.wp.NamespaceName), new XAttribute("id", "1"), new XAttribute("name", "chart")),
                        new XElement(
                            XName.Get("graphic", DocX.a.NamespaceName),
                            new XElement(
                                XName.Get("graphicData", DocX.a.NamespaceName),
                                new XAttribute("uri", DocX.c.NamespaceName),
                                new XElement(
                                    XName.Get("chart", DocX.c.NamespaceName),
                                    new XAttribute(XName.Get("id", DocX.r.NamespaceName), relID)
                                )
                            )
                        )
                    )
               ));
            p.Xml.Add(chartElement);
        }
Example #40
0
 /// <summary>
 /// Insert a Paragraph before this Paragraph, this Paragraph may have come from the same or another document.
 /// </summary>
 /// <param name="p">The Paragraph to insert.</param>
 /// <returns>The Paragraph now associated with this document.</returns>
 /// <example>
 /// Take a Paragraph from document a, and insert it into document b before this Paragraph.
 /// <code>
 /// // Place holder for a Paragraph.
 /// Paragraph p;
 ///
 /// // Load document a.
 /// using (DocX documentA = DocX.Load(@"a.docx"))
 /// {
 ///     // Get the first paragraph from this document.
 ///     p = documentA.Paragraphs[0];
 /// }
 ///
 /// // Load document b.
 /// using (DocX documentB = DocX.Load(@"b.docx"))
 /// {
 ///     // Get the first Paragraph in document b.
 ///     Paragraph p2 = documentB.Paragraphs[0];
 ///
 ///     // Insert the Paragraph from document a before this Paragraph.
 ///     Paragraph newParagraph = p2.InsertParagraphBeforeSelf(p);
 ///
 ///     // Save all changes made to document b.
 ///     documentB.Save();
 /// }// Release this document from memory.
 /// </code> 
 /// </example>
 public override Paragraph InsertParagraphBeforeSelf(Paragraph p)
 {
     Paragraph p2 = base.InsertParagraphBeforeSelf(p);
     p2.PackagePart = mainPart;
     return p2;
 }
Example #41
0
        internal static XElement[] SplitParagraph(Paragraph p, int index)
        {
            // In this case edit dosent really matter, you have a choice.
            Run r = p.GetFirstRunEffectedByEdit(index, EditType.ins);

            XElement[] split;
            XElement before, after;

            if (r.Xml.Parent.Name.LocalName == "ins")
            {
                split = p.SplitEdit(r.Xml.Parent, index, EditType.ins);
                before = new XElement(p.Xml.Name, p.Xml.Attributes(), r.Xml.Parent.ElementsBeforeSelf(), split[0]);
                after = new XElement(p.Xml.Name, p.Xml.Attributes(), r.Xml.Parent.ElementsAfterSelf(), split[1]);
            }
            else if (r.Xml.Parent.Name.LocalName == "del")
            {
                split = p.SplitEdit(r.Xml.Parent, index, EditType.del);

                before = new XElement(p.Xml.Name, p.Xml.Attributes(), r.Xml.Parent.ElementsBeforeSelf(), split[0]);
                after = new XElement(p.Xml.Name, p.Xml.Attributes(), r.Xml.Parent.ElementsAfterSelf(), split[1]);
            }
            else
            {
                split = Run.SplitRun(r, index);

                before = new XElement(p.Xml.Name, p.Xml.Attributes(), r.Xml.ElementsBeforeSelf(), split[0]);
                after = new XElement(p.Xml.Name, p.Xml.Attributes(), split[1], r.Xml.ElementsAfterSelf());
            }

            if (before.Elements().Count() == 0)
                before = null;

            if (after.Elements().Count() == 0)
                after = null;

            return new XElement[] { before, after };
        }
Example #42
0
        public virtual Paragraph InsertParagraph(int index, Paragraph p)
        {
            XElement newXElement = new XElement(p.Xml);
            p.Xml = newXElement;

            Paragraph paragraph = HelperFunctions.GetFirstParagraphEffectedByInsert(Document, index);

            if (paragraph == null)
                Xml.Add(p.Xml);
            else
            {
                XElement[] split = HelperFunctions.SplitParagraph(paragraph, index - paragraph.startIndex);

                paragraph.Xml.ReplaceWith
                (
                    split[0],
                    newXElement,
                    split[1]
                );
            }

            GetParent(p);

            return p;
        }
Example #43
0
        public string LegalServicesdoc(int id)
        {
            string PathStart = Server.MapPath("/Template");

            if (!Directory.Exists(PathStart))
            {
                Directory.CreateDirectory(PathStart);
            }

            string FolderNameByDate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            string path             = PathStart + "/" + FolderNameByDate;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            Nj_Detail obj    = new Nj_Detail();
            var       result = obj.ClientDetail(id);

            string FolderNameByUserName = path + "/" + result.F_Name + result.L_Name;

            if (!Directory.Exists(FolderNameByUserName))
            {
                Directory.CreateDirectory(FolderNameByUserName);
            }
            string openpath    = "/Template/" + FolderNameByDate + "/" + result.F_Name + result.L_Name + "/" + "LegalServices" + ".doc";
            string Filename    = FolderNameByUserName + "/" + "LegalServices" + ".doc";
            var    doc         = DocX.Create(Filename);
            string headerText  = "AGREEMENT TO PROVIDE LEGAL SERVICES";
            string SubHeader   = "In Municipal Court";
            var    titleFormat = new Formatting();

            titleFormat.FontFamily     = new System.Drawing.FontFamily("Times New Roman");
            titleFormat.Size           = 12D;
            titleFormat.Position       = 10;
            titleFormat.UnderlineColor = new System.Drawing.Color();
            Novacode.Paragraph title = doc.InsertParagraph(headerText, false, titleFormat);
            title.Bold();
            title.Alignment = Alignment.center;
            Novacode.Paragraph title1 = doc.InsertParagraph(SubHeader, false, titleFormat);
            title1.Bold();
            title1.Alignment = Alignment.center;
            string paraOne = ""
                             + "    THIS AGREEMENT, dated October 12, 2016 is made between the Client,";
            string paraOne1 = ""
                              + " " + result.F_Name + " " + result.L_Name + "";

            string paraOne2 = ""
                              + ", whose address is ";


            string paraOne3 = ""
                              + result.Address1 + " " + result.ST + " " + result.City + " " + result.ZIP;
            string ParaOne4 = ""
                              + ", referred to as  the “Client” and The Stabile Law Firm, LLC, hereafter referred to as the “Law Firm.”"
                              + Environment.NewLine
                              + "    1. SUBJECT MATTER OF AGREEMENT"
                              + Environment.NewLine
                              + "    a. The “Law Firm” will represent the client in the following matters: Summons "
                              + result.Summons
                              + Environment.NewLine
                              + "    b. This Agreement does not obligate the “Law Firm” to appeal on behalf of the client. If the client wishes to appeal, and the “Law Firm” agrees to represent the client, an additional agreement will be entered into for that purpose."
                              + Environment.NewLine
                              + "    2. LEGAL SERVICES TO BE RENDERED"
                              + Environment.NewLine
                              + "    a. The legal services to be provided include all necessary court appearances, legal research, investigation, correspondence, preparation of legal documents, trial preparation and all related work required to properly represent the client in this matter."
                              + Environment.NewLine
                              + "     b. The above legal services will be performed as needed by the “Law Firm” and without need for consultation with or authorization from the client."
                              + Environment.NewLine
                              + "    3. LEGAL SERVICES NOT COVERED BY THIS AGREEMENT"
                              + Environment.NewLine
                              + "    This agreement requires that the law firm represent the client with respect to the above subject matter only. Any other matters, except those incidental to and necessarily included with the above matter, must be the subject of a separate agreement between the “Law Firm” and client."
                              + Environment.NewLine
                              + "    4. CALCULATION OF LEGAL FEES"
                              + Environment.NewLine
                              + "    Client agrees to pay the law firm a non-refundable flat fee of $";


            string ParaOne5 = ""
                              + result.Payment_Total;

            string ParaOne6 = ""
                              + " plus costs to negotiate a plea.  Costs may include, but are not limited to, the cost of discovery; transcript fees; and expert fees.   If you elect to pursue a trial, the fee for trial preparation will be an additional $1000.00 for DUI and Disorderly Persons matters and $500.00 for a Traffic Matter.  If a motion is filed, an additional fee of $500.00 will be charged."
                              + Environment.NewLine
                              + "    Additionally, if the client fails to appear at any scheduled Court date, the attorney can charge an additional $200.00 appearance fee (unless case is done by affidavit). Additionally, if there is an outstanding balance seven (7) days before the scheduled court appearance, the client authorizes the “Law Firm” to charge the remaining balance to his credit or debit card on file without further notification and/or approval."
                              + Environment.NewLine
                              + "    This agreement is for the summons listed in Paragraph 1.  If the Attorney arrives at court and other summons or complaints are listed on the docket that are not disclosed to Law Firm, an additional fee will be charged for those summons or complaints."
                              + Environment.NewLine
                              + "    5.	CONTRACTUAL RELATIONSHIP"
                              + Environment.NewLine
                              + "    “Law Firm” solely owes a legal duty to the Client regardless if a third party has paid any portion of Client’s fee.  In the event that a third party pays any portion of the aforementioned fee owed by the Client, a contractual financial obligation and relationship is hereby established between the “Law Firm” and third party.  In the event that the client defaults on paragraph 4 of this agreement, said third party agrees to act as a surety with respect to the fees owed by the client.  By entering this agreement, Client affirms that they have given third party adequate notice and the third party has freely and voluntarily acknowledged said surety relationship."
                              + Environment.NewLine
                              + "    6. AUTHORIZATION AND DECISION MAKING"
                              + Environment.NewLine
                              + "    The “Law Firm” is authorized to take all actions which the law firm deems advisable on behalf of the client. The “Law Firm” agrees to notify the client promptly of all significant developments in this matter and to consult with the client with respect to any significant decisions related to those developments."
                              + Environment.NewLine
                              + "    7. CLIENT’S RESPONSIBILITY"
                              + Environment.NewLine
                              + "    The client must fully cooperate with the “Law Firm” in this matter. The client must provide all information relevant to the subject matter of this agreement. Failure of the client to bring documents to court which is critical to a successful outcome may result in an additional fee of $200.00 per additional appearance at the Firm’s discretion. These documents include but are not limited to: driver’s license, vehicle registration, insurance card, driving abstract and restoration documents from the motor vehicle commission."
                              + Environment.NewLine
                              + "    8. NO GUARANTEED RESULT"
                              + Environment.NewLine
                              + "    The “Law Firm” shall act on behalf of the client in a courteous, conscientious and diligent manner at all times to achieve solutions which are reasonable and just for the client. However, the “Law Firm” does not guarantee or predict what the final outcome of this matter will be."
                              + Environment.NewLine
                              + "    9. SUPERVISING COUNSEL"
                              + Environment.NewLine
                              + "    The client understands that the “Law Firm” employs several attorneys and attorney assignment to the client’s case will be made by the “Law Firm”. The client further understands that the “Law Firm”, on occasion, refers cases to other competent attorneys who are more familiar with a given Court and that on those occasions the referred to “Law Firm” will share in the fee paid by the client."
                              + Environment.NewLine
                              + "    10. TERMINATION OF SERVICES"
                              + Environment.NewLine
                              + "    The “Law Firm” may terminate this agreement if the client is in breach of its obligations under this agreement or if the “Law Firm” is otherwise required to do so in accordance with the rules of professional conduct governing attorneys.  Should the client terminate this agreement, and a dispute arises thereon, it is agreed that the “Law Firm” is entitled to minimally receive a fee of $350.00 per hour for time expended on client’s behalf."
                              + Environment.NewLine
                              + "    11. INFORMATION TO BE MADE AVAILABLE TO THE CLIENT"
                              + Environment.NewLine
                              + "    The “Law Firm” agrees to make every effort to inform the client at all times as to the status of the matter and as to the acts which are being taken on behalf of the client. The “Law Firm” will make the file available to the client and when possible will send copies of the material to the client at the client’s expense."
                              + Environment.NewLine
                              + "    Client understands that matters may be resolved expeditiously or may take a long time. Client further understands that attorneys may want to delay their case for tactical reasons and client agrees to be patient and allow the attorneys to do what they believe is the right course of action in getting the most positive result."
                              + Environment.NewLine
                              + "    12. COMPLETE AGREEMENT"
                              + Environment.NewLine
                              + "    This writing includes the entire agreement between the client and the law firm regarding this matter. This agreement can only be modified with another written agreement signed by the client and the law firm. This agreement shall be binding upon both, the client and the law firm and their respective heirs, legal representatives and successors in interest."
                              + Environment.NewLine
                              + "    13. ACKNOWLEDGEMENT OF TERMS"
                              + Environment.NewLine
                              + "    Client hereby acknowledges that this agreement can be delivered to Client via email, fax, or regular mail.  Client further acknowledges that if agreement is delivered to Client via email, Client agrees to the terms as written by opening the email and reading the agreement even if Client does not physically sign the agreement."
                              + Environment.NewLine
                              + "    14. SIGNATURES"
                              + Environment.NewLine
                              + "    Both the client and the “Law Firm” have read and agreed to this agreement. The “Law Firm” has provided the client with answers to any questions and has further explained this agreement to the complete satisfaction of the client. The client has also been given a copy of this agreement."
                              + Environment.NewLine + Environment.NewLine
                              + "The Stabile Law Firm, LLC"
                              + Environment.NewLine
                              + "____________________________________       ____________________________________  For: Stabile Law Firm, LLC." + "            " + "                " + "                ";
            string ParaOne7 = ""
                              + result.F_Name + " " + result.L_Name
                              + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine;

            title.Alignment = Alignment.center;
            string paratwo = ""
                             + Environment.NewLine
                             + "I ";

            string paratwo1 = ""
                              + result.F_Name + " " + result.L_Name;

            string paratwo2 = ""
                              + ", having retained the services of the Stabile Law Firm, LLC., (hereinafter "
                              + "referred to as the “Law Firm” ) in connection with matter(s) pending in ";

            string paratwo3 = ""
                              + result.Court_Name;

            string paratwo4 = ""
                              + " Court(s), hereby agree to comply with the following:"
                              + Environment.NewLine
                              + "1.      I must notify the “Law Firm” as soon as I receive a court notice.  Also, I must call to"
                              + " confirm court date two (2) days prior to date. If my phone number, email address or address changes, I must notify the firm and the court immediately."
                              + Environment.NewLine
                              + "2.      I must arrive on time to Court and inquire with Court staff as to check-in procedure (unless case is being handled by affidavit). I understand that the attorney’s may have other courts and may be delayed on arrival to Court.  I should, if asked by Court personnel or judge, indicate that I am pleading Not Guilty and that I am represented by an attorney."
                              + Environment.NewLine
                              + "3.      I must bring at the very least $200 to Court for possible fines."
                              + Environment.NewLine
                              + "4.      If I am charged with a Driving While Suspended, I must contact the Motor Vehicle Commission at 609-292-7500 and take all necessary steps to restore my license. I must bring proof in writing from the Motor Vehicle Commission that I am restored and/or in good standing regarding surcharges."
                              + Environment.NewLine
                              + "5.      If I am charged with any offense pertaining to Driver’s License, Registration and/or Insurance, I must bring original documents to Court"
                              + Environment.NewLine
                              + "6.      I acknowledge that if I fail to appear at a scheduled Court date, the Law Firm will charge me an additional appearance fee of $200.00 unless case is done by affidavit."
                              + Environment.NewLine + Environment.NewLine
                              + "Dated:   " + DateTime.Now.ToShortDateString() + "    " + "    " + "    " + "    " + "    " + "          " + "______________________________" + "    " + "    " + "                            " + ".                                              " + "                    " + "               ";

            string paratwo5 = ""
                              + result.F_Name + " " + result.L_Name;

            var paraFormat = new Formatting();

            paraFormat.FontFamily = new System.Drawing.FontFamily("Times New Roman");
            paraFormat.Size       = 12D;
            titleFormat.Position  = 6;
            doc.InsertParagraph(Environment.NewLine);
            var p = doc.InsertParagraph("", false, paraFormat);

            p.Append(paraOne).FontSize(12D).Append(paraOne1).Bold().FontSize(12D).Append(paraOne2).FontSize(12D).Append(paraOne3).FontSize(12D).Bold().Append(ParaOne4).FontSize(12D).Append(ParaOne5).FontSize(12D).Bold()
            .Append(ParaOne6).FontSize(12D).Append(ParaOne7).FontSize(12D).Bold();
            string ChildHeader = "CLIENT RESPONSIBILITIES AGREEMENT";

            Novacode.Paragraph title2 = doc.InsertParagraph(ChildHeader, false, titleFormat);
            title2.Bold();
            title2.Alignment = Alignment.center;
            var pp = doc.InsertParagraph("", false, paraFormat);

            pp.Append(paratwo).FontSize(12D).Append(paratwo1).FontSize(12D).Bold().Append(paratwo2).FontSize(12D).Append(paratwo3).FontSize(12D).Bold().Append(paratwo4).FontSize(12D).Append(paratwo5).FontSize(12D).Bold();
            pp.SetLineSpacing(LineSpacingType.Line, 1.3f);
            p.SetLineSpacing(LineSpacingType.Line, 1.3f);
            doc.Save();
            obj.ClientCertificateFiles(id, openpath);
            return(openpath);
        }
Example #44
0
        public virtual Paragraph InsertParagraph(int index, string text, bool trackChanges, Formatting formatting)
        {
            Paragraph newParagraph = new Paragraph(Document, new XElement(DocX.w + "p"), index);
            newParagraph.InsertText(0, text, trackChanges, formatting);

            Paragraph firstPar = HelperFunctions.GetFirstParagraphEffectedByInsert(Document, index);

            if (firstPar != null)
            {
                XElement[] splitParagraph = HelperFunctions.SplitParagraph(firstPar, index - firstPar.startIndex);

                firstPar.Xml.ReplaceWith
                (
                    splitParagraph[0],
                    newParagraph.Xml,
                    splitParagraph[1]
                );
            }

            else
                Xml.Add(newParagraph);

            GetParent(newParagraph);

            return newParagraph;
        }
Example #45
0
        public string CardAuthorizationdoc(int id)
        {
            string PathStart = Server.MapPath("/Template");

            if (!Directory.Exists(PathStart))
            {
                Directory.CreateDirectory(PathStart);
            }

            string FolderNameByDate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            string path             = PathStart + "/" + FolderNameByDate;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            Nj_Detail obj    = new Nj_Detail();
            var       result = obj.ClientDetail(id);

            string FolderNameByUserName = path + "/" + result.F_Name + result.L_Name;

            if (!Directory.Exists(FolderNameByUserName))
            {
                Directory.CreateDirectory(FolderNameByUserName);
            }


            string openpath = "/Template/" + FolderNameByDate + "/" + result.F_Name + result.L_Name + "/" + "CardAuthorization" + ".doc";
            string Filename = FolderNameByUserName + "/" + "CardAuthorization" + ".doc";
            var    doc      = DocX.Create(Filename);

            string headerText  = "Credit Card Authorization";
            var    titleFormat = new Formatting();

            titleFormat.FontFamily     = new System.Drawing.FontFamily("Arial Black");
            titleFormat.Size           = 20D;
            titleFormat.Position       = 12;
            titleFormat.UnderlineColor = new System.Drawing.Color();
            Novacode.Paragraph title = doc.InsertParagraph(headerText, false, titleFormat);
            title.Alignment = Alignment.center;

            string paraOne = ""
                             + "I  ,";

            string ParaOne1 = ""
                              + result.F_Name + " " + result.L_Name;

            string ParaOne2 = ""
                              + ", hereby authorize The Law "
                              + Environment.NewLine
                              + "Firm, LLC. to charge my Visa, MasterCard, or , "
                              + Environment.NewLine
                              + "American Express, card ";

            string ParaOne3 = ""
                              + result.Payment_Cardno
                              + Environment.NewLine;

            string ParaOne4 = ""
                              + " with expiration date of ";

            string ParaOne5 = ""
                              + result.Payment_Card_ExpDate;

            string ParaOne6 = ""
                              + ", the amount of ";

            string ParaOne7 = ""
                              + "$" + result.Payment_Total + Environment.NewLine
                              + ", on " + DateTime.Now.ToString("MMMM") + " " + DateTime.Now.Day.ToString() + "," + DateTime.Now.Year.ToString() + "," //December 23, 2016,
            ;

            string ParaOne8 = ""
                              + "for the services rendered on " + Environment.NewLine + " or to be rendered in the"
                              + " matter of ";

            string ParaOne9 = ""
                              + result.Summons;

            string ParaOne10 = ""
                               + "."
                               + Environment.NewLine + Environment.NewLine
                               + "                                                          ____________________________" + "     " + "    " + "    " + "    "
                               + "   " + "    " + "    " + "    "
                               + "." + "                             " + "                                      ";

            string ParaOne11 = ""
                               + result.F_Name + " " + result.L_Name;

            var paraFormat = new Formatting();

            paraFormat.FontFamily = new System.Drawing.FontFamily("Times New Roman");
            paraFormat.Size       = 20D;
            titleFormat.Position  = 12;
            doc.InsertParagraph(Environment.NewLine);
            doc.InsertParagraph(Environment.NewLine);

            var p = doc.InsertParagraph("", false, paraFormat);

            p.Append(paraOne).FontSize(19D).Append(ParaOne1).Bold().FontSize(19D).Append(ParaOne2).FontSize(19D).Append(ParaOne3).FontSize(19D).Bold().Append(ParaOne4).FontSize(19D).Append(ParaOne5).FontSize(19D).Bold().Append(ParaOne6).FontSize(19D).Append(ParaOne7).FontSize(19D).Bold().Append(ParaOne8).FontSize(19D).Append(ParaOne9).FontSize(19D).Bold().Append(ParaOne10).FontSize(15D).Append(ParaOne11).FontSize(19D).Bold();

            doc.Save();
            obj.ClientCertificateFiles(id, openpath);
            return(openpath);
        }
Example #46
0
        /// <summary>
        /// Removes paragraph
        /// </summary>
        /// <param name="p">Paragraph to remove</param>
        /// <returns>True if removed</returns>
        public bool RemoveParagraph(Paragraph p)
        {
            foreach (var paragraph in Xml.Descendants(DocX.w + "p"))
            {
                if (paragraph.Equals(p.Xml))
                {
                    paragraph.Remove();
                    return true;
                }
            }

            return false;
        }
Example #47
0
        public string GenrateCheckScript(int id)
        {
            string PathStart = Server.MapPath("/Template");

            if (!Directory.Exists(PathStart))
            {
                Directory.CreateDirectory(PathStart);
            }

            string FolderNameByDate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            string path             = PathStart + "/" + FolderNameByDate;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            Nj_Detail obj    = new Nj_Detail();
            var       result = obj.ClientDetail(id);

            string FolderNameByUserName = path + "/" + result.F_Name + result.L_Name;

            if (!Directory.Exists(FolderNameByUserName))
            {
                Directory.CreateDirectory(FolderNameByUserName);
            }

            string openpath = "/Template/" + FolderNameByDate + "/" + result.F_Name + result.L_Name + "/" + "CheckReceipt" + ".doc";
            string Filename = FolderNameByUserName + "/" + "CheckReceipt" + ".doc";
            var    doc      = DocX.Create(Filename);

            string headerText  = "Check Receipt";
            var    titleFormat = new Formatting();

            titleFormat.FontFamily     = new System.Drawing.FontFamily("Arial Black");
            titleFormat.Size           = 20D;
            titleFormat.Position       = 12;
            titleFormat.UnderlineColor = new System.Drawing.Color();

            Novacode.Paragraph title = doc.InsertParagraph(headerText, false, titleFormat);
            title.Alignment = Alignment.center;

            string paraOne = ""
                             + "I  ,";

            string paraOne1 = ""
                              + result.F_Name + " " + result.L_Name;

            string paraOne2 = ""
                              + ", have given the Stabile Law"
                              + Environment.NewLine
                              + "Firm, payment in the amount of, "
                              + "$";

            string paraOne3 = ""
                              + result.Payment_Paid
                              + Environment.NewLine;

            string paraOne4 = ""
                              + " , in cash on ";

            string paraOne5 = ""
                              + DateTime.Now.ToString("MMMM") + " " + DateTime.Now.Day.ToString() + "," + DateTime.Now.Year.ToString() + ",";


            string paraOne6 = ""
                              + "for the services" + Environment.NewLine + " rendered on or to be rendered in the  matter"
                              + Environment.NewLine
                              + " of  ";

            string paraOne7 = ""
                              + result.Summons
                              + Environment.NewLine + Environment.NewLine;

            string paraOne8 = ""
                              + "  The balance remaining is ";

            string paraOne9 = ""
                              + result.Payment_Balance + ""
                              + Environment.NewLine + Environment.NewLine;
            string paraOne10 = ""
                               + "                            " + "                                                ______________________                 "
                               + ".                                                                               ";
            string paraOne11 = ""
                               + result.F_Name + " " + result.L_Name;

            var paraFormat = new Formatting();

            paraFormat.FontFamily = new System.Drawing.FontFamily("Times New Roman");
            paraFormat.Size       = 20D;
            titleFormat.Position  = 12;
            doc.InsertParagraph(Environment.NewLine);
            doc.InsertParagraph(Environment.NewLine);

            var p = doc.InsertParagraph("", false, paraFormat);

            p.Append(paraOne).FontSize(19D).Append(paraOne1).Bold().FontSize(19D).Append(paraOne2).FontSize(19D).Append(paraOne3).FontSize(19D).Bold().Append(paraOne4).FontSize(19D).Append(paraOne5).FontSize(19D).Bold().Append(paraOne6).FontSize(19D).Append(paraOne7).FontSize(19D).Bold().Append(paraOne8).FontSize(19D).Append(paraOne9).FontSize(19D).Bold().Append(paraOne10).FontSize(15D).Append(paraOne11).FontSize(19D).Bold();

            //doc.InsertParagraph(paraOne, false, paraFormat);
            doc.Save();
            obj.ClientCertificateFiles(id, openpath);
            return(openpath);
        }
Example #48
0
        private void GetParent(Paragraph newParagraph)
        {
            var containerType = GetType();

            switch (containerType.Name)
            {

                case "Body":
                    newParagraph.ParentContainer = ContainerType.Body;
                    break;
                case "Table":
                    newParagraph.ParentContainer = ContainerType.Table;
                    break;
                case "TOC":
                    newParagraph.ParentContainer = ContainerType.TOC;
                    break;
                case "Section":
                    newParagraph.ParentContainer = ContainerType.Section;
                    break;
                case "Cell":
                    newParagraph.ParentContainer = ContainerType.Cell;
                    break;
                case "Header":
                    newParagraph.ParentContainer = ContainerType.Header;
                    break;
                case "Footer":
                    newParagraph.ParentContainer = ContainerType.Footer;
                    break;
                case "Paragraph":
                    newParagraph.ParentContainer = ContainerType.Paragraph;
                    break;
            }
        }
Example #49
0
 public Header4( DocX d, Paragraph p ) : base( d, p )  { }
        public virtual Paragraph InsertParagraphBeforeSelf(string text, bool trackChanges, Formatting formatting)
        {
            XElement newParagraph = new XElement
            (
                XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml)
            );

            if (trackChanges)
                newParagraph = Paragraph.CreateEdit(EditType.ins, DateTime.Now, newParagraph);

            Xml.AddBeforeSelf(newParagraph);
            XElement newlyInserted = Xml.ElementsBeforeSelf().Last();

            Paragraph p = new Paragraph(Document, newlyInserted, -1);

            return p;
        }
Example #51
-1
 private bool ReplaceSpEmail(Paragraph pg, string code, DirectoryInfo di)
 {
     if (!spemailre.IsMatch(code))
     {
         return(false);
     }
     if (di.SpouseEmail.HasValue())
     {
         var m   = spemailre.Match(code);
         var txt = m.Groups["text"].Value;
         if (!txt.HasValue())
         {
             pg.ReplaceText(code, di.SpouseEmail);
         }
         else
         {
             txt = txt.Replace("_addr_", di.SpouseEmail)
                   .Replace("_first_", di.SpouseFirst);
             pg.ReplaceText(code, txt);
         }
     }
     else
     {
         pg.ReplaceText(code, "");
     }
     return(true);
 }