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); } }
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 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); } }
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); } }
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 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 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); }
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); } }
public void TestGetInfoReturnsMissingFileInfo() { // Arrange var request = new GetInfoRequest(null); // Act & Assert Assert.Throws <ApiException>(() => { InfoApi.GetInfo(request); }); }
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 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); }
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); }
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); }
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); }
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 TestGetInfoReturnsMissingFileInfo() { // Arrange var request = new GetInfoRequest(); // Act & Assert var ex = Assert.Throws <ApiException>(() => { InfoApi.GetInfo(request); }); Assert.AreEqual("Missing required parameter 'fileInfo' when calling GetInfo", ex.Message); }
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); }
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); }
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); }
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); }
public void InfoApiTest_Pdf() { var options = new InfoOptions { FileInfo = TestFiles.Pdf.ToFileInfo() }; var request = new GetInfoRequest(options); var result = InfoApi.GetInfo(request); Assert.IsNotNull(result); Assert.AreEqual("PORTABLE DOCUMENT FORMAT FILE", result.FileType.FileFormat.ToUpper()); Assert.AreEqual(2, result.PageCount); }
public void InfoApiTest_Visio() { var options = new InfoOptions { FileInfo = TestFiles.Visio.ToFileInfo() }; var request = new GetInfoRequest(options); var result = InfoApi.GetInfo(request); Assert.IsNotNull(result); Assert.AreEqual("VISIO DRAWING", result.FileType.FileFormat.ToUpper()); Assert.AreEqual(1665923L, result.Size); }
public void InfoApiTest_Pptx() { var options = new InfoOptions { FileInfo = TestFiles.Pptx.ToFileInfo() }; var request = new GetInfoRequest(options); var result = InfoApi.GetInfo(request); Assert.IsNotNull(result); Assert.AreEqual("POWERPOINT OPEN XML PRESENTATION", result.FileType.FileFormat.ToUpper()); Assert.AreEqual(3, result.PageCount); }
public void InfoApiTest_Xlsx() { var options = new InfoOptions { FileInfo = TestFiles.Xlsx.ToFileInfo() }; var request = new GetInfoRequest(options); var result = InfoApi.GetInfo(request); Assert.IsNotNull(result); Assert.AreEqual("MICROSOFT EXCEL OPEN XML SPREADSHEET", result.FileType.FileFormat.ToUpper()); Assert.AreEqual(3, result.PageCount); }
public void TestGetInfo(string filePath, string password = null) { var fileInfo = new Model.FileInfo { FilePath = filePath, Password = password }; var request = new GetInfoRequest(fileInfo); var info = InfoApi.GetInfo(request); Assert.NotNull(info); Assert.AreEqual(filePath, info.Path); }
public void InfoApiTest_Word() { var options = new InfoOptions { FileInfo = TestFiles.Docx.ToFileInfo() }; var request = new GetInfoRequest(options); var result = InfoApi.GetInfo(request); Assert.IsNotNull(result); Assert.AreEqual("MICROSOFT WORD OPEN XML DOCUMENT", result.FileType.FileFormat.ToUpper()); Assert.AreEqual(2, result.PageCount); }
public void InfoApiTest_Msg() { var options = new InfoOptions { FileInfo = TestFiles.Msg.ToFileInfo() }; var request = new GetInfoRequest(options); var result = InfoApi.GetInfo(request); Assert.IsNotNull(result); Assert.AreEqual("OUTLOOK MAIL MESSAGE", result.FileType.FileFormat.ToUpper()); Assert.AreEqual(4090880L, result.Size); }
public void TestGetInfoReturnsFileNotFound() { // Arrange var infoSettings = new InfoSettings { FileInfo = TestFiles.NotExist.GetFileInfo() }; var request = new GetInfoRequest(infoSettings); // Act & Assert var ex = Assert.Throws <ApiException>(() => { InfoApi.GetInfo(request); }); Assert.AreEqual("Can't find file located at 'some-folder\\NotExist.docx'.", ex.Message); }
public void TestGetInfoWithMinimalViewOptions() { // Arrange var viewOptions = new ViewOptions { FileInfo = TestFiles.PasswordProtectedDocx.ToFileInfo() }; var request = new GetInfoRequest(viewOptions); // Act & Assert var infoResult = InfoApi.GetInfo(request); Assert.AreEqual(4, infoResult.Pages.Count); Assert.AreEqual(0, infoResult.Attachments.Count); }