public void TestOpenSaveDocxWithOptions()
        {
            // Load
            var testFile    = TestFiles.PasswordProtectedDocx;
            var loadOptions = new WordProcessingLoadOptions
            {
                FileInfo         = testFile.ToFileInfo(),
                OutputPath       = DefaultOutputPath,
                EnablePagination = true,
                FontExtraction   = WordProcessingLoadOptions.FontExtractionEnum.ExtractAll
            };

            var loadResult = EditApi.Load(new LoadRequest(loadOptions));

            Assert.IsNotEmpty(loadResult.HtmlPath);
            Assert.IsNotEmpty(loadResult.ResourcesPath);

            // Save
            var saveOptions = new WordProcessingSaveOptions
            {
                FileInfo           = testFile.ToFileInfo(),
                HtmlPath           = loadResult.HtmlPath,
                ResourcesPath      = loadResult.ResourcesPath,
                OutputPath         = $"{DefaultOutputPath}/{testFile.FileName}",
                EnablePagination   = true,
                Format             = "Docx",
                Password           = testFile.Password,
                ProtectionPassword = testFile.Password,
                ProtectionType     = WordProcessingSaveOptions.ProtectionTypeEnum.AllowOnlyComments
            };

            var saveResult = EditApi.Save(new SaveRequest(saveOptions));

            Assert.AreEqual(saveOptions.OutputPath, saveResult.Path);
        }
        public void TestOpenSavePresentationWithOptions()
        {
            // Load
            var testFile    = TestFiles.PresentationWithHiddenSlide;
            var loadOptions = new PresentationLoadOptions
            {
                FileInfo         = testFile.ToFileInfo(),
                OutputPath       = DefaultOutputPath,
                ShowHiddenSlides = true,
                SlideNumber      = 0
            };

            var loadResult = EditApi.Load(new LoadRequest(loadOptions));

            Assert.IsNotEmpty(loadResult.HtmlPath);
            Assert.IsNotEmpty(loadResult.ResourcesPath);

            // Save
            var saveOptions = new PresentationSaveOptions
            {
                FileInfo      = testFile.ToFileInfo(),
                HtmlPath      = loadResult.HtmlPath,
                ResourcesPath = loadResult.ResourcesPath,
                OutputPath    = $"{DefaultOutputPath}/{testFile.FileName}",
                Password      = "******"
            };

            var saveResult = EditApi.Save(new SaveRequest(saveOptions));

            Assert.AreEqual(saveOptions.OutputPath, saveResult.Path);
        }
        public void TestOpenSaveDocxProtected()
        {
            // Load
            var testFile    = TestFiles.PasswordProtectedDocx;
            var loadOptions = new LoadOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                OutputPath = DefaultOutputPath
            };

            var loadResult = EditApi.Load(new LoadRequest(loadOptions));

            Assert.IsNotEmpty(loadResult.HtmlPath);
            Assert.IsNotEmpty(loadResult.ResourcesPath);

            // Save
            var saveOptions = new SaveOptions
            {
                FileInfo      = testFile.ToFileInfo(),
                HtmlPath      = loadResult.HtmlPath,
                ResourcesPath = loadResult.ResourcesPath,
                OutputPath    = $"{DefaultOutputPath}/{testFile.FileName}"
            };

            var saveResult = EditApi.Save(new SaveRequest(saveOptions));

            Assert.AreEqual(saveOptions.OutputPath, saveResult.Path);
        }
        public void TestOpenSaveTsvWithOptions()
        {
            // Load
            var testFile    = TestFiles.Tsv;
            var loadOptions = new DelimitedTextLoadOptions
            {
                FileInfo           = testFile.ToFileInfo(),
                OutputPath         = DefaultOutputPath,
                Separator          = "\t",
                ConvertNumericData = true,
                TreatConsecutiveDelimitersAsOne = true
            };

            var loadResult = EditApi.Load(new LoadRequest(loadOptions));

            Assert.IsNotEmpty(loadResult.HtmlPath);
            Assert.IsNotEmpty(loadResult.ResourcesPath);

            // Save
            var saveOptions = new DelimitedTextSaveOptions
            {
                FileInfo                  = testFile.ToFileInfo(),
                HtmlPath                  = loadResult.HtmlPath,
                ResourcesPath             = loadResult.ResourcesPath,
                OutputPath                = $"{DefaultOutputPath}/{testFile.FileName}",
                Encoding                  = "UTF-8",
                Format                    = "tsv",
                KeepSeparatorsForBlankRow = true
            };

            var saveResult = EditApi.Save(new SaveRequest(saveOptions));

            Assert.AreEqual(saveOptions.OutputPath, saveResult.Path);
        }
        public void TestOpenSaveTextWithOptions()
        {
            // Load
            var testFile    = TestFiles.Txt;
            var loadOptions = new TextLoadOptions
            {
                FileInfo         = testFile.ToFileInfo(),
                OutputPath       = DefaultOutputPath,
                EnablePagination = true,
                LeadingSpaces    = TextLoadOptions.LeadingSpacesEnum.Trim,
                RecognizeLists   = true
            };

            var loadResult = EditApi.Load(new LoadRequest(loadOptions));

            Assert.IsNotEmpty(loadResult.HtmlPath);
            Assert.IsNotEmpty(loadResult.ResourcesPath);

            // Save
            var saveOptions = new TextSaveOptions
            {
                FileInfo            = testFile.ToFileInfo(),
                HtmlPath            = loadResult.HtmlPath,
                ResourcesPath       = loadResult.ResourcesPath,
                OutputPath          = $"{DefaultOutputPath}/{testFile.FileName}",
                AddBidiMarks        = true,
                Encoding            = "UTF-8",
                Format              = "txt",
                PreserveTableLayout = true
            };

            var saveResult = EditApi.Save(new SaveRequest(saveOptions));

            Assert.AreEqual(saveOptions.OutputPath, saveResult.Path);
        }
        public void TestOpenSaveXlsxWithOptions()
        {
            // Load
            var testFile    = TestFiles.FourSheetsProtectedXlsx;
            var loadOptions = new SpreadsheetLoadOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                OutputPath = DefaultOutputPath,
                ExcludeHiddenWorksheets = true
            };

            var loadResult = EditApi.Load(new LoadRequest(loadOptions));

            Assert.IsNotEmpty(loadResult.HtmlPath);
            Assert.IsNotEmpty(loadResult.ResourcesPath);

            // Save
            var saveOptions = new SpreadsheetSaveOptions
            {
                FileInfo           = testFile.ToFileInfo(),
                HtmlPath           = loadResult.HtmlPath,
                ResourcesPath      = loadResult.ResourcesPath,
                OutputPath         = $"{DefaultOutputPath}/{testFile.FileName}",
                Format             = "xlsx",
                Password           = testFile.Password,
                ProtectionPassword = testFile.Password,
                ProtectionType     = SpreadsheetSaveOptions.ProtectionTypeEnum.All
            };

            var saveResult = EditApi.Save(new SaveRequest(saveOptions));

            Assert.AreEqual(saveOptions.OutputPath, saveResult.Path);
        }
        public static void Run()
        {
            try
            {
                // Create necessary API instances
                var editApi = new EditApi(Common.GetConfig());
                var fileApi = new FileApi(Common.GetConfig());

                // The document already uploaded into the storage.
                // Load it into editable state
                var loadOptions = new PresentationLoadOptions
                {
                    FileInfo = new FileInfo
                    {
                        FilePath = "Presentation/with-notes.pptx"
                    },
                    OutputPath  = "output",
                    SlideNumber = 0
                };

                var loadResult = editApi.Load(new LoadRequest(loadOptions));

                // Download html document
                var stream     = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
                var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();

                // Edit something...
                htmlString = htmlString.Replace("Slide sub-heading", "Hello world!");

                // Upload html back to storage
                fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
                                                         new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));

                // Save html back to pptx
                var saveOptions = new PresentationSaveOptions
                {
                    FileInfo      = loadOptions.FileInfo,
                    OutputPath    = "output/edited.pptx",
                    HtmlPath      = loadResult.HtmlPath,
                    ResourcesPath = loadResult.ResourcesPath
                };

                var saveResult = editApi.Save(new SaveRequest(saveOptions));

                // Done.
                Console.WriteLine("Document edited: " + saveResult.Path);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
예제 #8
0
        public static void Run()
        {
            try
            {
                // Create necessary API instances
                var editApi = new EditApi(Common.GetConfig());
                var fileApi = new FileApi(Common.GetConfig());

                // The document already uploaded into the storage.
                // Load it into editable state
                var loadOptions = new SpreadsheetLoadOptions
                {
                    FileInfo = new FileInfo
                    {
                        FilePath = "Spreadsheet/four-sheets.xlsx"
                    },
                    OutputPath     = "output",
                    WorksheetIndex = 0
                };

                var loadResult = editApi.Load(new LoadRequest(loadOptions));

                // Download html document
                var stream     = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
                var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();

                // Edit something...
                htmlString = htmlString.Replace("This is sample sheet", "This is sample sheep");

                // Upload html back to storage
                fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
                                                         new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));

                // Save html back to xlsx
                var saveOptions = new SpreadsheetSaveOptions
                {
                    FileInfo      = loadOptions.FileInfo,
                    OutputPath    = "output/edited.xlsx",
                    HtmlPath      = loadResult.HtmlPath,
                    ResourcesPath = loadResult.ResourcesPath
                };

                var saveResult = editApi.Save(new SaveRequest(saveOptions));

                // Done.
                Console.WriteLine("Document edited: " + saveResult.Path);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
        public void BeforeAllTests()
        {
            var config = new Configuration(_appSid, _appKey)
            {
                ApiBaseUrl = _apiBaseUrl
            };

            EditApi    = new EditApi(config);
            InfoApi    = new InfoApi(config);
            FileApi    = new FileApi(config);
            FolderApi  = new FolderApi(config);
            StorageApi = new StorageApi(config);

            UploadTestFiles();
        }
예제 #10
0
 public void Init()
 {
     instance = new EditApi();
 }