public void ImageGetPageWithExtractTextTest()
        {
            var file       = TestFiles.OnePageDocx;
            var pageNumber = 1;

            var request = new ImageGetPageRequest
            {
                FileName          = file.FileName,
                PageNumber        = pageNumber,
                Format            = null,
                Width             = null,
                Height            = null,
                Quality           = null,
                Password          = null,
                ExtractText       = true,
                RenderComments    = null,
                RenderHiddenPages = null,
                DefaultFontName   = null,
                FontsFolder       = null,
                Folder            = file.Folder,
                Storage           = null
            };

            var response = ViewerApi.ImageGetPage(request);

            Assert.IsInstanceOf <System.IO.Stream>(response, "Expected response type is System.IO.Stream");
            Assert.IsTrue(response.Length > 0);
        }
        public void ImageGetPagesFromUrlTest()
        {
            var file = TestFiles.FromUrlWithNotesPptx;

            var request = new ImageGetPagesFromUrlRequest
            {
                Url               = file.Url,
                FileName          = file.FileName,
                Format            = null,
                Width             = null,
                Height            = null,
                Quality           = null,
                StartPageNumber   = null,
                CountPages        = null,
                Password          = null,
                ExtractText       = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                DefaultFontName   = null,
                FontsFolder       = null,
                Folder            = FromUrlFolder,
                Storage           = null
            };

            var response = ViewerApi.ImageGetPagesFromUrl(request);

            Assert.AreEqual("with-notes.pptx", response.FileName);
            Assert.AreEqual(1, response.Pages.Count);
        }
示例#3
0
        public void HtmlGetPagesFromUrlTest()
        {
            var file = TestFiles.FromUrlWithNotesPptx;

            var request = new HtmlGetPagesFromUrlRequest
            {
                Url          = file.Url,
                FileName     = file.FileName,
                ResourcePath = null,
                IgnoreResourcePathInResources = null,
                EmbedResources    = null,
                StartPageNumber   = null,
                CountPages        = null,
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                DefaultFontName   = null,
                FontsFolder       = null,
                Folder            = FromUrlFolder,
                Storage           = null,
            };

            var response = ViewerApi.HtmlGetPagesFromUrl(request);

            Assert.AreEqual("with-notes.pptx", response.FileName);
            Assert.AreEqual(1, response.Pages.Count);
        }
示例#4
0
        public void ImageGetZipWithImageAttachmentPagesTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var request = new ImageGetZipWithAttachmentPagesRequest
            {
                FileName           = file.FileName,
                AttachmentName     = file.AttachmentName,
                Format             = null,
                Width              = null,
                Height             = null,
                Quality            = null,
                StartPageNumber    = null,
                CountPages         = null,
                RenderComments     = null,
                RenderHiddenPages  = null,
                Password           = null,
                AttachmentPassword = file.AttachmentPassword,
                ExtractText        = null,
                DefaultFontName    = null,
                FontsFolder        = null,
                Folder             = file.Folder,
                Storage            = null
            };

            var response = ViewerApi.ImageGetZipWithAttachmentPages(request);

            Assert.IsInstanceOf <System.IO.Stream>(response, "Expected response type is System.IO.Stream");
            Assert.IsTrue(response.Length > 0);
        }
