示例#1
0
        public static void Run()
        {
            var apiInstance = new InfoApi(Constants.GetConfig());

            try
            {
                var viewOptions = new ViewOptions
                {
                    FileInfo = new FileInfo
                    {
                        FilePath = "SampleFiles/with_folders.zip"
                    }
                };

                var response = apiInstance.GetInfo(new GetInfoRequest(viewOptions));
                foreach (var folder in response.ArchiveViewInfo.Folders)
                {
                    Console.WriteLine(folder);
                }
                Console.WriteLine("GetInfoForArchiveFile completed: " + response.Pages.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new InfoApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath    = "containers/archive/zip.zip",
                    StorageName = Common.MyStorage
                };

                var options = new ContainerOptions
                {
                    FileInfo = fileInfo
                };

                var request  = new ContainerRequest(options);
                var response = apiInstance.Container(request);

                foreach (var item in response.ContainerItems)
                {
                    Console.WriteLine($"Name: {item.Name}. FilePath: {item.FilePath}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }
示例#3
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new InfoApi(configuration);

            try
            {
                var viewOptions = new ViewOptions()
                {
                    FileInfo = new FileInfo()
                    {
                        FilePath    = "viewerdocs/with-hidden-rows-and-columns.xlsx",
                        Password    = "",
                        StorageName = Common.MyStorage
                    },
                    RenderOptions = new RenderOptions()
                    {
                        SpreadsheetOptions = new SpreadsheetOptions()
                        {
                            PaginateSheets   = true,
                            CountRowsPerPage = 5
                        }
                    }
                };

                var request = new GetInfoRequest(viewOptions);

                var response = apiInstance.GetInfo(request);
                Console.WriteLine("Expected response type is InfoResult: " + response.Pages.Count.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }
        public void BeforeAllTests()
        {
            var config = new Configuration(_appSid, _appKey)
            {
                ApiBaseUrl = _apiBaseUrl
            };

            SignatureApi = new SignApi(config);
            InfoApi      = new InfoApi(config);
            FileApi      = new FileApi(config);
            FolderApi    = new FolderApi(config);
            StorageApi   = new StorageApi(config);

            //Prepare folder for signed files
            DownloadFolder = Path.Combine(GetTestDataPath(), "Downloaded");
            if (Directory.Exists(DownloadFolder))
            {
                ClearFolder(DownloadFolder);
            }
            else
            {
                Directory.CreateDirectory(DownloadFolder);
            }

            UploadTestFiles();
        }
示例#5
0
        public void TestGetInfoWithImageViewOptions()
        {
            // Arrange
            var testFile    = TestFiles.OnePageDocx;
            var viewOptions = new ViewOptions
            {
                FileInfo      = testFile.ToFileInfo(),
                ViewFormat    = ViewOptions.ViewFormatEnum.PNG,
                RenderOptions = new ImageOptions {
                    ExtractText = true
                }
            };

            var request = new GetInfoRequest(viewOptions);

            // Act & Assert
            var infoResult = InfoApi.GetInfo(request);

            Assert.AreEqual(1, infoResult.Pages.Count);
            Assert.AreEqual(0, infoResult.Attachments.Count);

            var page = infoResult.Pages[0];

            Assert.AreEqual(1, page.Number);
            Assert.Greater(page.Lines.Count, 0);
        }
示例#6
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new InfoApi(configuration);

            try
            {
                var viewOptions = new ViewOptions()
                {
                    FileInfo = new FileInfo()
                    {
                        FilePath    = "viewerdocs/password-protected.docx",
                        Password    = "******",
                        StorageName = Common.MyStorage
                    }
                };

                var request = new GetInfoRequest(viewOptions);

                var response = apiInstance.GetInfo(request);
                Console.WriteLine("Expected response type is InfoResult: " + response.Pages.Count.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }
示例#7
0
        public static void Run()
        {
            var apiInstance = new InfoApi(Constants.GetConfig());

            try
            {
                var viewOptions = new ViewOptions
                {
                    FileInfo = new FileInfo
                    {
                        FilePath = "SampleFiles/sample.docx"
                    },
                    ViewFormat    = ViewOptions.ViewFormatEnum.PNG,
                    RenderOptions = new ImageOptions
                    {
                        ExtractText = true
                    }
                };

                var response = apiInstance.GetInfo(new GetInfoRequest(viewOptions));
                foreach (var line in response.Pages[0].Lines.Take(3))
                {
                    Console.WriteLine($"x: {line.X}; y: {line.Y}; text: {line.Value}");
                }
                Console.WriteLine("...");
                Console.WriteLine("ImageViewerGetTextCoordinates completed");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }
示例#8
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new InfoApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath    = "words-processing/docx/password-protected.docx",
                    Password    = "******",
                    StorageName = Common.MyStorage
                };

                var options = new InfoOptions()
                {
                    FileInfo = fileInfo
                };

                var request = new GetInfoRequest(options);

                var response = apiInstance.GetInfo(request);
                Console.WriteLine("InfoResult.PageCount: " + response.PageCount);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }
示例#9
0
        public JsonResult Get()
        {
            var filename = "testbarcode.png";
            var version  = GetType().Assembly.GetName().Version;

            var barcodeConfig = new Aspose.BarCode.Cloud.Sdk.Api.Configuration()
            {
                AppKey = _configuration.GetValue <string>("Settings:AsposeCloudAppKey"),
                AppSid = _configuration.GetValue <string>("Settings:AsposeCloudAppSid")
            };

            barcodeConfig.DefaultHeaders.Add(AsposeClientHeaderName, "test proxy app");
            barcodeConfig.DefaultHeaders.Add(AsposeClientVersionHeaderName, $"{version.Major}.{version.Minor}");

            IBarcodeApi barcodeApi      = new Aspose.BarCode.Cloud.Sdk.Api.BarcodeApi(barcodeConfig);
            var         groupdocsConfig = new GroupDocs.Conversion.Cloud.Sdk.Client.Configuration(
                _configuration.GetValue <string>("Settings:GroupdocsCloudAppSid"), _configuration.GetValue <string>("Settings:GroupdocsCloudAppKey"));
            var infoApi = new InfoApi(groupdocsConfig);

            var barcodeResponse = barcodeApi.PutBarcodeGenerateFile(new Aspose.BarCode.Cloud.Sdk.Model.Requests.PutBarcodeGenerateFileRequest(
                                                                        text: "TEST", type: "qr", format: "PNG", textLocation: "None", name: filename, storage: null, folder: null));

            var supportedFileFormatsResponse = infoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest(format: System.IO.Path.GetExtension(filename)?.Trim('.')));

            return(new JsonResult(new
            {
                filename = filename,
                width = barcodeResponse.ImageWidth,
                height = barcodeResponse.ImageHeight,
                canBeConvertedTo = supportedFileFormatsResponse != null && supportedFileFormatsResponse.Any() ? supportedFileFormatsResponse[0].TargetFormats : null
            }));
        }
示例#10
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new InfoApi(configuration);

            try
            {
                var viewOptions = new ViewOptions()
                {
                    FileInfo = new FileInfo()
                    {
                        FilePath    = "viewerdocs/one-page.docx",
                        Password    = "",
                        StorageName = Common.MyStorage
                    },
                    RenderOptions = new ImageOptions()
                    {
                        ExtractText = true
                    },
                    ViewFormat = ViewOptions.ViewFormatEnum.PNG
                };

                var request = new GetInfoRequest(viewOptions);

                var response = apiInstance.GetInfo(request);
                Console.WriteLine("Expected response type is InfoResult: " + response.Pages.Count.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling InfoApi: " + e.Message);
            }
        }
示例#11
0
        public void TestGetInfoWithProjectOptions()
        {
            // Arrange
            var testFile    = TestFiles.ProjectMpp;
            var viewOptions = new ViewOptions
            {
                FileInfo      = testFile.ToFileInfo(),
                RenderOptions = new RenderOptions
                {
                    ProjectManagementOptions = new ProjectManagementOptions
                    {
                        PageSize  = ProjectManagementOptions.PageSizeEnum.Unspecified,
                        TimeUnit  = ProjectManagementOptions.TimeUnitEnum.Months,
                        StartDate = new DateTime(2008, 7, 1),
                        EndDate   = new DateTime(2008, 7, 31)
                    }
                }
            };
            var request = new GetInfoRequest(viewOptions);

            // Act & Assert
            var infoResult = InfoApi.GetInfo(request);

            Assert.IsTrue(infoResult.Pages.Count == 1 || infoResult.Pages.Count == 2);
        }
        public static void Run()
        {
            var apiInstance = new InfoApi(Constants.GetConfig());

            // Get supported file formats
            var response = apiInstance.GetSupportedFileFormats();

            Console.WriteLine("GetSupportedFormats: formats count = " + response.Formats.Count);
        }
        public void TestGetInfoReturnsMissingFileInfo()
        {
            // Arrange
            var request = new GetInfoRequest(null);

            // Act & Assert
            Assert.Throws <ApiException>(() => {
                InfoApi.GetInfo(request);
            });
        }
示例#14
0
        public void TestGetInfo()
        {
            // Arrange
            var request = new GetDocumentInfoRequest(TestFiles.SourceWord.ToFileInfo());

            // Act & Assert
            var infoResult = InfoApi.GetDocumentInfo(request);

            Assert.AreEqual(1, infoResult.PageCount);
        }
示例#15
0
        public void InfoApiTest_FileNotFoundResult()
        {
            var options = new InfoOptions {
                FileInfo = TestFiles.NotExist.ToFileInfo()
            };
            var request = new GetInfoRequest(options);

            var ex = Assert.Throws <ApiException>(() => { InfoApi.GetInfo(request); });

            Assert.AreEqual($"Can't find file located at '{TestFiles.NotExist.FullName}'.", ex.Message);
        }
        public void GetSupportedQrCodeFormats()
        {
            var response = InfoApi.GetSupportedQRCodes();

            Assert.IsTrue(response.QRCodeTypes.Count > 0);
            foreach (var format in response.QRCodeTypes)
            {
                Assert.IsNotNull(format.Name);
                Assert.IsNotEmpty(format.Name);
            }
        }
        public void GetSupportedConversionTypesTest()
        {
            var response = InfoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest());

            Assert.IsTrue(response.Count > 0);
            foreach (var entry in response)
            {
                Assert.IsNotEmpty(entry.SourceFormat);
                Assert.IsTrue(entry.TargetFormats.Count > 0);
            }
        }
示例#18
0
        public void GetSupportedFileFormatsTest()
        {
            var response = InfoApi.GetSupportedFileFormats();

            Assert.IsTrue(response.Formats.Count > 0);
            foreach (var entry in response.Formats)
            {
                Assert.IsNotEmpty(entry.Extension);
                Assert.IsNotEmpty(entry.FileFormat);
            }
        }
        public void TestPostInfoWithPassword()
        {
            // Arrange
            var fileInfo = TestFiles.PasswordProtectedDocx.ToFileInfo();

            var request = new GetInfoRequest(fileInfo);

            // Act & Assert
            var infoResult = InfoApi.GetInfo(request);

            Assert.AreEqual(4, infoResult.PageCount);
        }
        public void TestGetInfoReturnsFileNotFound()
        {
            // Arrange
            var fileInfo = TestFiles.NotExist.ToFileInfo();

            var request = new GetInfoRequest(fileInfo);

            // Act & Assert
            Assert.Throws <ApiException>(() => {
                InfoApi.GetInfo(request);
            });
        }
        public void TestPostInfoWithMinimalOptions()
        {
            // Arrange
            var fileInfo = TestFiles.FourPagesDocx.ToFileInfo();

            var request = new GetInfoRequest(fileInfo);

            // Act & Assert
            var infoResult = InfoApi.GetInfo(request);

            Assert.AreEqual(4, infoResult.PageCount);
        }
示例#22
0
        public void InfoApiTest_Not_Supported()
        {
            var testFile = TestFiles.Zip;
            var options  = new InfoOptions {
                FileInfo = testFile.ToFileInfo()
            };
            var request = new GetInfoRequest(options);

            var ex = Assert.Throws <ApiException>(() => { InfoApi.GetInfo(request); });

            Assert.AreEqual($"The specified file '{testFile.FullName}' has type which is not currently supported.", ex.Message);
        }
示例#23
0
        public void TestGetInfoReturnsFileNotFound()
        {
            // Arrange
            var request = new GetDocumentInfoRequest(TestFiles.NotExist.ToFileInfo());

            // Act & Assert
            var ex = Assert.Throws <ApiException>(() => {
                InfoApi.GetDocumentInfo(request);
            });

            Assert.AreEqual("Can't find file located at 'some-folder\\NotExist.docx'.", ex.Message);
        }
示例#24
0
        public static void Run()
        {
            var apiInstance = new InfoApi(Constants.GetConfig());

            var request = new GetInfoRequest(new FileInfo {
                FilePath = "one-page.docx"
            });

            var response = apiInstance.GetInfo(request);

            Console.WriteLine("GetDocumentInfo: pages count = " + response.Pages.Count);
        }
示例#25
0
        public void TestGetInfoReturnsMissingFileInfo()
        {
            // Arrange
            var request = new GetDocumentInfoRequest();

            // Act & Assert
            var ex = Assert.Throws <ApiException>(() => {
                InfoApi.GetDocumentInfo(request);
            });

            Assert.AreEqual("Missing required parameter 'fileInfo' when calling GetDocumentInfo", ex.Message);
        }
示例#26
0
        public void InfoApiTest_Not_Supported()
        {
            var testFile = TestFiles.Json;
            var options  = new InfoOptions {
                FileInfo = testFile.ToFileInfo()
            };
            var request = new GetInfoRequest(options);

            var ex = Assert.Throws <ApiException>(() => { InfoApi.GetInfo(request); });

            Assert.AreEqual($"The file format is not supported at the moment. Basic operations are not implemented for the loaded file", ex.Message);
        }
示例#27
0
        public void InfoHandlerTest_Slides()
        {
            var options = new InfoOptions {
                FileInfo = TestFiles.Pptx.ToFileInfo()
            };
            var request = new GetInfoRequest(options);

            var result = InfoApi.GetInfo(request);

            Assert.IsNotNull(result);
            Assert.AreEqual("PRESENTATION", result.FileType.FileFormat.ToUpper());
            Assert.AreEqual(1, result.PageCount);
        }
示例#28
0
        public void InfoHandlerTest_Docx()
        {
            var options = new InfoOptions {
                FileInfo = TestFiles.Docx.ToFileInfo()
            };
            var request = new GetInfoRequest(options);

            var result = InfoApi.GetInfo(request);

            Assert.IsNotNull(result);
            Assert.AreEqual("APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.WORDPROCESSINGML.DOCUMENT", result.FileType.MimeType.ToUpper());
            Assert.AreEqual(1, result.PageCount);
        }
示例#29
0
        public void InfoHandlerTest_Xlsx()
        {
            var options = new InfoOptions {
                FileInfo = TestFiles.Xlsx.ToFileInfo()
            };
            var request = new GetInfoRequest(options);

            var result = InfoApi.GetInfo(request);

            Assert.IsNotNull(result);
            Assert.AreEqual("APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.SPREADSHEETML.SHEET", result.FileType.MimeType.ToUpper());
            Assert.AreEqual(3, result.PageCount);
        }
示例#30
0
        public void InfoHandlerTest_Jpeg()
        {
            var options = new InfoOptions {
                FileInfo = TestFiles.Jpg.ToFileInfo()
            };
            var request = new GetInfoRequest(options);

            var result = InfoApi.GetInfo(request);

            Assert.IsNotNull(result);
            Assert.AreEqual("IMAGE/JPEG", result.FileType.MimeType.ToUpper());
            Assert.AreEqual(1, result.PageCount);
        }