public void CheckThatAllMethodsArePresent()
        {
            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions();
            htmlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.Png);
            imageSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
            pdfSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            PsSaveOptions psSaveOptions = new PsSaveOptions();
            psSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            SvgSaveOptions svgSaveOptions = new SvgSaveOptions();
            svgSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            SwfSaveOptions swfSaveOptions = new SwfSaveOptions();
            swfSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            XamlFixedSaveOptions xamlFixedSaveOptions = new XamlFixedSaveOptions();
            xamlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            XpsSaveOptions xpsSaveOptions = new XpsSaveOptions();
            xpsSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();
        }
        public void PageStreamSavingCallback()
        {
            Stream docStream = new FileStream(MyDir + "Rendering.doc", FileMode.Open);
            Document doc = new Document(docStream);

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions { PageIndex = 0, PageCount = doc.PageCount };
            htmlFixedSaveOptions.PageSavingCallback = new CustomPageStreamPageSavingCallback();

            doc.Save(MyDir + @"\Artifacts\out.html", htmlFixedSaveOptions);

            docStream.Close();
        }
        public void EncodingUsingSystemTextEncoding()
        {
            Document doc = DocumentHelper.CreateDocumentFillWithDummyText();

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                Encoding = Encoding.ASCII,
                SaveFormat = SaveFormat.HtmlFixed,
                ExportEmbeddedCss = true,
                ExportEmbeddedFonts = true,
                ExportEmbeddedImages = true,
                ExportEmbeddedSvg = true
            };

            doc.Save(MyDir + "EncodingUsingSystemTextEncoding OUT.html", htmlFixedSaveOptions);
        }
        public void PageFileNameSavingCallback()
        {
            Document doc = new Document(MyDir + "Rendering.doc");

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions { PageIndex = 0, PageCount = doc.PageCount };
            htmlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            doc.Save(MyDir + @"\Artifacts\out.html", htmlFixedSaveOptions);

            string[] filePaths = Directory.GetFiles(MyDir, "Page_*.html");

            for (int i = 0; i < doc.PageCount; i++)
            {
                string file = string.Format(MyDir + "Page_{0}.html", i);
                Assert.AreEqual(file, filePaths[i]);
            }
        }
        [Test] //ExSkip
        public void PageFileNameSavingCallback()
        {
            Document doc = new Document(MyDir + "Rendering.doc");

            HtmlFixedSaveOptions htmlFixedSaveOptions =
                new HtmlFixedSaveOptions {
                PageIndex = 0, PageCount = doc.PageCount
            };

            htmlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            doc.Save(ArtifactsDir + "Rendering.html", htmlFixedSaveOptions);

            string[] filePaths = Directory.GetFiles(ArtifactsDir + "", "Page_*.html");

            for (int i = 0; i < doc.PageCount; i++)
            {
                string file = string.Format(ArtifactsDir + "Page_{0}.html", i);
                Assert.AreEqual(file, filePaths[i]);//ExSkip
            }
        }
        public void UseEncoding()
        {
            //ExStart
            //ExFor:Saving.HtmlFixedSaveOptions.Encoding
            //ExSummary:Shows how to use "Encoding" parameter with "HtmlFixedSaveOptions"
            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Writeln("Hello World!");

            //Create "HtmlFixedSaveOptions" with "Encoding" parameter
            //You can also set "Encoding" using System.Text.Encoding, like "Encoding.ASCII", or "Encoding.GetEncoding()"
            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions {
                Encoding = new ASCIIEncoding(), SaveFormat = SaveFormat.HtmlFixed,
            };

            //Uses "HtmlFixedSaveOptions"
            doc.Save(MyDir + @"\Artifacts\UseEncoding.html", htmlFixedSaveOptions);
            //ExEnd
        }
