public override DependencyObject GetControl(HtmlFragment fragment)
        {
            var node = fragment as HtmlNode;
            var src  = GetImageSrc(node);

            if (node != null && !string.IsNullOrEmpty(src))
            {
                Uri uri;

                if (Uri.TryCreate(src, UriKind.Absolute, out uri))
                {
                    try
                    {
                        var viewbox = CreateImage(node, src);

                        if (IsInline(fragment))
                        {
                            return(new InlineUIContainer
                            {
                                Child = viewbox
                            });
                        }
                        else
                        {
                            return(viewbox);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine($"Error loading img@src '{uri?.ToString()}': {ex.Message}");
                    }
                }
            }
            return(null);
        }
 public override void ApplyStyles(DocumentStyle style, DependencyObject ctrl, HtmlFragment fragment)
 {
     if (!IsInline(fragment))
     {
         ApplyImageStyles(ctrl as Viewbox, style.Img);
     }
 }
Beispiel #3
0
        private static string AddFragments(TagReader reader, HtmlFragment parentFragment, Stack <string> openTagStack)
        {
            while (reader.Read())
            {
                parentFragment.TryToAddText(HtmlText.Create(reader.Document, reader.PreviousTag, reader.CurrentTag));

                if (reader.CurrentTag.TagType == TagType.Close && openTagStack.Any(t => t.Equals(reader.CurrentTag.Name, StringComparison.CurrentCultureIgnoreCase)))
                {
                    return(reader.CurrentTag.Name);
                }

                var node = parentFragment.AddNode(reader.CurrentTag);
                node.Parent = parentFragment;

                if (reader.CurrentTag.TagType == TagType.Open)
                {
                    openTagStack.Push(reader.CurrentTag.Name);

                    var lastClosed = AddFragments(reader, node, openTagStack);
                    if (lastClosed != openTagStack.Pop())
                    {
                        return(lastClosed);
                    }
                }
            }
            parentFragment.TryToAddText(HtmlText.Create(reader.Document, reader.CurrentTag, null));
            return(null);
        }
Beispiel #4
0
        public void CopyToClipboard()
        {
            HtmlFragment.CopyToClipboard("<p>Hallo</p>");

            // Verify manually that the content can be pasted as text and into MS Word or
            // LibreOffice Writer. There it should create a formatted table.
        }
        public static void Run()
        {
            // ExStart:WithPreambleanddocument
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
            // Create a new Document Object
            Document doc = new Document();
            // Add Page in Pages Collection
            Page page = doc.Pages.Add();
            // Create a Table
            Table table = new Table();
            // Add a row into Table
            Row row = table.Rows.Add();
            // Add Cell with Latex Script to add methematical expressions/formulae
            string latexText2 = @"\documentclass{article}
                                \begin{document}
                                Latex and the document class will normally take care of page layout issues for you. For submission to an academic publication, this entire topic will be out
                                \end{document}";
            Cell   cell       = row.Cells.Add();

            cell.Margin = new MarginInfo {
                Left = 20, Right = 20, Top = 20, Bottom = 20
            };
            HtmlFragment text2 = new HtmlFragment(latexText2);

            cell.Paragraphs.Add(text2);
            // Add table inside page
            page.Paragraphs.Add(table);
            // Save the document
            doc.Save(dataDir + "LatextScriptInPdf2_out.pdf");
            // ExEnd:WithPreambleanddocument
        }
        public static void Run()
        {
            // ExStart:AddHTMLUsingDOM
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Instantiate Document object
            Document doc = new Document();
            // Add a page to pages collection of PDF file
            Page page = doc.Pages.Add();
            // Instantiate HtmlFragment with HTML contnets
            HtmlFragment titel = new HtmlFragment("<fontsize=10><b><i>Table</i></b></fontsize>");

            // Set bottom margin information
            titel.Margin.Bottom = 10;
            // Set top margin information
            titel.Margin.Top = 200;
            // Add HTML Fragment to paragraphs collection of page
            page.Paragraphs.Add(titel);

            dataDir = dataDir + "AddHTMLUsingDOM_out.pdf";
            // Save PDF file
            doc.Save(dataDir);

            // ExEnd:AddHTMLUsingDOM
            Console.WriteLine("\nHTML using DOM added successfully.\nFile saved at " + dataDir);
        }
        private async Task UpdateContentAsync()
        {
            if (_container != null && !string.IsNullOrEmpty(Source))
            {
                _container.RowDefinitions.Clear();
                _container.ColumnDefinitions.Clear();
                _container.Children.Clear();

                var container = new GridDocumentContainer(_container);

                try
                {
                    var doc = await HtmlDocument.LoadAsync(Source);

                    HtmlFragment body = doc?.Body;
                    if (body == null)
                    {
                        body = doc;
                    }

                    WriteFragments(body, container);
                }
                catch (Exception ex)
                {
                    ShowError(ex, container);
                }
            }
        }
        public static void Run()
        {
            // ExStart:AddHTMLUsingDOMAndOverwrite
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
            // Instantiate Document object
            Document doc = new Document();
            // Add a page to pages collection of PDF file
            Page page = doc.Pages.Add();
            // Instantiate HtmlFragment with HTML contnets
            HtmlFragment title = new HtmlFragment("<p style='font-family: Verdana'><b><i>Table contains text</i></b></p>");

            //Font-family from 'Verdana' will be reset to 'Arial'
            title.TextState          = new TextState("Arial");
            title.TextState.FontSize = 20;
            // Set bottom margin information
            title.Margin.Bottom = 10;
            // Set top margin information
            title.Margin.Top = 400;
            // Add HTML Fragment to paragraphs collection of page
            page.Paragraphs.Add(title);
            // Save PDF file
            dataDir = dataDir + "AddHTMLUsingDOMAndOverwrite_out.pdf";
            // Save PDF file
            doc.Save(dataDir);
        }
Beispiel #9
0
        public override void ApplyStyles(DocumentStyle style, DependencyObject ctrl, HtmlFragment fragment)
        {
            var column = ctrl as GridColumn;
            var border = column.Row.Container.GetChild <Border>(column.Index, column.Row.Index);

            if (border != null)
            {
                var tableBorder = GetTableBorder(fragment.AsNode());
                if (tableBorder.HasValue)
                {
                    border.BorderThickness = new Thickness(tableBorder.Value);
                    border.BorderBrush     = style.Table?.BorderForeground ?? new SolidColorBrush(Colors.Black);
                }
                else if (style.Table != null && !double.IsNaN(style.Table.Border.Top))
                {
                    BindingOperations.SetBinding(border, Border.BorderThicknessProperty, CreateBinding(style.Table, "Border"));
                    BindingOperations.SetBinding(border, Border.BorderBrushProperty, CreateBinding(style.Table, "BorderForeground"));
                }

                if (style.Table != null)
                {
                    BindingOperations.SetBinding(border, Border.MarginProperty, CreateBinding(style.Td, "Margin"));
                    BindingOperations.SetBinding(border, Border.PaddingProperty, CreateBinding(style.Td, "Padding"));
                }
            }
        }
        private static ParagraphStyle GetDocumentStyle(HtmlFragment fragment, DocumentStyle style)
        {
            if (style == null)
            {
                return(null);
            }
            switch (fragment.Name.ToLowerInvariant())
            {
            case "h1":
                return(style.H1);

            case "h2":
                return(style.H2);

            case "h3":
                return(style.H3);

            case "h4":
                return(style.H4);

            case "h5":
                return(style.H5);

            case "h6":
                return(style.H6);

            default:
                return(null);
            }
        }
        private void WriteFragments(HtmlFragment fragment, DocumentContainer parentContainer)
        {
            if (parentContainer != null)
            {
                foreach (var childFragment in fragment.Fragments)
                {
                    var writer = HtmlWriterFactory.Find(childFragment);

                    var ctrl = writer?.GetControl(childFragment);

                    if (ctrl != null)
                    {
                        if (!parentContainer.CanContain(ctrl))
                        {
                            var antecesorContainer = parentContainer.Find(ctrl);

                            if (antecesorContainer == null)
                            {
                                continue;
                            }
                            else
                            {
                                parentContainer = antecesorContainer;
                            }
                        }

                        var currentContainer = parentContainer.Append(ctrl);

                        WriteFragments(childFragment, currentContainer);

                        writer?.ApplyStyles(_docStyles, ctrl, childFragment);
                    }
                }
            }
        }
        public override DependencyObject GetControl(HtmlFragment fragment)
        {
            var node = fragment as HtmlNode;

            if (node != null && node.Attributes.ContainsKey("href"))
            {
                Hyperlink a = new Hyperlink();

                Uri uri;

                if (Uri.TryCreate(node.Attributes["href"], UriKind.Absolute, out uri))
                {
                    try
                    {
                        a.NavigateUri = uri;
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine($"Error loading a@href '{uri?.ToString()}': {ex.Message}");
                    }
                }

                return(a);
            }
            return(null);
        }
        public override void ApplyStyles(DocumentStyle style, DependencyObject ctrl, HtmlFragment fragment)
        {
            var grid = ctrl as Grid;
            var vb   = grid.GetChild <Viewbox>(0, 0);

            ApplyImageStyles(vb, GetStyle(style));
        }
Beispiel #14
0
        public override void ApplyStyles(DocumentStyle style, DependencyObject ctrl, HtmlFragment fragment)
        {
            var li           = ctrl as Paragraph;
            var currentStyle = style.Li;

            if (!string.IsNullOrEmpty(currentStyle?.Bullet))
            {
                currentStyle.RegisterPropertyChangedCallback(ListStyle.BulletProperty, (sender, dp) =>
                {
                    var r = li.Inlines[0] as Run;
                    if (r != null)
                    {
                        r.Text = currentStyle?.Bullet;
                    }
                });

                li.Inlines.Insert(0, new Run
                {
                    Text = currentStyle.Bullet
                });
                li.Inlines.Insert(1, new Run
                {
                    Text = " "
                });
            }
            ApplyParagraphStyles(li, currentStyle);
        }
Beispiel #15
0
        public void MarkdownToPDFTest()
        {
            var path = System.Environment.CurrentDirectory;

            path = System.IO.Path.Combine(path, "../../../Content/Markdown/Markdown.md");
            path = System.IO.Path.GetFullPath(path);
            var content = System.IO.File.ReadAllText(path);

            var doc = new Document();
            var pg  = new Section();

            pg.FontSize = 12;
            pg.Margins  = new Scryber.Drawing.PDFThickness(20);
            var frag = new HtmlFragment();

            doc.Pages.Add(pg);
            pg.Contents.Add(frag);
            frag.ContentsAsString = content;
            frag.Format           = HtmlFormatType.Markdown;

            using (var output = DocStreams.GetOutputStream("MarkdownTest.pdf"))
            {
                doc.LayoutComplete += Doc_LayoutComplete;
                doc.SaveAsPDF(output);
            }
        }
        public void Should_render_only_its_children()
        {
            var fragment = new HtmlFragment();
            fragment.Children.Add(new HtmlElement("a"));

            fragment.ToString().ShouldEqual("<a></a>");
        }
        public static void Run()
        {
            // ExStart:AddHTMLUsingDOM
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Instantiate Document object
            Document doc = new Document();
            // Add a page to pages collection of PDF file
            Page page = doc.Pages.Add();
            // Instantiate HtmlFragment with HTML contnets
            HtmlFragment titel = new HtmlFragment("<fontsize=10><b><i>Table</i></b></fontsize>");
            // Set bottom margin information
            titel.Margin.Bottom = 10;
            // Set top margin information
            titel.Margin.Top = 200;
            // Add HTML Fragment to paragraphs collection of page
            page.Paragraphs.Add(titel);

            dataDir = dataDir + "AddHTMLUsingDOM_out.pdf";
            // Save PDF file
            doc.Save(dataDir);

            // ExEnd:AddHTMLUsingDOM            
            Console.WriteLine("\nHTML using DOM added successfully.\nFile saved at " + dataDir);
        }
        public void Should_render_only_its_children()
        {
            var fragment = new HtmlFragment();

            fragment.Children.Add(new HtmlElement("a"));

            fragment.ToString().ShouldEqual("<a></a>");
        }
        public IHtmlNode CreateSections(GridPagerData section)
        {
            var fragment = new HtmlFragment();

            pagingSectionsBuilder.CreateSections(section).AppendTo(fragment);

            return(fragment);
        }
        public IHtmlNode CreateSections(GridPagerData section)
        {
            var fragment = new HtmlFragment();

            pagingSectionsBuilder.CreateSections(section).AppendTo(fragment);

            return fragment;
        }
Beispiel #21
0
 public override DependencyObject GetControl(HtmlFragment fragment)
 {
     return(new GridColumn()
     {
         ColSpan = GetSpan(fragment.AsNode(), "colspan"),
         RowSpan = GetSpan(fragment.AsNode(), "rowspan"),
     });
 }
Beispiel #22
0
        public override void ApplyStyles(DocumentStyle style, DependencyObject ctrl, HtmlFragment fragment)
        {
            var caption = ctrl as Paragraph;

            caption.TextAlignment = Parse(style.Img.HorizontalAlignment);

            ApplyParagraphStyles(caption, style.FigCaption);
        }
 public override DependencyObject GetControl(HtmlFragment fragment)
 {
     //LineBreak doesn't work with hyperlink
     return(new Run
     {
         Text = Environment.NewLine
     });
 }
Beispiel #24
0
        public static void Run()
        {
            // ExStart:SetHTMLStringFormatting
            HtmlFragment html = new HtmlFragment("some text");

            html.TextState      = new TextState();
            html.TextState.Font = FontRepository.FindFont("Calibri");
            // ExEnd:SetHTMLStringFormatting
        }
Beispiel #25
0
    static public HtmlFragment FromClipboard()

    {
        string rawClipboardText = Clipboard.GetText(TextDataFormat.Html);

        HtmlFragment h = new HtmlFragment(rawClipboardText);

        return(h);
    }
        public void Should_append_to_container()
        {
            var fragment = new HtmlFragment();
            var container = new HtmlElement("div");

            fragment.AppendTo(container);

            container.Children[0].ShouldBeSameAs(fragment);
        }
Beispiel #27
0
        public IHtmlNode Build()
        {
            var fragment = new HtmlFragment();

            RadioButton().AppendTo(fragment);
            Label().AppendTo(fragment);

            return fragment;
        }
        public void Should_append_to_container()
        {
            var fragment  = new HtmlFragment();
            var container = new HtmlElement("div");

            fragment.AppendTo(container);

            container.Children[0].ShouldBeSameAs(fragment);
        }
Beispiel #29
0
        /// <summary>
        /// Copy HighLight Code To Clipboard
        /// </summary>
        private void InsertToClipboard(string outputFileName)
        {
            StringBuilder sb = new StringBuilder();

            using (FileStream fs = new FileStream(outputFileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs, new UTF8Encoding(false)))
                {
                    //Fix 存到剪貼簿空白不見的問題
                    while (sr.Peek() >= 0)
                    {
                        string line = sr.ReadLine();

                        string byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
                        line = line.Replace(byteOrderMarkUtf8, "");

                        if (!line.StartsWith("</pre>"))
                        {
                            line = line.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("&apos;", "'") + "<br />";
                        }
                        var charList = line.ToCharArray().ToList();

                        StringBuilder sbLine = new StringBuilder();
                        int           index  = 0;

                        if (IsShowLineNumber && !line.StartsWith("</pre>"))
                        {
                            index = line.IndexOf(span) + span.Length;
                            string nrLine = line.Substring(0, index);

                            int endTextIndex   = nrLine.IndexOf(span);
                            int startTextIndex = nrLine.LastIndexOf(">", endTextIndex) + 1;

                            nrLine = nrLine.Substring(0, startTextIndex) + nrLine.Substring(startTextIndex, endTextIndex - startTextIndex).Replace(" ", "&nbsp;") + nrLine.Substring(endTextIndex);

                            sbLine.Append(nrLine);
                        }

                        for (int i = index; i < charList.Count; i++)
                        {
                            if (charList[i] == ' ')
                            {
                                sbLine.Append("&nbsp;&nbsp;");
                            }
                            else
                            {
                                sbLine.Append(line.Substring(i));
                                break;
                            }
                        }
                        sb.AppendLine(sbLine.ToString());
                    }
                }
            }
            HtmlFragment.CopyToClipboard(sb.ToString());
            File.Delete(outputFileName);
        }
        public IHtmlNode CreateRow()
        {
            var container = new HtmlFragment();
            foreach (var builder in rowBuilders)
            {
                builder.CreateRow().AppendTo(container);
            }

            return container;
        }
        public virtual IHtmlNode Create(GridPagerData section)
        {
            var fragment = new HtmlFragment();

            pagerSections.CreateSections(section).AppendTo(fragment);

            statusBuilder.Create(section).AppendTo(fragment);

            return fragment;
        }
        public IHtmlNode Build()
        {
            var fragment = new HtmlFragment();

            Checkbox().AppendTo(fragment);
            Label().AppendTo(fragment);
            HiddenInput().AppendTo(fragment);

            return fragment;
        }
        public override Component DoBuildItemCell(TableGrid grid, TableRow row, int rowindex, int columnindex, PDFDataContext context)
        {
            TableCell    cell     = (TableCell)base.DoBuildItemCell(grid, row, rowindex, columnindex, context);
            HtmlFragment fragment = new HtmlFragment();

            fragment.DataBinding += new PDFDataBindEventHandler(link_DataBinding);
            cell.Contents.Add(fragment);

            return(cell);
        }
Beispiel #34
0
        public virtual IHtmlNode Create(GridPagerData section)
        {
            var fragment = new HtmlFragment();


            pagerSections.CreateSections(section).AppendTo(fragment);

            statusBuilder.Create(section).AppendTo(fragment);

            return(fragment);
        }
Beispiel #35
0
    public HtmlFragment ParseFragment( string html )
    {
      var document = new AP.HtmlDocument();

      document.LoadHtml( html );

      var fragment = new HtmlFragment( this );
      fragment.AddCopies( document.AsDocument().Nodes() );

      return fragment;
    }
        public IHtmlNode CreateSections(GridPagerData section)
        {
            var container = new HtmlFragment();

            AppendFirstPrevButtons(container, section.UrlBuilder, section);
            AppendNumericSection(container, section.UrlBuilder, section);
            AppendPageInput(container, section);
            AppendNextLast(container, section.UrlBuilder, section);
            AppendPageSizeDropDown(container, section);

            return container;
        }
Beispiel #37
0
        public HtmlFragment ParseFragment(string html)
        {
            var document = new AP.HtmlDocument();

            document.LoadHtml(html);

            var fragment = new HtmlFragment(this);

            fragment.AddCopies(document.AsDocument().Nodes());

            return(fragment);
        }
        public IHtmlNode CreateSections(GridPagerData section)
        {
            var container = new HtmlFragment();

            AppendFirstPrevButtons(container, section.UrlBuilder, section);
            AppendNumericSection(container, section.UrlBuilder, section);
            AppendPageInput(container, section);
            AppendNextLast(container, section.UrlBuilder, section);
            AppendPageSizeDropDown(container, section);

            return(container);
        }