示例#5
0
        public void HtmlGetZipWithPagesTest()
        {
            var file = TestFiles.FourPagesDocx;

            var request = new HtmlGetZipWithPagesRequest
            {
                FileName     = file.FileName,
                ResourcePath = null,
                IgnoreResourcePathInResources = null,
                EmbedResources    = null,
                StartPageNumber   = null,
                CountPages        = null,
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                DefaultFontName   = null,
                FontsFolder       = null,
                Folder            = file.Folder,
                Storage           = null,
            };

            var response = ViewerApi.HtmlGetZipWithPages(request);

            Assert.IsInstanceOf <System.IO.Stream>(response, "Expected response type is System.IO.Stream");
            Assert.IsTrue(response.Length > 0);
        }
        public void ImageGetDocumentInfoWithExtractTextTest()
        {
            var file = TestFiles.OnePageDocx;

            var request = new ImageGetDocumentInfoRequest
            {
                FileName          = file.FileName,
                Password          = null,
                ExtractText       = true,
                RenderComments    = null,
                RenderHiddenPages = null,
                Folder            = file.Folder,
                Storage           = null
            };

            var response = ViewerApi.ImageGetDocumentInfo(request);

            Assert.AreEqual("one-page.docx", response.FileName);
            Assert.AreEqual(".docx", response.Extension);
            Assert.AreEqual(1, response.Pages.Count);

            Assert.IsTrue(response.Pages[0].Rows.Count > 0);
            foreach (var row in response.Pages[0].Rows)
            {
                Assert.IsNotEmpty(row.Text);
                Assert.IsTrue(row.RowHeight > 0);
                Assert.IsTrue(row.RowWidth > 0);
                Assert.IsTrue(row.RowLeft > 0);
                Assert.IsTrue(row.RowTop > 0);
                Assert.IsTrue(row.TextCoordinates.Count > 0);
                Assert.IsTrue(row.CharacterCoordinates.Count > 0);
            }
        }
示例#7
0
        public void HtmlGetPagesTest()
        {
            var file = TestFiles.FourPagesDocx;

            var request = new HtmlGetPagesRequest
            {
                FileName     = file.FileName,
                ResourcePath = null,
                IgnoreResourcePathInResources = null,
                EmbedResources    = null,
                StartPageNumber   = null,
                CountPages        = null,
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                DefaultFontName   = null,
                FontsFolder       = null,
                Folder            = file.Folder,
                Storage           = null,
            };

            var response = ViewerApi.HtmlGetPages(request);

            Assert.AreEqual("four-pages.docx", response.FileName);
            Assert.AreEqual("words\\docx", response.Folder);
            Assert.AreEqual(4, response.Pages.Count);
        }
示例#8
0
        public void HtmlGetPageWithCustomFontTest()
        {
            var file       = TestFiles.UsesCustomFontPptx;
            var pageNumber = 1;

            var request = new HtmlGetPageRequest
            {
                FileName     = file.FileName,
                PageNumber   = pageNumber,
                ResourcePath = null,
                IgnoreResourcePathInResources = null,
                EmbedResources    = true,
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                DefaultFontName   = null,
                FontsFolder       = "fonts",
                Folder            = file.Folder,
                Storage           = null,
            };

            var response = ViewerApi.HtmlGetPage(request);

            Assert.IsInstanceOf <System.IO.Stream>(response, "Expected response type is System.IO.Stream");
            Assert.IsTrue(response.Length > 0);
        }
示例#9
0
        public void HtmlGetAttachmentPageResourceTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var pagesCollection = GetPageCollection(file);
            var page            = pagesCollection.Pages[0];

            foreach (var resource in page.Resources)
            {
                var request = new HtmlGetAttachmentPageResourceRequest
                {
                    FileName       = file.FileName,
                    AttachmentName = file.AttachmentName,
                    PageNumber     = page.Number,
                    ResourceName   = resource.Name,
                    Folder         = file.Folder,
                    Storage        = null,
                };

                var response = ViewerApi.HtmlGetAttachmentPageResource(request);

                Assert.IsInstanceOf <System.IO.Stream>(response, "Expected response type is System.IO.Stream");
                Assert.IsTrue(response.Length > 0);
            }
        }
示例#10
0
        private HtmlAttachmentPageCollection GetPageCollection(TestFile file)
        {
            var request = new HtmlGetAttachmentPagesRequest
            {
                FileName       = file.FileName,
                AttachmentName = file.AttachmentName,
                ResourcePath   = null,
                IgnoreResourcePathInResources = null,
                EmbedResources     = false,
                StartPageNumber    = 1,
                CountPages         = 1,
                RenderComments     = null,
                RenderHiddenPages  = null,
                Password           = null,
                AttachmentPassword = file.AttachmentPassword,
                DefaultFontName    = null,
                FontsFolder        = null,
                Folder             = file.Folder,
                Storage            = null,
            };

            var response = ViewerApi.HtmlGetAttachmentPages(request);

            Assert.IsInstanceOf <HtmlAttachmentPageCollection>(response, "Expected response type is HtmlAttachmentPageCollection");

            return(response);
        }
