Exemplo n.º 1
0
        public void ExportIntoMarkdownWithTableContentAlignment()
        {
            //ExStart:ExportIntoMarkdownWithTableContentAlignment
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertCell();
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            builder.Write("Cell1");
            builder.InsertCell();
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
            builder.Write("Cell2");

            // Makes all paragraphs inside the table to be aligned.
            MarkdownSaveOptions saveOptions = new MarkdownSaveOptions
            {
                TableContentAlignment = TableContentAlignment.Left
            };

            doc.Save(ArtifactsDir + "WorkingWithMarkdownSaveOptions.LeftTableContentAlignment.md", saveOptions);

            saveOptions.TableContentAlignment = TableContentAlignment.Right;
            doc.Save(ArtifactsDir + "WorkingWithMarkdownSaveOptions.RightTableContentAlignment.md", saveOptions);

            saveOptions.TableContentAlignment = TableContentAlignment.Center;
            doc.Save(ArtifactsDir + "WorkingWithMarkdownSaveOptions.CenterTableContentAlignment.md", saveOptions);

            // The alignment in this case will be taken from the first paragraph in corresponding table column.
            saveOptions.TableContentAlignment = TableContentAlignment.Auto;
            doc.Save(ArtifactsDir + "WorkingWithMarkdownSaveOptions.AutoTableContentAlignment.md", saveOptions);
            //ExEnd:ExportIntoMarkdownWithTableContentAlignment
        }
Exemplo n.º 2
0
        private static void SpecifySaveOptionsAndSaveAsMD(string dataDir)
        {
            DocumentBuilder builder = new DocumentBuilder();

            builder.Writeln("Some text!");

            // specify MarkDownSaveOptions
            MarkdownSaveOptions saveOptions = (MarkdownSaveOptions)SaveOptions.CreateSaveOptions(SaveFormat.Markdown);

            builder.Document.Save(dataDir + "TestDocument.md", saveOptions);
        }
Exemplo n.º 3
0
        public void SetImagesFolder()
        {
            //ExStart:SetImagesFolder
            Document doc = new Document(MyDir + "Image bullet points.docx");

            MarkdownSaveOptions saveOptions = new MarkdownSaveOptions {
                ImagesFolder = ArtifactsDir + "Images"
            };

            using (MemoryStream stream = new MemoryStream())
                doc.Save(stream, saveOptions);
            //ExEnd:SetImagesFolder
        }
Exemplo n.º 4
0
        private static void SetImagesFolder(string dataDir)
        {
            // ExStart:SetImagesFolder
            // Load the document from disk.
            Document doc = new Document(dataDir + "Test.docx");

            MarkdownSaveOptions so = new MarkdownSaveOptions();

            so.ImagesFolder = dataDir + "\\Images";

            using (MemoryStream stream = new MemoryStream())
                doc.Save(stream, so);
            // ExEnd:SetImagesFolder
        }
        public void CellsSaveAsPostDocumentSaveAsMDTest()
        {
            // TODO uncomment below to test the method and replace null with proper value
            string name = BOOK1;
            MarkdownSaveOptions saveOptions = new MarkdownSaveOptions();

            saveOptions.SaveFormat = "markdown";
            string newfilename      = "newbook.md";
            bool?  isAutoFitRows    = true;
            bool?  isAutoFitColumns = true;
            string folder           = TEMPFOLDER;
            //UpdateDataFile(instance,folder, name);
            var response = instance.CellsSaveAsPostDocumentSaveAs(name, saveOptions, folder + "\\" + newfilename, isAutoFitRows, isAutoFitColumns, folder);

            Assert.IsInstanceOf <SaveResponse>(response, "response is SaveResponse");
        }
        public void SpecifyMarkdownSaveOptionsTest()
        {
            // Prepare a path for converted file saving
            string savePath = Path.Combine(OutputDir, "options-output.md");

            // Prepare HTML code and save it to the file
            var code = "<h1>Header 1</h1>" +
                       "<h2>Header 2</h2>" +
                       "<p>Hello, World!!</p>" +
                       "<a href='aspose.com'>aspose</a>";

            File.WriteAllText(Path.Combine(OutputDir, "options.html"), code);

            // Create an instance of SaveOptions and set up the rule:
            // - only <a> and <p> elements will be converted to Markdown
            var options = new MarkdownSaveOptions();

            options.Features = MarkdownFeatures.Link | MarkdownFeatures.AutomaticParagraph;

            // Call the ConvertHTML method to convert the HTML to Markdown.
            Converter.ConvertHTML(Path.Combine(OutputDir, "options.html"), options, savePath);

            Assert.True(File.Exists(savePath));
        }