public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new ConvertApi(configuration); try { // convert settings var settings = new ConvertSettings { StorageName = Common.MyStorage, FilePath = "conversions/sample.docx", Format = "pptx", LoadOptions = new DocxLoadOptions() { Password = "", HideWordTrackedChanges = true, DefaultFont = "Arial" }, ConvertOptions = new PptxConvertOptions() { FromPage = 1, PagesCount = 2, Zoom = 1 }, OutputPath = null // set OutputPath as null will result the output as document IOStream }; // convert to specified format Stream response = apiInstance.ConvertDocumentDownload(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response.Length.ToString()); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi: " + e.Message); } }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new ConvertApi(configuration); try { // convert settings var settings = new ConvertSettings { StorageName = Common.MyStorage, FilePath = "conversions/password-protected.docx", Format = "html", LoadOptions = new DocxLoadOptions() { Password = "******" }, ConvertOptions = new HtmlConvertOptions() { FixedLayout = true, UsePdf = true }, OutputPath = null // set OutputPath as null will result the output as document IOStream }; // convert to specified format Stream response = apiInstance.ConvertDocumentDownload(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response.Length.ToString()); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi: " + e.Message); } }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new ConvertApi(configuration); try { // convert settings var settings = new ConvertSettings { StorageName = Common.MyStorage, FilePath = "conversions/sample.pdf", Format = "docx", LoadOptions = new PdfLoadOptions() { Password = "", HidePdfAnnotations = true, RemoveEmbeddedFiles = false, FlattenAllFields = true }, ConvertOptions = new DocxConvertOptions() { FromPage = 1, PagesCount = 2, Zoom = 100, Dpi = 300 }, OutputPath = null // set OutputPath as null will result the output as document IOStream }; // convert to specified format Stream response = apiInstance.ConvertDocumentDownload(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response.Length.ToString()); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi: " + e.Message); } }
public static void Run(string convertToFormat, ConvertOptions convertOptions) { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new ConvertApi(configuration); try { // convert settings var settings = new ConvertSettings { StorageName = Common.MyStorage, FilePath = "conversions/sample.docx", Format = convertToFormat, ConvertOptions = convertOptions, OutputPath = null // set OutputPath as null will result the output as document IOStream }; // convert to specified format Stream response = apiInstance.ConvertDocumentDownload(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response.Length.ToString()); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi.QuickConvert: " + e.Message); } }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new ConvertApi(configuration); try { // convert settings var settings = new ConvertSettings { StorageName = Common.MyStorage, FilePath = "conversions/password-protected.docx", Format = "pdf", LoadOptions = new DocxLoadOptions() { Password = "******" }, ConvertOptions = new PdfConvertOptions() { BookmarksOutlineLevel = 1, CenterWindow = true, CompressImages = false, DisplayDocTitle = true, Dpi = 1024, ExpandedOutlineLevels = 1, FitWindow = false, FromPage = 1, Grayscale = false, HeadingsOutlineLevels = 1, ImageQuality = 100, Linearize = false, MarginTop = 5, MarginLeft = 5, Password = "******", UnembedFonts = true, RemoveUnusedStreams = true, RemoveUnusedObjects = true, RemovePdfaCompliance = false, Height = 1024 }, OutputPath = null // set OutputPath as null will result the output as document IOStream }; // convert to specified format Stream response = apiInstance.ConvertDocumentDownload(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response.Length.ToString()); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi: " + e.Message); } }
public void TestConvertMissingSettings() { // Arrange var request = new ConvertDocumentRequest(null); // Act & Assert var ex = Assert.Throws <ApiException>(() => { ConvertApi.ConvertDocumentDownload(request); }); Assert.True(ex.Message.Contains("Missing required parameter 'convertSettings'")); }
public static void Run() { try { // Create necessary API instances var apiInstance = new ConvertApi(Constants.GetConfig()); // Prepare convert settings var settings = new ConvertSettings { StorageName = Constants.MyStorage, FilePath = "WordProcessing/password-protected.docx", Format = "pdf", LoadOptions = new DocxLoadOptions { Password = "******" }, ConvertOptions = new PdfConvertOptions { CenterWindow = true, CompressImages = false, DisplayDocTitle = true, Dpi = 1024, FitWindow = false, FromPage = 1, Grayscale = false, ImageQuality = 100, Linearize = false, MarginTop = 5, MarginLeft = 5, Password = "******", UnembedFonts = true, RemoveUnusedStreams = true, RemoveUnusedObjects = true, RemovePdfaCompliance = false }, OutputPath = null // set OutputPath as null will result the output as document IOStream }; // Convert to specified format var response = apiInstance.ConvertDocumentDownload(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response.Length); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
public void ConvertDocumentDownloadTest(TestFile testFile, string targetFormat, ConvertOptions convertOptions) { var format = targetFormat; var options = convertOptions; var filePath = testFile.FullName; var settings = new ConvertSettings { FilePath = filePath, Format = format, ConvertOptions = options }; var result = ConvertApi.ConvertDocumentDownload(new ConvertDocumentRequest(settings)); Assert.IsNotNull(result); Assert.Greater(result.Length, 0); }
public void TestConversionFileNotFound() { var settings = new ConvertSettings { FilePath = TestFiles.NotExist.FullName, Format = "pdf" }; // Arrange var request = new ConvertDocumentRequest(settings); // Act & Assert var ex = Assert.Throws <ApiException>(() => { ConvertApi.ConvertDocumentDownload(request); }); Assert.True(ex.Message.Contains("The specified key does not exist")); }