Beispiel #39
0
        private void AppendText(IHtmlNode td)
        {
            var p = new HtmlElement("p").AddClass(UIPrimitives.ResetStyle)
                    .AppendTo(td);

            new HtmlElement("a").AddClass(UIPrimitives.Icon, "t-collapse")
            .Attribute("href", "#")
            .AppendTo(p);

            var fragment = new HtmlFragment().AppendTo(p);

            template(fragment);
        }
        protected static string GetIframeSrc(HtmlFragment fragment)
        {
            var node = fragment.AsNode();

            if (node != null)
            {
                if (node.Attributes.ContainsKey("src"))
                {
                    return(node.Attributes["src"]);
                }
            }
            return(string.Empty);
        }
        private void AppendText(IHtmlNode td)
        {
            var p = new HtmlElement("p").AddClass(UIPrimitives.ResetStyle)
                .AppendTo(td);

            new HtmlElement("a").AddClass(UIPrimitives.Icon, "k-i-collapse")
                .Attribute("href", "#")
                .AppendTo(p);

            var fragment = new HtmlFragment().AppendTo(p);

            template(fragment);
        }
        public IHtmlNode CreateSections(GridPagerData section)
        {
            var currentPage = section.CurrentPage;
            var pageCount = section.PageCount;

            var container = new HtmlFragment();
            var style = section.Style;

            AppendFirstPrevButtons(container, style, section.UrlBuilder, currentPage);
            AppendNumericSection(container, style, section.UrlBuilder, section.CurrentPage, section.PageCount);
            AppendPageSizeDropDown(container, style, section);
            AppendPageInput(container, style, section);
            AppendNextLast(container, style, section.UrlBuilder, currentPage, pageCount);
            return container;
        }
        public override IHtmlNode Create(object dataItem)
        {
            var fragment = new HtmlFragment();

            if (ShouldAppendDataKeys)
            {
                AppendDataKeys(fragment, dataItem);
            }

            var button = base.Create(dataItem);

            button.AppendTo(fragment);

            return fragment;
        }