示例#11
0
        public void HtmlGetAttachmentPagesTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var request = new HtmlGetAttachmentPagesRequest
            {
                FileName       = file.FileName,
                AttachmentName = file.AttachmentName,
                ResourcePath   = null,
                IgnoreResourcePathInResources = null,
                EmbedResources     = null,
                StartPageNumber    = null,
                CountPages         = null,
                RenderComments     = null,
                RenderHiddenPages  = null,
                Password           = null,
                AttachmentPassword = file.AttachmentPassword,
                DefaultFontName    = null,
                FontsFolder        = null,
                Folder             = file.Folder,
                Storage            = null,
            };

            var response = ViewerApi.HtmlGetAttachmentPages(request);

            Assert.AreEqual(1, response.Pages.Count);
            Assert.AreEqual("with-attachment.msg", response.FileName);
            Assert.AreEqual("password-protected.docx", response.AttachmentName);
            Assert.AreEqual("email\\msg", response.Folder);
        }
示例#12
0
        public void ImageGetAttachmentPagesTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var request = new ImageGetAttachmentPagesRequest
            {
                FileName           = file.FileName,
                AttachmentName     = file.AttachmentName,
                Format             = null,
                Width              = null,
                Height             = null,
                Quality            = null,
                StartPageNumber    = null,
                CountPages         = null,
                RenderComments     = null,
                RenderHiddenPages  = null,
                Password           = null,
                AttachmentPassword = file.AttachmentPassword,
                ExtractText        = null,
                DefaultFontName    = null,
                FontsFolder        = null,
                Folder             = file.Folder,
                Storage            = null
            };

            var response = ViewerApi.ImageGetAttachmentPages(request);

            Assert.AreEqual(1, response.Pages.Count);
            Assert.AreEqual("with-attachment.msg", response.FileName);
            Assert.AreEqual("password-protected.docx", response.AttachmentName);
            Assert.AreEqual("email\\msg", response.Folder);
        }
        public void ImageGetPagesTest()
        {
            var file = TestFiles.FourPagesDocx;

            var request = new ImageGetPagesRequest
            {
                FileName          = file.FileName,
                Format            = null,
                Width             = null,
                Height            = null,
                Quality           = null,
                StartPageNumber   = null,
                CountPages        = null,
                Password          = null,
                ExtractText       = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                DefaultFontName   = null,
                FontsFolder       = file.Folder,
                Folder            = file.Folder,
                Storage           = null
            };

            var response = ViewerApi.ImageGetPages(request);

            Assert.AreEqual("four-pages.docx", response.FileName);
            Assert.AreEqual("words\\docx", response.Folder);
            Assert.AreEqual(4, response.Pages.Count);
        }
        public void ImageCreatePdfFileFromContentTest()
        {
            var file           = TestFiles.PasswordProtectedDocx;
            var pdfFileOptions = new PdfFileOptions
            {
                Password = file.Password
            };

            var request = new ImageCreatePdfFileFromContentRequest
            {
                PdfFileOptions = this.SerializeObject(pdfFileOptions),
                File           = this.GetTestFileStream(file),
                FileName       = null,
                FontsFolder    = null,
                Folder         = FromContentFolder,
                Storage        = null
            };

            var response = ViewerApi.ImageCreatePdfFileFromContent(request);

            Assert.IsNotEmpty(response.FileName);
            Assert.IsNotEmpty(response.Folder);
            Assert.IsNotEmpty(response.PdfFileName);
            Assert.IsNotEmpty(response.Url);
        }
        public void GetFontsTest()
        {
            var request = new GetFontsRequest();

            var response = ViewerApi.GetFonts(request);

            Assert.IsTrue(response.Families.Count > 0);
            foreach (var entry in response.Families)
            {
                Assert.IsNotEmpty(entry.Name);
            }
        }
