XPath Query Processing
Improved the processing of the XPath Query. The following C# code sample demonstrates a Web Scrapping, XPath Query usage via API:
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-.NET
// Prepare HTML code
var code = @"
<div class='happy'>
<div>
<span>Hello!</span>
</div>
</div>
<p class='happy'>
<span>World</span>
</p>
";
// Initialize a document based on the prepared code
using (var document = new Aspose.Html.HTMLDocument(code, "."))
{
// Here we evaluate the XPath expression where we select all child SPAN elements from elements whose 'class' attribute equals to 'happy':
var result = document.Evaluate("//*[@class='happy']//span",
document,
null,
Aspose.Html.Dom.XPath.XPathResultType.Any,
null);
// Iterate over the resulted nodes
for (Aspose.Html.Dom.Node node; (node = result.IterateNext()) != null;)
{
System.Console.WriteLine(node.TextContent);
// output: Hello
// output: World!
}
}
Improved handling of Combining Diacritical Marks
Improved the handling of Combining Diacritical Marks Unicode block containing the combining characters for symbols.
Improved CSS Style Parsing
The parsing performance of CSS Styles has been improved.
Improved HTML to PDF Conversion
The HTML to PDF document converter process has been optimized. The representation of Arabic Characters when converting HTML to PDF has also been improved. The following C# code sample demonstrates how HTML can be converted into PDF using API, while configuring various PDF related options (such as, PDF page size and PDF page background color):
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-.NET
// Prepare an HTML code and save it to the file
var code = @"<span>Hello</span> <span>World!!</span>";
System.IO.File.WriteAllText("document.html", code);
// Set A5 as a page-size and change the background color to green
var options = new Aspose.Html.Saving.PdfSaveOptions()
{
PageSetup =
{
AnyPage = new Aspose.Html.Drawing.Page()
{
Size = new Aspose.Html.Drawing.Size(Aspose.Html.Drawing.Length.FromInches(8.3f), Aspose.Html.Drawing.Length.FromInches(5.8f))
}
},
BackgroundColor = System.Drawing.Color.Green,
};
// Convert HTML document to PDF
Aspose.Html.Converters.Converter.ConvertHTML("document.html", options, "output.pdf");
Better Support of Showing SVG in PDF
Previously SVG was not showing up in PDF. This issue has been resolved. The following C# API code sample demonstrates SVG to PDF conversion:
using System.IO;
using Aspose.Html.Converters;
using Aspose.Html.Saving;
...
// Invoke the ConvertSVG method for SVG to PDF conversion
Converter.ConvertSVG(Path.Combine(DataDir, "shapes.svg"), new PdfSaveOptions(), Path.Combine(OutputDir, "convert-with-single-line.pdf"));
For a complete list of features, enhancements, and bug fixes in this release please visit, Aspose.HTML for .NET 22.5 Release Notes.