Beispiel #1
0
        public static void SpecifyImageSaveOptions()
        {
            //ExStart: SpecifyImageSaveOptions
            // 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 up the page-size to 3000x1000 pixels and change the background color.
            var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Jpeg)
            {
                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 ConvertSVG to convert 'document.html' into jpeg image
            Aspose.Html.Converters.Converter.ConvertSVG("document.svg", options, "output.jpg");
            //ExEnd: SpecifyImageSaveOptions
        }
Beispiel #2
0
        public static void SpecifyImageSaveOptions()
        {
            //ExStart: SpecifyImageSaveOptions
            string dataDir = RunExamples.GetDataDir_Data();

            // Open an existing EPUB file for reading.
            using (var stream = System.IO.File.OpenRead(dataDir + "input.epub"))
            {
                // Initailize the ImageSaveOptions with a custom page-size and a background-color.
                var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Jpeg)
                {
                    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 ConvertEPUB method to convert the EPUB file to JPG.
                Aspose.Html.Converters.Converter.ConvertEPUB(stream, options, "output.jpg");
            }
            //ExEnd: SpecifyImageSaveOptions
        }
Beispiel #3
0
        public static void SpecifyImageSaveOptions()
        {
            //ExStart: SpecifyImageSaveOptions
            // 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 up the page-size 3000x1000 pixels and change the background color to green
            var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Jpeg)
            {
                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.Green,
            };

            // Call the ConvertHTML to convert 'document.html' into jpeg image
            Aspose.Html.Converters.Converter.ConvertHTML("document.html", options, "output.jpg");
            //ExEnd: SpecifyImageSaveOptions
        }
Beispiel #4
0
        public static void ConvertEPUBToTIFF()
        {
            //ExStart: ConvertEPUBToTIFF
            string dataDir = RunExamples.GetDataDir_Data();

            // Open an existing EPUB file for reading.
            using (var stream = System.IO.File.OpenRead(dataDir + "input.epub"))
            {
                // Initialize ImageSaveOptions
                var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Tiff);

                // Call the ConvertEPUB method to convert the EPUB file to TIFF.
                Aspose.Html.Converters.Converter.ConvertEPUB(stream, options, "output.tiff");
            }
            //ExEnd: ConvertEPUBToTIFF
        }
Beispiel #5
0
        public static void ConvertMHTMLToGIF()
        {
            //ExStart: ConvertMHTMLToGIF
            string dataDir = RunExamples.GetDataDir_Data();

            // Open an existing MHTML file for reading.
            using (var stream = System.IO.File.OpenRead(dataDir + "sample.mht"))
            {
                // Initialize ImageSaveOptions
                var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Gif);

                // Call the ConvertMHTML method to convert the MHTML file to GIF.
                Aspose.Html.Converters.Converter.ConvertMHTML(stream, options, "output.gif");
            }
            //ExEnd: ConvertMHTMLToGIF
        }
Beispiel #6
0
        public static void ConvertHTMLToTIFF()
        {
            //ExStart: ConvertHTMLToTIFF
            // 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);

            // Initialize an HTML document from the html file
            using (var document = new Aspose.Html.HTMLDocument("document.html"))
            {
                // Initialize ImageSaveOptions
                var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Tiff);

                // Convert HTML to TIFF
                Aspose.Html.Converters.Converter.ConvertHTML(document, options, "output.tiff");
            }
            //ExEnd: ConvertHTMLToTIFF
        }
Beispiel #7
0
        public static void ConvertSVGToGIF()
        {
            //ExStart: ConvertSVGToGIF
            // 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 ImageSaveOptions
                var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Gif);

                // Convert HTML to GIF
                Aspose.Html.Converters.Converter.ConvertSVG(document, options, "output.gif");
            }
            //ExEnd: ConvertSVGToGIF
        }