示例#16
0
        public void GetSupportedFileFormatsTest()
        {
            var request = new GetSupportedFileFormatsRequest();

            var response = ViewerApi.GetSupportedFileFormats(request);

            Assert.IsTrue(response.Formats.Count > 0);
            foreach (var entry in response.Formats)
            {
                Assert.IsNotEmpty(entry.Extension);
                Assert.IsNotEmpty(entry.FileFormat);
            }
        }
示例#17
0
        public void HtmlDeletePagesCacheTest()
        {
            var file = TestFiles.FourPagesDocx;

            var request = new HtmlDeletePagesCacheRequest
            {
                FileName = file.FileName,
                Folder   = file.Folder,
                Storage  = null,
            };

            ViewerApi.HtmlDeletePagesCache(request);
        }
示例#18
0
        public void ImageDeleteAttachmentPagesCacheTest()
        {
            var file = TestFiles.WithAttachmentPdf;

            var request = new ImageDeleteAttachmentPagesCacheRequest
            {
                FileName       = file.FileName,
                AttachmentName = file.AttachmentName,
                Folder         = file.Folder,
                Storage        = null
            };

            ViewerApi.ImageDeleteAttachmentPagesCache(request);
        }
        public void HtmlGetAttachmentsFromPdfTest()
        {
            var file = TestFiles.WithAttachmentPdf;

            var request = new HtmlGetAttachmentsRequest
            {
                FileName = file.FileName,
                Folder   = file.Folder,
                Storage  = null
            };

            var response = ViewerApi.HtmlGetAttachments(request);

            Assert.AreEqual(1, response.Attachments.Count);
            Assert.AreEqual("password-protected.docx", response.Attachments[0].Name);
        }
        public void HtmlGetAttachmentFromPdfTest()
        {
            var file = TestFiles.WithAttachmentPdf;

            var request = new HtmlGetAttachmentRequest
            {
                FileName       = file.FileName,
                AttachmentName = file.AttachmentName,
                Folder         = file.Folder,
                Storage        = null
            };

            var response = ViewerApi.HtmlGetAttachment(request);

            Assert.IsInstanceOf <System.IO.Stream>(response, "Expected response type is System.IO.Stream");
            Assert.IsTrue(response.Length > 0);
        }
        public void ImageGetDocumentInfoReturnsFileNotFoundTest()
        {
            var request = new ImageGetDocumentInfoRequest
            {
                FileName          = "file-not-found.docx",
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                Folder            = null,
                Storage           = null,
            };

            var ex = Assert.Throws <ApiException>(() =>
            {
                ViewerApi.ImageGetDocumentInfo(request);
            });

            Assert.AreEqual("Can't find file with given name 'file-not-found.docx' and folder ''.", ex.Message);
        }
        public void ImageGetDocumentInfoFromUrlWithOptionsTest()
        {
            var file = TestFiles.FromUrlOnePageDocx;
            var documentInfoOptions = new DocumentInfoOptions();

            var request = new ImageGetDocumentInfoFromUrlWithOptionsRequest
            {
                Url = file.Url,
                DocumentInfoOptions = documentInfoOptions,
                FileName            = null,
                Folder  = FromUrlFolder,
                Storage = null
            };

            var response = ViewerApi.ImageGetDocumentInfoFromUrlWithOptions(request);

            Assert.IsInstanceOf <DocumentInfo>(response, "Expected response type is DocumentInfo");
            Assert.AreEqual(".docx", response.Extension);
        }
