Exemplo n.º 1
0
        ///<Summary>
        /// ConvertHtmlToXps to convert html file to xps
        ///</Summary>
        public Response ConvertHtmlToXps(string[] fileNames, string folderName)
        {
            return(ProcessTask_(fileNames, (inFiles, outPath, zipOutFolder) =>
            {
                Aspose.Html.Rendering.Xps.XpsRenderingOptions xps_options = new Aspose.Html.Rendering.Xps.XpsRenderingOptions();
                if (Opts.HasCustomParameter("pageSize"))
                {
                    var sz = OptionHelper.getPageSizeByName(Opts.GetCustomParameter("pageSize"));
                    if (sz != null)
                    {
                        xps_options.PageSetup.AnyPage.Size = sz;
                    }
                }
                Dictionary <string, string> customParams = null;
                if (Opts.HasCustomParameter("mdTheme"))
                {
                    var csstheme = Opts.GetCustomParameter("mdTheme");
                    customParams = new Dictionary <string, string> {
                        { "cssTheme", csstheme }
                    };
                }
                SourceFormat srcFormat = ExportHelper.GetSourceFormatByFileName(Opts.FileName);
                ExportHelper helper = ExportHelper.GetHelper(srcFormat, ExportFormat.XPS, customParams);

                helper.Export(inFiles, outPath, xps_options);
            }));
        }
Exemplo n.º 2
0
 ///<Summary>
 /// ConvertHtmlToTiff to convert html file to tiff
 ///</Summary>
 public Response ConvertHtmlToTiff(string[] fileNames, string folderName)
 {
     return(ProcessTask_(fileNames, (inFiles, outPath, zipOutFolder) =>
     {
         ImageRenderingOptions img_options = new ImageRenderingOptions();
         img_options.Format = ImageFormat.Tiff;
         if (Opts.HasCustomParameter("pageSize"))
         {
             var sz = OptionHelper.getPageSizeByName(Opts.GetCustomParameter("pageSize"));
             if (sz != null)
             {
                 img_options.PageSetup.AnyPage.Size = sz;
             }
         }
         if (Opts.HasCustomParameter("bgColor"))
         {
             string bgColor = Opts.GetCustomParameter("bgColor");
             if (!string.IsNullOrEmpty(bgColor))
             {
                 long argb = long.Parse(bgColor, System.Globalization.NumberStyles.HexNumber);
                 img_options.BackgroundColor = System.Drawing.Color.FromArgb((int)(argb | 0xFF000000));
             }
         }
         Dictionary <string, string> customParams = null;
         if (Opts.HasCustomParameter("mdTheme"))
         {
             var csstheme = Opts.GetCustomParameter("mdTheme");
             customParams = new Dictionary <string, string> {
                 { "cssTheme", csstheme }
             };
         }
         SourceFormat srcFormat = ExportHelper.GetSourceFormatByFileName(Opts.FileName);
         ExportHelper helper = ExportHelper.GetHelper(srcFormat, ExportFormat.TIFF, customParams);
         helper.Export(inFiles, outPath, img_options);
     }));
 }
Exemplo n.º 3
0
        ///<Summary>
        /// ConvertHtmlToImages to convert html file to images
        ///</Summary>
        public Response ConvertHtmlToImages(string[] fileNames, string folderName, string outputType)
        {
            if (outputType.Equals("bmp") ||
                outputType.Equals("jpg") || outputType.Equals("jpeg") ||
                outputType.Equals("png") || outputType.Equals("gif"))
            {
                ImageFormat  format    = ImageFormat.Bmp;
                ExportFormat expFormat = ExportFormat.BMP;

                if (outputType.Equals("jpg") || outputType.Equals("jpeg"))
                {
                    format    = ImageFormat.Jpeg;
                    expFormat = ExportFormat.JPEG;
                }
                else if (outputType.Equals("png"))
                {
                    format    = ImageFormat.Png;
                    expFormat = ExportFormat.PNG;
                }
                else if (outputType.Equals("gif"))
                {
                    format    = ImageFormat.Gif;
                    expFormat = ExportFormat.GIF;
                }

                return(ProcessTask_(fileNames, (inFiles, outPath, zipOutFolder) =>
                {
                    ImageRenderingOptions img_options = new ImageRenderingOptions();
                    img_options.Format = format;
                    if (Opts.HasCustomParameter("pageSize"))
                    {
                        var sz = OptionHelper.getPageSizeByName(Opts.GetCustomParameter("pageSize"));
                        if (sz != null)
                        {
                            img_options.PageSetup.AnyPage.Size = sz;
                        }
                    }
                    if (Opts.HasCustomParameter("bgColor"))
                    {
                        string bgColor = Opts.GetCustomParameter("bgColor");
                        if (!string.IsNullOrEmpty(bgColor))
                        {
                            int argb = int.Parse(bgColor, System.Globalization.NumberStyles.HexNumber);
                            img_options.BackgroundColor = System.Drawing.Color.FromArgb(argb);
                        }
                    }
                    Dictionary <string, string> customParams = null;
                    if (Opts.HasCustomParameter("mdTheme"))
                    {
                        var csstheme = Opts.GetCustomParameter("mdTheme");
                        customParams = new Dictionary <string, string> {
                            { "cssTheme", csstheme }
                        };
                    }
                    SourceFormat srcFormat = ExportHelper.GetSourceFormatByFileName(Opts.FileName);
                    ExportHelper helper = ExportHelper.GetHelper(srcFormat, expFormat, customParams);

                    helper.Export(inFiles, outPath, img_options);
                }));
            }

            return(new Response
            {
                FileName = null,
                Status = "Output type not found",
                StatusCode = 500
            });
        }