示例#1
0
        public void ExportPageMargins(SaveFormat saveFormat)
        {
            Document doc = new Document(MyDir + "HtmlSaveOptions.ExportPageMargins.docx");

            Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions
            {
                SaveFormat        = saveFormat,
                ExportPageMargins = true
            };

            switch (saveFormat)
            {
            case SaveFormat.Html:
                doc.Save(MyDir + "ExportPageMargins.html", htmlSaveOptions);
                break;

            case SaveFormat.Mhtml:
                doc.Save(MyDir + "ExportPageMargins.Mhtml", htmlSaveOptions);
                break;

            case SaveFormat.Epub:
                doc.Save(MyDir + "ExportPageMargins.Epub", htmlSaveOptions);     //There is draw images bug with epub. Need write to NSezganov
                break;
            }
        }
            /// <summary>
            /// Creates new SpanVisitor instance.
            /// </summary>
            /// <param name="doc">
            /// Is document which we should parse.
            /// </param>
            public SpanVisitor(Document doc)
            {
                mWordTables = doc.GetChildNodes(NodeType.Table, true);

                // We will parse HTML to determine the rowspan and colspan of each cell.
                MemoryStream htmlStream = new MemoryStream();

                Aspose.Words.Saving.HtmlSaveOptions options = new Aspose.Words.Saving.HtmlSaveOptions
                {
                    ImagesFolder = Path.GetTempPath()
                };

                doc.Save(htmlStream, options);

                // Load HTML into the XML document.
                XmlDocument xmlDoc = new XmlDocument();

                htmlStream.Position = 0;
                xmlDoc.Load(htmlStream);

                // Get collection of tables in the HTML document.
                XmlNodeList tables = xmlDoc.DocumentElement.SelectNodes("// Table");

                foreach (XmlNode table in tables)
                {
                    TableInfo tableInf = new TableInfo();
                    // Get collection of rows in the table.
                    XmlNodeList rows = table.SelectNodes("tr");

                    foreach (XmlNode row in rows)
                    {
                        RowInfo rowInf = new RowInfo();
                        // Get collection of cells.
                        XmlNodeList cells = row.SelectNodes("td");

                        foreach (XmlNode cell in cells)
                        {
                            // Determine row span and colspan of the current cell.
                            XmlAttribute colSpanAttr = cell.Attributes["colspan"];
                            XmlAttribute rowSpanAttr = cell.Attributes["rowspan"];

                            int colSpan = colSpanAttr == null ? 0 : int.Parse(colSpanAttr.Value);
                            int rowSpan = rowSpanAttr == null ? 0 : int.Parse(rowSpanAttr.Value);

                            CellInfo cellInf = new CellInfo(colSpan, rowSpan);
                            rowInf.Cells.Add(cellInf);
                        }

                        tableInf.Rows.Add(rowInf);
                    }

                    mTables.Add(tableInf);
                }
            }
示例#3
0
        public void RoundtripInformationDefaulValue()
        {
            //Assert that default value is true for HTML and false for MHTML and EPUB.
            Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);
            Assert.AreEqual(true, saveOptions.ExportRoundtripInformation);

            saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Mhtml);
            Assert.AreEqual(false, saveOptions.ExportRoundtripInformation);

            saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Epub);
            Assert.AreEqual(false, saveOptions.ExportRoundtripInformation);
        }