예제 #7
0
        public void ExportEmbeddedObjects()
        {
            //ExStart
            //ExFor:HtmlFixedSaveOptions.ExportEmbeddedCss
            //ExFor:HtmlFixedSaveOptions.ExportEmbeddedFonts
            //ExFor:HtmlFixedSaveOptions.ExportEmbeddedImages
            //ExFor:HtmlFixedSaveOptions.ExportEmbeddedSvg
            //ExSummary:Shows how to export embedded objects into HTML file.
            Document doc = DocumentHelper.CreateDocumentFillWithDummyText();

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                ExportEmbeddedCss    = true,
                ExportEmbeddedFonts  = true,
                ExportEmbeddedImages = true,
                ExportEmbeddedSvg    = true
            };

            doc.Save(MyDir + @"\Artifacts\ExportEmbeddedObjects.html", htmlFixedSaveOptions);
            //ExEnd
        }
        public void UseEncoding()
        {
            //ExStart
            //ExFor:Saving.HtmlFixedSaveOptions.Encoding
            //ExSummary:Shows how to use "Encoding" parameter with "HtmlFixedSaveOptions"
            Aspose.Words.Document doc = new Aspose.Words.Document();

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.Writeln("Hello World!");

            //Create "HtmlFixedSaveOptions" with "Encoding" parameter
            //You can also set "Encoding" using System.Text.Encoding, like "Encoding.ASCII", or "Encoding.GetEncoding()"
            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                Encoding = new ASCIIEncoding(),
                SaveFormat = SaveFormat.HtmlFixed,
            };

            //Uses "HtmlFixedSaveOptions"
            doc.Save(MyDir + "UseEncoding.html", htmlFixedSaveOptions);
            //ExEnd
        }
        public void ExportFormFields(bool exportFormFields)
        {
            //ExStart
            //ExFor:HtmlFixedSaveOptions.ExportFormFields
            //ExSummary:Shows how to export form fields to Html.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertCheckBox("CheckBox", false, 15);

            // When we export a document with form fields to .html,
            // there are two ways in which Aspose.Words can export form fields.
            // Setting the "ExportFormFields" flag to "true" will export them as interactive objects.
            // Setting this flag to "false" will display form fields as plain text.
            // This will freeze them at their current value, and prevent the reader of our HTML document
            // from being able to interact with them.
            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                ExportFormFields = exportFormFields
            };

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.ExportFormFields.html", htmlFixedSaveOptions);

            string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.ExportFormFields.html");

            if (exportFormFields)
            {
                Assert.True(Regex.Match(outDocContents,
                                        "<a name=\"CheckBox\" style=\"left:0pt; top:0pt;\"></a>" +
                                        "<input style=\"position:absolute; left:0pt; top:0pt;\" type=\"checkbox\" name=\"CheckBox\" />").Success);
            }
            else
            {
                Assert.True(Regex.Match(outDocContents,
                                        "<a name=\"CheckBox\" style=\"left:0pt; top:0pt;\"></a>" +
                                        "<div class=\"awdiv\" style=\"left:0.8pt; top:0.8pt; width:14.25pt; height:14.25pt; border:solid 0.75pt #000000;\"").Success);
            }
            //ExEnd
        }
        public void OptimizeGraphicsOutput()
        {
            //ExStart
            //ExFor:FixedPageSaveOptions.OptimizeOutput
            //ExFor:HtmlFixedSaveOptions.OptimizeOutput
            //ExSummary:Shows how to optimize document objects while saving to html.
            Document doc = new Document(MyDir + "Rendering.docx");

            HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions {
                OptimizeOutput = false
            };

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.OptimizeGraphicsOutput.Unoptimized.html", saveOptions);

            saveOptions.OptimizeOutput = true;

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.OptimizeGraphicsOutput.Optimized.html", saveOptions);

            Assert.True(new FileInfo(ArtifactsDir + "HtmlFixedSaveOptions.OptimizeGraphicsOutput.Unoptimized.html").Length >
                        new FileInfo(ArtifactsDir + "HtmlFixedSaveOptions.OptimizeGraphicsOutput.Optimized.html").Length);
            //ExEnd
        }
        public void ExportEmbeddedFonts(bool exportEmbeddedFonts)
        {
            //ExStart
            //ExFor:HtmlFixedSaveOptions.ExportEmbeddedFonts
            //ExSummary:Shows how to determine where to store embedded fonts when exporting a document to Html.
            Document doc = new Document(MyDir + "Embedded font.docx");

            // When we export a document with embedded fonts to .html,
            // Aspose.Words can place the fonts in two possible locations.
            // Setting the "ExportEmbeddedFonts" flag to "true" will store the raw data for embedded fonts within the CSS stylesheet,
            // in the "url" property of the "@font-face" rule. This may create a huge CSS stylesheet file
            // and reduce the number of external files that this HTML conversion will create.
            // Setting this flag to "false" will create a file for each font.
            // The CSS stylesheet will link to each font file using the "url" property of the "@font-face" rule.
            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                ExportEmbeddedFonts = exportEmbeddedFonts
            };

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedFonts.html", htmlFixedSaveOptions);

            string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedFonts/styles.css");

            if (exportEmbeddedFonts)
            {
                Assert.True(Regex.Match(outDocContents,
                                        "@font-face { font-family:'Arial'; font-style:normal; font-weight:normal; src:local[(]'☺'[)], url[(].+[)] format[(]'woff'[)]; }").Success);
                Assert.AreEqual(0, Directory.GetFiles(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedFonts").Count(f => f.EndsWith(".woff")));
            }
            else
            {
                Assert.True(Regex.Match(outDocContents,
                                        "@font-face { font-family:'Arial'; font-style:normal; font-weight:normal; src:local[(]'☺'[)], url[(]'font001[.]woff'[)] format[(]'woff'[)]; }").Success);
                Assert.AreEqual(2, Directory.GetFiles(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedFonts").Count(f => f.EndsWith(".woff")));
            }
            //ExEnd
        }
        public void ExportEmbeddedImages(bool exportImages)
        {
            //ExStart
            //ExFor:HtmlFixedSaveOptions.ExportEmbeddedImages
            //ExSummary:Shows how to determine where to store images when exporting a document to Html.
            Document doc = new Document(MyDir + "Images.docx");

            // When we export a document with embedded images to .html,
            // Aspose.Words can place the images in two possible locations.
            // Setting the "ExportEmbeddedImages" flag to "true" will store the raw data
            // for all images within the output HTML document, in the "src" attribute of <image> tags.
            // Setting this flag to "false" will create an image file in the local file system for every image,
            // and store all these files in a separate folder.
            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                ExportEmbeddedImages = exportImages
            };

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedImages.html", htmlFixedSaveOptions);

            string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedImages.html");

            if (exportImages)
            {
                Assert.False(File.Exists(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedImages/image001.jpeg"));
                Assert.True(Regex.Match(outDocContents,
                                        "<img class=\"awimg\" style=\"left:0pt; top:0pt; width:493.1pt; height:300.55pt;\" src=\".+\" />").Success);
            }
            else
            {
                Assert.True(File.Exists(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedImages/image001.jpeg"));
                Assert.True(Regex.Match(outDocContents,
                                        "<img class=\"awimg\" style=\"left:0pt; top:0pt; width:493.1pt; height:300.55pt;\" " +
                                        "src=\"HtmlFixedSaveOptions[.]ExportEmbeddedImages/image001[.]jpeg\" />").Success);
            }
            //ExEnd
        }
        public void AddCssClassNamesPrefix()
        {
            //ExStart
            //ExFor:HtmlFixedSaveOptions.CssClassNamesPrefix
            //ExFor:HtmlFixedSaveOptions.SaveFontFaceCssSeparately
            //ExSummary:Shows how to add prefix to all class names in css file.
            Document doc = new Document(MyDir + "Bookmarks.docx");

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                CssClassNamesPrefix       = "myprefix",
                SaveFontFaceCssSeparately = true
            };

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.AddCssClassNamesPrefix.html", htmlFixedSaveOptions);

            string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.AddCssClassNamesPrefix.html");

            Assert.True(Regex.Match(outDocContents,
                                    "<div class=\"myprefixdiv myprefixpage\" style=\"width:595[.]3pt; height:841[.]9pt;\">" +
                                    "<div class=\"myprefixdiv\" style=\"left:85[.]05pt; top:36pt; clip:rect[(]0pt,510[.]25pt,74[.]95pt,-85.05pt[)];\">" +
                                    "<span class=\"myprefixspan myprefixtext001\" style=\"font-size:11pt; left:294[.]73pt; top:0[.]36pt;\">").Success);
            //ExEnd
        }
예제 #14
0
        public void PageFileNameSavingCallback()
        {
            //ExStart
            //ExFor:IPageSavingCallback
            //ExFor:FixedPageSaveOptions.PageSavingCallback
            //ExSummary:Shows how separate pages are saved when a document is exported to fixed page format.
            Document doc = new Document(MyDir + "Rendering.doc");

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions {
                PageIndex = 0, PageCount = doc.PageCount
            };

            htmlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback();

            doc.Save(MyDir + @"\Artifacts\Rendering.html", htmlFixedSaveOptions);

            string[] filePaths = Directory.GetFiles(MyDir + @"\Artifacts\", "Page_*.html");

            for (int i = 0; i < doc.PageCount; i++)
            {
                string file = string.Format(MyDir + @"\Artifacts\Page_{0}.html", i);
                Assert.AreEqual(file, filePaths[i]);//ExSkip
            }
        }
        public void HorizontalAlignment(HtmlFixedPageHorizontalAlignment pageHorizontalAlignment)
        {
            //ExStart
            //ExFor:HtmlFixedSaveOptions.PageHorizontalAlignment
            //ExFor:HtmlFixedPageHorizontalAlignment
            //ExSummary:Shows how to set the horizontal alignment of pages when saving a document to HTML.
            Document doc = new Document(MyDir + "Rendering.docx");

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                PageHorizontalAlignment = pageHorizontalAlignment
            };

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.HorizontalAlignment.html", htmlFixedSaveOptions);

            string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.HorizontalAlignment/styles.css");

            switch (pageHorizontalAlignment)
            {
            case HtmlFixedPageHorizontalAlignment.Center:
                Assert.True(Regex.Match(outDocContents,
                                        "[.]awpage { position:relative; border:solid 1pt black; margin:10pt auto 10pt auto; overflow:hidden; }").Success);
                break;

            case HtmlFixedPageHorizontalAlignment.Left:
                Assert.True(Regex.Match(outDocContents,
                                        "[.]awpage { position:relative; border:solid 1pt black; margin:10pt auto 10pt 10pt; overflow:hidden; }").Success);
                break;

            case HtmlFixedPageHorizontalAlignment.Right:
                Assert.True(Regex.Match(outDocContents,
                                        "[.]awpage { position:relative; border:solid 1pt black; margin:10pt 10pt 10pt auto; overflow:hidden; }").Success);
                break;
            }
            //ExEnd
        }
        public void ExportEmbeddedSvgs(bool exportSvgs)
        {
            //ExStart
            //ExFor:HtmlFixedSaveOptions.ExportEmbeddedSvg
            //ExSummary:Shows how to determine where to store SVG objects when exporting a document to Html.
            Document doc = new Document(MyDir + "Images.docx");

            // When we export a document with SVG objects to .html,
            // Aspose.Words can place these objects in two possible locations.
            // Setting the "ExportEmbeddedSvg" flag to "true" will embed all SVG object raw data
            // within the output HTML, inside <image> tags.
            // Setting this flag to "false" will create a file in the local file system for each SVG object.
            // The HTML will link to each file using the "data" attribute of an <object> tag.
            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                ExportEmbeddedSvg = exportSvgs
            };

            doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedSvgs.html", htmlFixedSaveOptions);

            string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedSvgs.html");

            if (exportSvgs)
            {
                Assert.False(File.Exists(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedSvgs/svg001.svg"));
                Assert.True(Regex.Match(outDocContents,
                                        "<image id=\"image004\" xlink:href=.+/>").Success);
            }
            else
            {
                Assert.True(File.Exists(ArtifactsDir + "HtmlFixedSaveOptions.ExportEmbeddedSvgs/svg001.svg"));
                Assert.True(Regex.Match(outDocContents,
                                        "<object type=\"image/svg[+]xml\" data=\"HtmlFixedSaveOptions.ExportEmbeddedSvgs/svg001[.]svg\"></object>").Success);
            }
            //ExEnd
        }
        public void PageMarginsException()
        {
            HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();

            Assert.That(() => saveOptions.PageMargins = -1, Throws.TypeOf <ArgumentException>());
        }
        public void ExportFormFields(bool exportFormFields)
        {
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertCheckBox("CheckBox", false, 15);

            HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
            {
                SaveFormat = SaveFormat.HtmlFixed,
                ExportEmbeddedCss = true,
                ExportEmbeddedFonts = true,
                ExportEmbeddedImages = true,
                ExportEmbeddedSvg = true,
                ExportFormFields = exportFormFields
            };

            //For assert test result you need to open documents and check that checkbox are clickable in "ExportFormFiels.html" file and are not clickable in "WithoutExportFormFiels.html" file
            if (exportFormFields == true)
            {
                doc.Save(MyDir + "ExportFormFiels.html", htmlFixedSaveOptions);
            }
            else
            {
                doc.Save(MyDir + "WithoutExportFormFiels.html", htmlFixedSaveOptions);
            }
        }
        public void CssPrefix(string cssprefix)
        {
            Document doc = new Document(MyDir + "Bookmark.doc");

            HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
            saveOptions.CssClassNamesPrefix = cssprefix;

            doc.Save(MyDir + @"\Artifacts\cssPrefix_Out.html", saveOptions);

            DocumentHelper.FindTextInFile(MyDir + @"\Artifacts\cssPrefix_Out\styles.css", "div");
        }
        public void HorizontalAlignment(HtmlFixedPageHorizontalAlignment horizontalAlignment)
        {
            Document doc = new Document(MyDir + "Bookmark.doc");

            HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
            saveOptions.PageHorizontalAlignment = horizontalAlignment;

            doc.Save(MyDir + @"\Artifacts\HtmlFixedPageHorizontalAlignment.html", saveOptions);
        }
        public void PageMarginsException()
        {
            Document doc = new Document(MyDir + "Bookmark.doc");

            HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
            Assert.That(() => saveOptions.PageMargins = -1, Throws.TypeOf<ArgumentException>());

            doc.Save(MyDir + @"\Artifacts\HtmlFixedPageMargins.html", saveOptions);
        }
        public void PageMargins(int margin)
        {
            Document doc = new Document(MyDir + "Bookmark.doc");

            HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
            saveOptions.PageMargins = margin;

            doc.Save(MyDir + @"\Artifacts\HtmlFixedPageMargins.html", saveOptions);
        }
예제 #23
0
        public HttpResponseMessage Download(RequestData request)
        {
            Opts.AppName    = "Viewer";
            Opts.FileName   = request.fileName;
            Opts.FolderName = request.folderName;
            Opts.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            try
            {
                if (Opts.FolderName.Contains(".."))
                {
                    throw new Exception("Break-in attempt");
                }

                if (string.IsNullOrEmpty(request.outputType))
                {
                    request.outputType = Path.GetExtension(Opts.FileName);
                }
                var fn         = Path.GetFileNameWithoutExtension(Opts.FileName) + request.outputType;
                var resultfile = Config.Configuration.OutputDirectory + Opts.FolderName + "/" + fn;
                if (!File.Exists(resultfile))
                {
                    if (string.IsNullOrEmpty(request.outputType) ||
                        Path.GetExtension(Opts.FileName).ToLower() == Path.GetExtension(request.outputType).ToLower())
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(resultfile));
                        File.Copy(Opts.WorkingFileName, resultfile);
                    }
                    else
                    {
                        var doc = new Document(Opts.WorkingFileName);
                        switch (request.outputType.ToLower())
                        {
                        case ".html":
                            var so = new HtmlFixedSaveOptions()
                            {
                                ExportEmbeddedFonts  = true,
                                ExportEmbeddedImages = true,
                                ExportEmbeddedCss    = true,
                                ShowPageBorder       = false,
                                Encoding             = UTF8WithoutBom
                            };
                            doc.Save(resultfile, so);
                            break;

                        default:
                            doc.Save(resultfile);
                            break;
                        }
                    }
                }

                var response = new Response()
                {
                    FileName   = HttpUtility.UrlEncode(fn),
                    FolderName = Opts.FolderName,
                    StatusCode = 200
                };
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                return(ExceptionResponse(ex));
            }
        }