示例#23
0
        public void HtmlRotatePageTest()
        {
            var file = TestFiles.FourPagesDocx;

            var request = new HtmlTransformPagesRequest
            {
                FileName         = file.FileName,
                TransformOptions = new RotateOptions
                {
                    PageNumber = 1,
                    Angle      = 90
                },
                Folder  = file.Folder,
                Storage = null,
            };

            var response = ViewerApi.HtmlTransformPages(request);

            Assert.AreEqual(90, response.Pages[0].Angle);
        }
        public void HtmlGetInfoFromUrlReturnsInvalidUrlTest()
        {
            var request = new HtmlGetDocumentInfoFromUrlRequest
            {
                Url               = "invalid-url",
                FileName          = null,
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                Folder            = null,
                Storage           = null
            };

            var ex = Assert.Throws <ApiException>(() =>
            {
                ViewerApi.HtmlGetDocumentInfoFromUrl(request);
            });

            Assert.AreEqual("Can't parse specified URL 'invalid-url'.", ex.Message);
        }
        public void HtmlGetAttachmentInfoTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var request = new HtmlGetAttachmentInfoRequest
            {
                FileName           = file.FileName,
                AttachmentName     = file.AttachmentName,
                Password           = null,
                AttachmentPassword = file.AttachmentPassword,
                Folder             = file.Folder,
                Storage            = null,
            };

            var response = ViewerApi.HtmlGetAttachmentInfo(request);

            Assert.AreEqual(1, response.Pages.Count);
            Assert.AreEqual(".docx", response.Extension);
            Assert.AreEqual("password-protected.docx", response.FileName);
        }
        public void HtmlGetInfoTest()
        {
            var file = TestFiles.FourPagesDocx;

            var request = new HtmlGetDocumentInfoRequest
            {
                FileName          = file.FileName,
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = null,
                Folder            = file.Folder,
                Storage           = null,
            };

            var response = ViewerApi.HtmlGetDocumentInfo(request);

            Assert.AreEqual("four-pages.docx", response.FileName);
            Assert.AreEqual(".docx", response.Extension);
            Assert.AreEqual(4, response.Pages.Count);
        }
        public void ImageGetDocumentInfoWithRenderHiddenPagesTest()
        {
            var file = TestFiles.TwoHiddenPagesVsd;

            var request = new ImageGetDocumentInfoRequest
            {
                FileName          = file.FileName,
                Password          = null,
                RenderComments    = null,
                RenderHiddenPages = true,
                Folder            = file.Folder,
                Storage           = null,
            };

            var response = ViewerApi.ImageGetDocumentInfo(request);

            Assert.AreEqual("two-hidden-pages.vsd", response.FileName);
            Assert.AreEqual(".vsd", response.Extension);
            Assert.AreEqual(3, response.Pages.Count);
        }
        public void HtmlGetAttachmentInfoReturnsInvalidPasswordTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var request = new HtmlGetAttachmentInfoRequest
            {
                FileName           = file.FileName,
                AttachmentName     = file.AttachmentName,
                Password           = null,
                AttachmentPassword = "******",
                Folder             = file.Folder,
                Storage            = null,
            };

            var ex = Assert.Throws <ApiException>(() =>
            {
                ViewerApi.HtmlGetAttachmentInfo(request);
            });

            Assert.AreEqual("Password provided for file with name 'password-protected.docx' is incorrect.", ex.Message);
        }
        public void HtmlGetAttachmentInfoReturnsPasswordNotProvidedTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var request = new HtmlGetAttachmentInfoRequest
            {
                FileName           = file.FileName,
                AttachmentName     = file.AttachmentName,
                Password           = null,
                AttachmentPassword = null,
                Folder             = file.Folder,
                Storage            = null,
            };

            var ex = Assert.Throws <ApiException>(() =>
            {
                ViewerApi.HtmlGetAttachmentInfo(request);
            });

            Assert.AreEqual("The password was not provided. The specified file 'password-protected.docx' is password-protected.", ex.Message);
        }
        public void HtmlGetAttachmentInfoReturnsAttachmentNotFoundTest()
        {
            var file = TestFiles.WithAttachmentMsg;

            var request = new HtmlGetAttachmentInfoRequest
            {
                FileName           = file.FileName,
                AttachmentName     = "not-found.pdf",
                Password           = null,
                AttachmentPassword = null,
                Folder             = file.Folder,
                Storage            = null,
            };

            var ex = Assert.Throws <ApiException>(() =>
            {
                ViewerApi.HtmlGetAttachmentInfo(request);
            });

            Assert.AreEqual("Can't find attachment with given name 'not-found.pdf'.", ex.Message);
        }