Beispiel #44
0
        public virtual IHtmlNode Create(GridPagerData section)
        {
            var fragment = new HtmlFragment();

            pagerSections.CreateSections(section).AppendTo(fragment);

            if (section.Refresh)
            {
                refreshBuilder.Create(section.UrlBuilder.SelectUrl(), section.Messages.Refresh).AppendTo(fragment);
            }

            if (section.Info)
            {
                statusBuilder.Create(section).AppendTo(fragment);
            }

            return fragment;
        }
Beispiel #45
0
 private static bool IsTableFragment(HtmlFragment htmlFragment)
 {
     var tableTags = new[] {"table", "tr", "td", "thead", "tfoot", "tbody"};
     return tableTags.Contains(htmlFragment.Name);
 }
Beispiel #46
0
 protected void output(HtmlFragment fragment)
 {
     Console.WriteLine(((string)fragment).Replace("\n", Environment.NewLine));
 }
        public static void Run()
        {
            // ExStart:CreateMultiColumnPdf
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            Document doc = new Document();
            // Specify the left margin info for the PDF file
            doc.PageInfo.Margin.Left = 40;
            // Specify the Right margin info for the PDF file
            doc.PageInfo.Margin.Right = 40;
            Page page = doc.Pages.Add();

            Aspose.Pdf.Drawing.Graph graph1 = new Aspose.Pdf.Drawing.Graph(500, 2);
            // Add the line to paraphraphs collection of section object
            page.Paragraphs.Add(graph1);

            // Specify the coordinates for the line
            float[] posArr = new float[] { 1, 2, 500, 2 };
            Aspose.Pdf.Drawing.Line l1 = new Aspose.Pdf.Drawing.Line(posArr);
            graph1.Shapes.Add(l1);
            // Create string variables with text containing html tags

            string s = "<font face=\"Times New Roman\" size=4>" +

            "<strong> How to Steer Clear of money scams</<strong> "
            + "</font>";
            // Create text paragraphs containing HTML text

            HtmlFragment heading_text = new HtmlFragment(s);
            page.Paragraphs.Add(heading_text);

            Aspose.Pdf.FloatingBox box = new Aspose.Pdf.FloatingBox();
            // Add four columns in the section
            box.ColumnInfo.ColumnCount = 2;
            // Set the spacing between the columns
            box.ColumnInfo.ColumnSpacing = "5";

            box.ColumnInfo.ColumnWidths = "105 105";
            TextFragment text1 = new TextFragment("By A Googler (The Official Google Blog)");
            text1.TextState.FontSize = 8;
            text1.TextState.LineSpacing = 2;
            box.Paragraphs.Add(text1);
            text1.TextState.FontSize = 10;

            text1.TextState.FontStyle = FontStyles.Italic;
            // Create a graphs object to draw a line
            Aspose.Pdf.Drawing.Graph graph2 = new Aspose.Pdf.Drawing.Graph(50, 10);
            // Specify the coordinates for the line
            float[] posArr2 = new float[] { 1, 10, 100, 10 };
            Aspose.Pdf.Drawing.Line l2 = new Aspose.Pdf.Drawing.Line(posArr2);
            graph2.Shapes.Add(l2);

            // Add the line to paragraphs collection of section object
            box.Paragraphs.Add(graph2);

            TextFragment text2 = new TextFragment(@"Sed augue tortor, sodales id, luctus et, pulvinar ut, eros. Suspendisse vel dolor. Sed quam. Curabitur ut massa vitae eros euismod aliquam. Pellentesque sit amet elit. Vestibulum interdum pellentesque augue. Cras mollis arcu sit amet purus. Donec augue. Nam mollis tortor a elit. Nulla viverra nisl vel mauris. Vivamus sapien. nascetur ridiculus mus. Nam justo lorem, aliquam luctus, sodales et, semper sed, enim Nam justo lorem, aliquam luctus, sodales et,nAenean posuere ante ut neque. Morbi sollicitudin congue felis. Praesent turpis diam, iaculis sed, pharetra non, mollis ac, mauris. Phasellus nisi ipsum, pretium vitae, tempor sed, molestie eu, dui. Duis lacus purus, tristique ut, iaculis cursus, tincidunt vitae, risus. Sed commodo. *** sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam justo lorem, aliquam luctus, sodales et, semper sed, enim Nam justo lorem, aliquam luctus, sodales et, semper sed, enim Nam justo lorem, aliquam luctus, sodales et, semper sed, enim nAenean posuere ante ut neque. Morbi sollicitudin congue felis. Praesent turpis diam, iaculis sed, pharetra non, mollis ac, mauris. Phasellus nisi ipsum, pretium vitae, tempor sed, molestie eu, dui. Duis lacus purus, tristique ut, iaculis cursus, tincidunt vitae, risus. Sed commodo. *** sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed urna. . Duis convallis ultrices nisi. Maecenas non ligula. Nunc nibh est, tincidunt in, placerat sit amet, vestibulum a, nulla. Praesent porttitor turpis eleifend ante. Morbi sodales.nAenean posuere ante ut neque. Morbi sollicitudin congue felis. Praesent turpis diam, iaculis sed, pharetra non, mollis ac, mauris. Phasellus nisi ipsum, pretium vitae, tempor sed, molestie eu, dui. Duis lacus purus, tristique ut, iaculis cursus, tincidunt vitae, risus. Sed commodo. *** sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed urna. . Duis convallis ultrices nisi. Maecenas non ligula. Nunc nibh est, tincidunt in, placerat sit amet, vestibulum a, nulla. Praesent porttitor turpis eleifend ante. Morbi sodales.");
            box.Paragraphs.Add(text2);

            page.Paragraphs.Add(box);

            dataDir = dataDir + "CreateMultiColumnPdf_out.pdf";
            // Save PDF file
            doc.Save(dataDir);
            // ExEnd:CreateMultiColumnPdf            
            Console.WriteLine("\nMulti column pdf file created successfully.\nFile saved at " + dataDir);
        }
        public void Should_render_as_empty_if_no_children()
        {
            var fragment = new HtmlFragment();

            fragment.InnerHtml.ShouldBeEmpty();
        }
Beispiel #49
0
        /// <summary>
        ///     Replaces XForm HTML tables with more semantic markup.
        /// </summary>
        /// <param name="htmlFragment">HtmlFragment of XForm</param>
        /// <param name="addClassAttribute">
        ///     Will add individual HTML class for each element.
        ///     For matching HTML classes see <see cref="XFormHelper.TableTagCssClasses" />
        /// </param>
        /// <param name="numTableColumns">Number of columns in the XForm table. Use GetNumberOfTableColumns to retrieve the value.</param>
        /// <returns>Modified HtmlFragment</returns>
        public static HtmlFragment CleanupXFormHtmlMarkup(HtmlFragment htmlFragment, bool addClassAttribute = true, int numTableColumns = 1)
        {
            var originalTag = htmlFragment.Name;

            if (!IsTableFragment(htmlFragment))
            {
                return htmlFragment;
            }

            htmlFragment.Name = "div";
            var elFragment = htmlFragment as ElementFragment;

            if (elFragment != null)
            {
                RemoveAttribute(elFragment, "valign");

                if (addClassAttribute)
                {
                    AddClassAttribute(originalTag, elFragment, numTableColumns);
                }
            }

            return htmlFragment;
        }