public static void SpecifyXpsSaveOptions() { //ExStart: SpecifyXpsSaveOptions string dataDir = RunExamples.GetDataDir_Data(); // Open an existing MHTML file for reading. using (var stream = System.IO.File.OpenRead(dataDir + "sample.mht")) { // Create an instance of the XpsSaveOptions with a custom page-size and a background-color. var options = new Aspose.Html.Saving.XpsSaveOptions() { PageSetup = { AnyPage = new Aspose.Html.Drawing.Page() { Size = new Aspose.Html.Drawing.Size(Aspose.Html.Drawing.Length.FromPixels(3000), Aspose.Html.Drawing.Length.FromPixels(1000)) } }, BackgroundColor = System.Drawing.Color.AliceBlue, }; // Call the ConvertMHTML method to convert the MHTML to XPS. Aspose.Html.Converters.Converter.ConvertMHTML(stream, options, "output.xps"); } //ExEnd: SpecifyXpsSaveOptions }
public static void SpecifyXpsSaveOptions() { //ExStart: SpecifyXpsSaveOptions // Prepare an SVG code and save it to the file. var code = "<svg xmlns='http://www.w3.org/2000/svg'>" + "<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red' />" + "</svg>"; System.IO.File.WriteAllText("document.svg", code); // Set A5 as a page-size and change the background color to green var options = new Aspose.Html.Saving.XpsSaveOptions() { 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 SVG document to XPS Aspose.Html.Converters.Converter.ConvertSVG("document.svg", options, "output.xps"); //ExEnd: SpecifyXpsSaveOptions }
public static void SpecifyXpsSaveOptions() { //ExStart: SpecifyXpsSaveOptions // 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.XpsSaveOptions() { 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 XPS Aspose.Html.Converters.Converter.ConvertHTML("document.html", options, "output.xps"); //ExEnd: SpecifyXpsSaveOptions }
public static void ConvertMHTMLFileToXPS() { //ExStart: ConvertMHTMLFileToXPS string dataDir = RunExamples.GetDataDir_Data(); // Open an existing MHTML file for reading. using (var stream = System.IO.File.OpenRead(dataDir + "sample.mht")) { // Create an instance of XpsSaveOptions. var options = new Aspose.Html.Saving.XpsSaveOptions(); // Call the ConvertMHTML method to convert the MHTML to XPS. Aspose.Html.Converters.Converter.ConvertMHTML(stream, options, "output.xps"); } //ExEnd: ConvertMHTMLFileToXPS }
public static void ConvertHTMLDocumentToXPS() { //ExStart: ConvertHTMLDocumentToXPS // Prepare an HTML code and save it to the file. var code = @"<span>Hello World!!</span>"; System.IO.File.WriteAllText("document.html", code); // Initialize an HTML document from the file using (var document = new HTMLDocument("document.html")) { // Initialize PdfSaveOptions var options = new Aspose.Html.Saving.XpsSaveOptions(); // Convert HTML to XPS Aspose.Html.Converters.Converter.ConvertHTML(document, options, "output.xps"); } //ExEnd: ConvertHTMLDocumentToXPS }
public static void ConvertSVGDocumentToXPS() { //ExStart: ConvertSVGDocumentToXPS // Prepare an SVG code and save it to the file. var code = "<svg xmlns='http://www.w3.org/2000/svg'>" + "<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red' />" + "</svg>"; System.IO.File.WriteAllText("document.svg", code); // Initialize an SVG document from the svg file. using (var document = new Aspose.Html.Dom.Svg.SVGDocument("document.svg")) { // Initialize XpsSaveOptions. var options = new Aspose.Html.Saving.XpsSaveOptions(); // Convert SVG to XPS Aspose.Html.Converters.Converter.ConvertSVG(document, options, "output.xps"); } //ExEnd: ConvertSVGDocumentToXPS }