示例#4
0
        public void ExportUrlForLinkedImage(bool export)
        {
            Document doc = new Document(MyDir + "ExportUrlForLinkedImage.docx");

            Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
            saveOptions.ExportOriginalUrlForLinkedImages = export;

            doc.Save(MyDir + @"\Artifacts\ExportUrlForLinkedImage.html", saveOptions);

            String[] dirFiles = Directory.GetFiles(MyDir + @"\Artifacts\", "ExportUrlForLinkedImage.001.png", SearchOption.AllDirectories);

            if (dirFiles.Length == 0)
            {
                DocumentHelper.FindTextInFile(MyDir + @"\Artifacts\ExportUrlForLinkedImage.html", "<img src=\"http://www.aspose.com/images/aspose-logo.gif\"");
            }
            else
            {
                DocumentHelper.FindTextInFile(MyDir + @"\Artifacts\ExportUrlForLinkedImage.html", "<img src=\"ExportUrlForLinkedImage.001.png\"");
            }
        }
        public void ExportUrlForLinkedImage(bool export)
        {
            Document doc = new Document(MyDir + "ExportUrlForLinkedImage.docx");

            Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
            saveOptions.ExportOriginalUrlForLinkedImages = export;

            doc.Save(MyDir + @"\Artifacts\ExportUrlForLinkedImage.html", saveOptions);

            String[] dirFiles = Directory.GetFiles(MyDir + @"\Artifacts\", "ExportUrlForLinkedImage.001.png", SearchOption.AllDirectories);

            if (dirFiles.Length == 0)
            {
                DocumentHelper.FindTextInFile(MyDir + @"\Artifacts\ExportUrlForLinkedImage.html", "<img src=\"http://www.aspose.com/images/aspose-logo.gif\"");
            }
            else
            {
                DocumentHelper.FindTextInFile(MyDir + @"\Artifacts\ExportUrlForLinkedImage.html", "<img src=\"ExportUrlForLinkedImage.001.png\"");
            }
        }
示例#6
0
        public void ExportRoundtripInformation(bool valueHtml)
        {
            Document doc = new Document(MyDir + "HtmlSaveOptions.ExportPageMargins.docx");

            Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
            saveOptions.ExportRoundtripInformation = valueHtml;

            doc.Save(MyDir + @"\Artifacts\HtmlSaveOptions.RoundtripInformation.html");

            if (valueHtml)
            {
                this.CompareFiles(
                    MyDir + @"\Golds\HtmlSaveOptions.WithRoundtripInformation.html",
                    MyDir + @"\Artifacts\HtmlSaveOptions.RoundtripInformation.html");
            }
            else
            {
                this.CompareFiles(
                    MyDir + @"\Golds\HtmlSaveOptions.WithoutRoundtripInformation.html",
                    MyDir + @"\Artifacts\HtmlSaveOptions.RoundtripInformation.html");
            }
        }
        public void ExportRoundtripInformation(bool valueHtml)
        {
            Document doc = new Document(MyDir + "HtmlSaveOptions.ExportPageMargins.docx");

            Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
            saveOptions.ExportRoundtripInformation = valueHtml;

            doc.Save(MyDir + @"\Artifacts\HtmlSaveOptions.RoundtripInformation.html");

            if (valueHtml)
            {
                this.CompareFiles(
                    MyDir + @"\Golds\HtmlSaveOptions.WithRoundtripInformation.html",
                    MyDir + @"\Artifacts\HtmlSaveOptions.RoundtripInformation.html");
            }
            else
            {
                this.CompareFiles(
                    MyDir + @"\Golds\HtmlSaveOptions.WithoutRoundtripInformation.html",
                    MyDir + @"\Artifacts\HtmlSaveOptions.RoundtripInformation.html");
            }
        }
        public void ExportPageMargins(SaveFormat saveFormat)
        {
            Document doc = new Document(MyDir + "HtmlSaveOptions.ExportPageMargins.docx");

            Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions
            {
                SaveFormat = saveFormat, 
                ExportPageMargins = true
            };

            switch (saveFormat)
            {
                case SaveFormat.Html:
                    doc.Save(MyDir + "ExportPageMargins.html", htmlSaveOptions);
                    break;
                case SaveFormat.Mhtml:
                    doc.Save(MyDir + "ExportPageMargins.Mhtml", htmlSaveOptions);
                    break;
                case SaveFormat.Epub:
                    doc.Save(MyDir + "ExportPageMargins.Epub", htmlSaveOptions); //There is draw images bug with epub. Need write to NSezganov
                    break;
            }
        }
        public void RoundtripInformationDefaulValue()
        {
            //Assert that default value is true for HTML and false for MHTML and EPUB.
            Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);
            Assert.AreEqual(true, saveOptions.ExportRoundtripInformation);

            saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Mhtml);
            Assert.AreEqual(false, saveOptions.ExportRoundtripInformation);

            saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Epub);
            Assert.AreEqual(false, saveOptions.ExportRoundtripInformation);
        }