Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Feb 25, 2014 11:50 am

Hi

We are looking to replace using word automation in our WPF client application.

Are you able to tell me if the following is supported by your product?

Open a word document template (.dotx) and then be able to do any of the following

replace bookmarks with text
delete bookmarks
add watermarks
select a content control (by Tag) with an inline shape then delete the inline shape and add a new inlineshape linked picture in its place.
Locate a particular bit of text and change the formatting (bold,underline,Italic)
Insert HTML

then save as document.

And be able to print to different printer trays (document.PageSetup.OtherPagesTray and document.PageSetup.FirstPageTray)

Thanks very much

crazyman1979
 
Posts: 1
Joined: Tue Feb 25, 2014 11:47 am

Wed Feb 26, 2014 7:20 am

Hello,

Thank you for considering our product.
Our Spire.Doc can meet all your requirements but the one (select a content control (by Tag) with an inline shape then delete the inline shape and add a new inlineshape linked picture in its place.). We have added it to our schedule. We will tell you when it is supported in the future.

You could refer to the following online article and sample code to test these features. Welcome to evaluate Spire.Doc Pack Version:5.0 (http://www.e-iceblue.com/Download/downl ... t-now.html)

Replacing the text of bookmark:
http://www.e-iceblue.com/Knowledgebase/ ... -Code.html

Removing bookmarks:
http://www.e-iceblue.com/Knowledgebase/ ... B.NET.html

Adding watermarks:
http://www.e-iceblue.com/Knowledgebase/ ... -Word.html

Formatting a particular text:
Sample code:
Code: Select all
            Spire.Doc.Documents.Paragraph paragraph = document.Sections[0].Paragraphs[0];
            Spire.Doc.Documents. TextSelection selection = document.FindString(paragraph, "Spire.Doc for .NET", true, true);
            Spire.Doc.Fields.TextRange range = selection.GetAsOneRange();
            range.CharacterFormat.TextColor =System.Drawing. Color.GreenYellow;
            range.CharacterFormat.Bold = true;
            range.CharacterFormat.UnderlineStyle = UnderlineStyle.Single;
            range.CharacterFormat.Italic = true;

Inserting HTML:
Sample code:
Code: Select all
Paragraph paragraph = document.Sections[0].AddParagraph();
paragraph.AppendHTML(string html);


Please don't hesitate to contact us if you need any help.

Best wishes and have a nice day,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 30, 2014 7:35 am

Hello,

Thanks for your waiting.
Our Spire.Doc has supported to get content controls.
Please download and test Spire.Doc Pack(hot fix) Version:5.2.65(http://www.e-iceblue.com/downloads/hot_ ... 5.2.65.zip).
Share sample code:
Code: Select all
  public void Bug_727()
        {
            String inputFile = @"..\..\..\..\DOCTestData\Bug_727.docx";
            using (Document document = new Document(inputFile))
            {

                StructureTags structureTags = GetAllTags(document);
                List<StructureDocumentTagInline> tagInlines = structureTags.tagInlines;

                string alias = tagInlines[0].SDTProperties.Alias;
                decimal id = tagInlines[0].SDTProperties.Id;
                string tag = tagInlines[0].SDTProperties.Tag;

                List<StructureDocumentTag> tags = structureTags.tags;

                alias = tags[0].SDTProperties.Alias;
                id = tags[0].SDTProperties.Id;
                tag = tags[0].SDTProperties.Tag;
                int count = structureTags.SDTCell.Count+structureTags.tagInlines.Count+structureTags.tags.Count;
                Assert.AreEqual(count, 16);
            }
        }

        static StructureTags GetAllTags(Document document)
        {
            StructureTags structureTags = new StructureTags();
            foreach (Section section in document.Sections)
            {
                foreach (DocumentObject obj in section.Body.ChildObjects)
                {
                    if (obj.DocumentObjectType == DocumentObjectType.Paragraph)
                    {
                        foreach (DocumentObject pobj in (obj as Paragraph).ChildObjects)
                        {
                            if (pobj.DocumentObjectType == DocumentObjectType.StructureDocumentTagInline)
                            {
                                structureTags.tagInlines.Add(pobj as StructureDocumentTagInline);
                            }
                        }
                    }
                    else if (obj.DocumentObjectType == DocumentObjectType.Table)
                    {
                        foreach (TableRow row in (obj as Table).Rows)
                        {
                            foreach (TableCell cell in row.Cells)
                            {

                                if (cell is StructureDocumentTagCell)
                                {
                                    structureTags.SDTCell.Add(cell as StructureDocumentTagCell);
                                }

                                foreach (DocumentObject cellChild in cell.ChildObjects)
                                {
                                    if (cellChild.DocumentObjectType == DocumentObjectType.StructureDocumentTag)
                                    {
                                        structureTags.tags.Add(cellChild as StructureDocumentTag);
                                    }
                                    else if (cellChild.DocumentObjectType == DocumentObjectType.Paragraph)
                                    {
                                        foreach (DocumentObject pobj in (cellChild as Paragraph).ChildObjects)
                                        {
                                            if (pobj.DocumentObjectType == DocumentObjectType.StructureDocumentTagInline)
                                            {
                                                structureTags.tagInlines.Add(pobj as StructureDocumentTagInline);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return structureTags;
        }
        public class StructureTags
        {
            List<StructureDocumentTagInline> m_tagInlines;
            public List<StructureDocumentTagInline> tagInlines
            {
                get
                {
                    if (m_tagInlines == null)
                        m_tagInlines = new List<StructureDocumentTagInline>();
                    return m_tagInlines;
                }
                set
                {
                    m_tagInlines = value;
                }
            }
            List<StructureDocumentTag> m_tags;
            public List<StructureDocumentTag> tags
            {
                get
                {
                    if (m_tags == null)
                        m_tags = new List<StructureDocumentTag>();
                    return m_tags;
                }
            }

            List<StructureDocumentTagCell> m_sdtCell;
            public List<StructureDocumentTagCell> SDTCell
            {
                get
                {
                    if (m_sdtCell == null)
                        m_sdtCell = new List<StructureDocumentTagCell>();
                    return m_sdtCell;
                }
            }
        }
   


Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc