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/four-pages.docx", Format = "pdf", ConvertOptions = new PdfConvertOptions { Pages = new List <int?> { 1, 3 } // Page numbers starts from 1 }, OutputPath = "converted/two-pages.pdf" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
/// <summary> /// Example of extracting first and last pages from PDF and then merging them back to new PDF. /// https://www.convertapi.com/pdf-to-split /// https://www.convertapi.com/pdf-to-merge /// </summary> static async Task Main(string[] args) { try { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); const string sourceFile = @"..\..\..\TestFiles\test.pdf"; var destinationFileName = Path.Combine(Path.GetTempPath(), $"test-merged-{Guid.NewGuid()}.pdf"); var splitTask = await convertApi.ConvertAsync("pdf", "split", new ConvertApiFileParam(sourceFile)); var mergeTask = await convertApi.ConvertAsync("pdf", "merge", new ConvertApiFileParam(splitTask.Files.First()), new ConvertApiFileParam(splitTask.Files.Last())); var saveFiles = await mergeTask.Files.First().SaveFileAsync(destinationFileName); Console.WriteLine("The PDF saved to " + saveFiles); } //Catch exceptions from asynchronous methods catch (ConvertApiException e) { Console.WriteLine("Status Code: " + e.StatusCode); Console.WriteLine("Response: " + e.Response); } Console.ReadLine(); }
public static void Run() { try { // Create necessary API instances var apiInstance = new ConvertApi(Constants.GetConfig()); // Prepare convert settings var loadOptions = new SpreadsheetLoadOptions { SkipEmptyRowsAndColumns = true, OnePagePerSheet = true }; var settings = new ConvertSettings { StorageName = Constants.MyStorage, FilePath = "Spreadsheet/sample.xlsx", Format = "pdf", LoadOptions = loadOptions, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
/// <summary> /// Example of extracting first page from PDF and then chaining conversion PDF page to JPG. /// https://www.convertapi.com/pdf-to-extract /// https://www.convertapi.com/pdf-to-jpg /// </summary> static void Main(string[] args) { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); var pdfFile = @"..\..\..\TestFiles\test.pdf"; var extractFirstPage = convertApi.ConvertAsync("pdf", "extract", new[] { new ConvertApiParam("File", File.OpenRead(pdfFile)), new ConvertApiParam("PageRange", "1") }); var thumbnail = convertApi.ConvertAsync("pdf", "jpg", new[] { new ConvertApiParam("File", extractFirstPage.Result), new ConvertApiParam("ScaleImage", "true"), new ConvertApiParam("ScaleProportions", "true"), new ConvertApiParam("ImageHeight", "300"), new ConvertApiParam("ImageWidth", "300") }); var saveFiles = thumbnail.Result.SaveFiles(Path.GetTempPath()); Console.WriteLine("The thumbnail saved to " + saveFiles.First()); Console.ReadLine(); }
public static void Run() { try { // Create necessary API instances var apiInstance = new ConvertApi(Constants.GetConfig()); // Prepare convert settings var loadOptions = new TxtLoadOptions { Encoding = "shift_jis" }; var settings = new ConvertSettings { StorageName = Constants.MyStorage, FilePath = "Text/sample.txt", Format = "pdf", LoadOptions = loadOptions, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + 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.docx", Format = "pptx", LoadOptions = new DocxLoadOptions() { Password = "", HideWordTrackedChanges = true, DefaultFont = "Arial" }, ConvertOptions = new PptxConvertOptions() { FromPage = 1, PagesCount = 2, Zoom = 1 }, OutputPath = "converted/toslides" }; // convert to specified format List <StoredConvertedResult> response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response[0].Url); } 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 = "converted/tohtml" }; // convert to specified format List <StoredConvertedResult> response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi: " + e.Message); } }
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 = "Email/sample.msg", Format = "pdf", LoadOptions = new EmailLoadOptions { DisplayHeader = false, DisplayFromEmailAddress = false, DisplayToEmailAddress = false, DisplayEmailAddress = false, DisplayCcEmailAddress = false, DisplayBccEmailAddress = false }, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
/// <summary> /// The example converting remotely stored file /// </summary> static async Task Main(string[] args) { try { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); var sourceFile = new Uri("https://cdn.convertapi.com/test-files/presentation.pptx"); Console.WriteLine($"Converting online PowerPoint file {sourceFile} to PDF..."); var convertToPdf = await convertApi.ConvertAsync("pptx", "pdf", new ConvertApiFileParam(sourceFile)); var outputFileName = convertToPdf.Files[0]; var fileInfo = await outputFileName.SaveFileAsync(Path.Combine(Path.GetTempPath(), outputFileName.FileName)); Console.WriteLine("The PDF saved to " + fileInfo); } //Catch exceptions from asynchronous methods catch (ConvertApiException e) { Console.WriteLine("Status Code: " + e.StatusCode); Console.WriteLine("Response: " + e.Response); } Console.ReadLine(); }
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 = "jpeg", LoadOptions = new DocxLoadOptions() { Password = "******" }, ConvertOptions = new JpegConvertOptions() { Grayscale = false, FromPage = 1, PagesCount = 1, Quality = 100, RotateAngle = 90, UsePdf = false }, OutputPath = "converted/tojpeg" }; // convert to specified format List <StoredConvertedResult> response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi: " + e.Message); } }
static void Main(string[] args) { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); try { Console.WriteLine("Converting Powerpoint to PDF..."); var pdfFile = convertApi.ConvertFile(@"..\..\..\TestFiles\test.pptx", Path.Combine(Path.GetTempPath(), "presentation.pdf")); Console.WriteLine("PDF created at " + pdfFile.FullName); Console.WriteLine("Extracting PDF pages and saving them to PNG..."); var pngFiles = convertApi.ConvertFile(@"..\..\..\TestFiles\test.pdf", "png", Path.GetTempPath()); foreach (var fileInfo in pngFiles) { Console.WriteLine("PDF page as image " + fileInfo.FullName); } Console.WriteLine("Google web site to PDF"); var googlePdf = convertApi.ConvertUrl("https://www.google.com", Path.Combine(Path.GetTempPath(), "google.pdf")); Console.WriteLine("PDF created at " + googlePdf.FullName); Console.WriteLine("Converting Word to PDF..."); pdfFile = convertApi.ConvertRemoteFile("https://cdn.convertapi.com/cara/testfiles/document.docx", Path.Combine(Path.GetTempPath(), "document.pdf")); Console.WriteLine("PDF created at " + pdfFile.FullName); } catch (ConvertApiException e) { Console.WriteLine("Status Code: " + e.StatusCode); Console.WriteLine("Response: " + e.Response); } Console.ReadLine(); }
/// <summary> /// Example of saving Word docx to PDF and to PNG /// https://www.convertapi.com/docx-to-pdf /// https://www.convertapi.com/docx-to-png /// </summary> static void Main(string[] args) { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); const string sourceFile = @"..\..\..\TestFiles\test.docx"; var fileParam = new ConvertApiParam("File", File.OpenRead(sourceFile)); var convertToPdf = convertApi.ConvertAsync("docx", "pdf", new[] { fileParam }); var outputFileName = convertToPdf.Result.Files[0]; var fileInfo = outputFileName.AsFileAsync(Path.Combine(Path.GetTempPath(), outputFileName.FileName)).Result; Console.WriteLine("The PDF saved to " + fileInfo); var convertToPng = convertApi.ConvertAsync("docx", "png", new[] { //Reuse the same uploaded file parameter fileParam }); foreach (var processedFile in convertToPng.Result.Files) { fileInfo = processedFile.AsFileAsync(Path.Combine(Path.GetTempPath(), processedFile.FileName)).Result; Console.WriteLine("The PNG saved to " + fileInfo); } Console.ReadLine(); }
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 = "Pdf/sample.pdf", Format = "docx", LoadOptions = new PdfLoadOptions { Password = "", HidePdfAnnotations = true, RemoveEmbeddedFiles = false, FlattenAllFields = true }, ConvertOptions = new DocxConvertOptions(), OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
/// <summary> /// Short example of conversions workflow, the PDF pages extracted and saved as separated JPGs and then ZIP'ed /// https://www.convertapi.com/doc/chaining /// </summary> static async Task Main(string[] args) { try { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); Console.WriteLine("Converting PDF to JPG and compressing result files with ZIP"); var fileName = Path.Combine(Path.GetTempPath(), "test.pdf"); var firstTask = await convertApi.ConvertAsync("pdf", "jpg", new ConvertApiFileParam(fileName)); Console.WriteLine($"Conversions done. Cost: {firstTask.ConversionCost}. Total files created: {firstTask.FileCount()}"); var secondsTask = await convertApi.ConvertAsync("jpg", "zip", new ConvertApiFileParam(firstTask)); var saveFiles = await secondsTask.Files.SaveFilesAsync(Path.GetTempPath()); Console.WriteLine($"Conversions done. Cost: {secondsTask.ConversionCost}. Total files created: {secondsTask.FileCount()}"); Console.WriteLine($"File saved to {saveFiles.First().FullName}"); } //Catch exceptions from asynchronous methods catch (ConvertApiException e) { Console.WriteLine("Status Code: " + e.StatusCode); Console.WriteLine("Response: " + e.Response); } Console.ReadLine(); }
static async Task Main(string[] args) { if (args.Length == 3) { var convertApi = new ConvertApi(args[0]); var maxSize = Int64.Parse(args[1]); var result = await convertApi.ConvertAsync("pdf", "compress", new[] { new ConvertApiFileParam(args[2]) }); if (result.Files[0].FileSize > Int64.Parse(args[1])) { var splitRes = await convertApi.ConvertAsync("pdf", "split", new[] { new ConvertApiParam("file", result) }); var size = 0; var fileParams = splitRes.Files.ToList().Where(f => { size += f.FileSize; return(size <= maxSize); }) .Select(f => new ConvertApiFileParam(f)); var mergeRes = await convertApi.ConvertAsync("pdf", "merge", fileParams); result = await convertApi.ConvertAsync("pdf", "compress", new[] { new ConvertApiParam("file", mergeRes) }); } result.SaveFilesAsync(Directory.GetCurrentDirectory()).Wait(); } else { Console.WriteLine("Usage: limitpdfsize.exe <CONVERTAPI_SECRET> <SIZE_LIMIT_BYTES> <PDF_FILE>"); } }
/// <summary> /// Create PDF Thumbnail /// Example of extracting first page from PDF and then converting it to JPG using chaining. /// https://www.convertapi.com/pdf-to-extract /// https://www.convertapi.com/pdf-to-jpg /// </summary> static async Task Main(string[] args) { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); var pdfFile = @"..\..\..\TestFiles\test.pdf"; var extractFirstPage = await convertApi.ConvertAsync("pdf", "extract", new ConvertApiFileParam(pdfFile), new ConvertApiParam("PageRange", "1") ); var thumbnail = await convertApi.ConvertAsync("pdf", "jpg", new ConvertApiFileParam(extractFirstPage), new ConvertApiParam("ScaleImage", "true"), new ConvertApiParam("ScaleProportions", "true"), new ConvertApiParam("ImageHeight", "300"), new ConvertApiParam("ImageWidth", "300") ); var saveFiles = await thumbnail.SaveFilesAsync(Path.GetTempPath()); Console.WriteLine("The thumbnail saved to " + saveFiles.First()); Console.ReadLine(); }
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 = "converted/towords" }; // convert to specified format List <StoredConvertedResult> response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document conveted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi: " + e.Message); } }
/// <summary> /// The example shows how to use alternative converters to convert Word document to PDF. /// Build in MS Word converter https://www.convertapi.com/docx-to-pdf /// Custom MS Word printer converter https://www.convertapi.com/docx-to-pdf/printer /// OpenOffice converter https://www.convertapi.com/docx-to-pdf/openoffice /// </summary> static async Task Main(string[] args) { var convertApi = new ConvertApi("8wTuDWLxgHleYS4E"); var pdf1 = Path.Combine(Path.GetTempPath(), $"test-Office-{Guid.NewGuid()}.pdf"); var doc1 = await convertApi.ConvertAsync("docx", "pdf", new ConvertApiFileParam(@"..\..\..\..\TestFiles\test.docx")); await doc1.Files.First().SaveFileAsync(pdf1); Console.WriteLine($"The file converted using Office {pdf1}"); var pdf2 = Path.Combine(Path.GetTempPath(), $"test-Office-Printer-{Guid.NewGuid()}.pdf"); var doc2 = await convertApi.ConvertAsync("docx", "pdf", new ConvertApiFileParam(@"..\..\..\..\TestFiles\test.docx"), new ConvertApiFileParam("Converter", "Printer")); await doc2.Files.First().SaveFileAsync(pdf2); Console.WriteLine($"The file converted using Office {pdf2}"); var pdf3 = Path.Combine(Path.GetTempPath(), $"test-Office-OpenOffice-{Guid.NewGuid()}.pdf"); var doc3 = await convertApi.ConvertAsync("docx", "pdf", new ConvertApiFileParam(@"..\..\..\..\TestFiles\test.docx"), new ConvertApiFileParam("Converter", "OpenOffice")); await doc3.Files.First().SaveFileAsync(pdf3); Console.WriteLine($"The file converted using Office {pdf3}"); }
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 = "Email/embedded-image-and-attachment.eml", Format = "pdf", LoadOptions = new EmailLoadOptions { ConvertAttachments = true }, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
/// <summary> /// Example of saving the same Word docx to PDF and to PNG without uploading the same Word file two times. /// https://www.convertapi.com/docx-to-pdf /// https://www.convertapi.com/docx-to-png /// </summary> static async Task Main(string[] args) { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); const string sourceFile = @"..\..\..\TestFiles\test.docx"; var fileParam = new ConvertApiFileParam(sourceFile); var convertToPdf = await convertApi.ConvertAsync("docx", "pdf", fileParam); var outputFileName = convertToPdf.Files[0]; var fileInfo = await outputFileName.SaveFileAsync(Path.Combine(Path.GetTempPath(), outputFileName.FileName)); Console.WriteLine("The PDF saved to " + fileInfo); var convertToPng = await convertApi.ConvertAsync("docx", "png", fileParam); foreach (var processedFile in convertToPng.Files) { fileInfo = await processedFile.SaveFileAsync(Path.Combine(Path.GetTempPath(), processedFile.FileName)); Console.WriteLine("The PNG saved to " + fileInfo); } Console.ReadLine(); }
public static void Run() { try { // Create necessary API instances var apiInstance = new ConvertApi(Constants.GetConfig()); // Prepare convert settings var loadOptions = new PresentationLoadOptions { DefaultFont = "Helvetica", FontSubstitutes = new Dictionary <string, string> { { "Tahoma", "Arial" }, { "Times New Roman", "Arial" } } }; var settings = new ConvertSettings { StorageName = Constants.MyStorage, FilePath = "Presentation/with_notes.pptx", Format = "pdf", LoadOptions = loadOptions, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + 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 = "converted/" + convertToFormat }; // convert to specified format List <StoredConvertedResult> response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception when calling ConvertApi.QuickConvert: " + e.Message); } }
public static void Run() { try { // Create necessary API instances var apiInstance = new ConvertApi(Constants.GetConfig()); // Prepare convert settings var loadOptions = new PresentationLoadOptions { ShowHiddenSlides = true }; var settings = new ConvertSettings { StorageName = Constants.MyStorage, FilePath = "Presentation/with_hidden_page.pptx", Format = "pdf", LoadOptions = loadOptions, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
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 = "Presentation/uses-custom-font.pptx", Format = "pdf", OutputPath = "converted", FontsPath = "font/ttf" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + 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); } }
/// <summary> /// Token authentication example /// More information https://www.convertapi.com/doc/auth /// </summary> static async Task Main(string[] args) { try { //Get your token and apikey at https://www.convertapi.com/a/auth var convertApi = new ConvertApi("token", 0); var sourceFile = @"..\..\..\TestFiles\test.docx"; var result = await convertApi.ConvertAsync("docx", "pdf", new ConvertApiFileParam(sourceFile) ); var saveFiles = await result.SaveFilesAsync(Path.GetTempPath()); Console.WriteLine("The pdf saved to " + saveFiles.First()); } //Catch exceptions from asynchronous methods catch (ConvertApiException e) { Console.WriteLine("Status Code: " + e.StatusCode); Console.WriteLine("Response: " + e.Response); } Console.ReadLine(); }
/// <summary> /// Example of converting Web Page URL to PDF file /// https://www.convertapi.com/web-to-pdf /// </summary> static async Task Main(string[] args) { try { //Get your secret at https://www.convertapi.com/a var convertApi = new ConvertApi("your api secret"); Console.WriteLine("Converting web page https://en.wikipedia.org/wiki/Data_conversion to PDF..."); var response = await convertApi.ConvertAsync("web", "pdf", new ConvertApiParam("Url", "https://en.wikipedia.org/wiki/Data_conversion"), new ConvertApiParam("FileName", "web-example")); var fileSaved = await response.Files.SaveFilesAsync(Path.GetTempPath()); Console.WriteLine("The web page PDF saved to " + fileSaved.First()); } //Catch exceptions from asynchronous methods catch (ConvertApiException e) { Console.WriteLine("Status Code: " + e.StatusCode); Console.WriteLine("Response: " + e.Response); } Console.ReadLine(); }
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 = "Cad/Sample.dwg", Format = "pdf", LoadOptions = new CadLoadOptions { Width = 1920, Height = 1080 }, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
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/four-pages.docx", Format = "xlsx", ConvertOptions = new SpreadsheetConvertOptions() { FromPage = 2, PagesCount = 1, Zoom = 150 }, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: "); Console.WriteLine(response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
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 = "Email/sample.msg", Format = "pdf", LoadOptions = new EmailLoadOptions { TimeZoneOffset = TimeSpan.FromHours(5).ToString() }, OutputPath = "converted" }; // Convert to specified format var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings)); Console.WriteLine("Document converted successfully: " + response[0].Url); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }