Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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()
        {
            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);
            }
        }
Exemple #5
0
        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    = "Spreadsheet/sample.csv",
                    Format      = "pdf",
                    LoadOptions = new CsvLoadOptions
                    {
                        ConvertDateTimeData = true,
                        ConvertNumericData  = 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);
            }
        }
        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);
            }
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        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);
            }
        }
Exemple #9
0
        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);
            }
        }
        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);
            }
        }
Exemple #11
0
        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);
            }
        }
Exemple #12
0
        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);
            }
        }
Exemple #13
0
        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);
            }
        }
Exemple #14
0
        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);
            }
        }
Exemple #15
0
        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);
            }
        }
Exemple #16
0
        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);
            }
        }
Exemple #17
0
        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);
            }
        }
Exemple #18
0
        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);
            }
        }
        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 = "converted/topdf"
                };

                // 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);
            }
        }
Exemple #20
0
        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 = "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);
            }
        }
Exemple #21
0
        public static void Run()
        {
            try
            {
                // Create necessary API instances
                var apiInstance = new ConvertApi(Constants.GetConfig());

                // Prepare convert settings
                var watermark = new WatermarkOptions
                {
                    Text       = "Sample watermark",
                    Color      = "Red",
                    Width      = 100,
                    Height     = 100,
                    Background = true
                };

                var settings = new ConvertSettings
                {
                    StorageName    = Constants.MyStorage,
                    FilePath       = "WordProcessing/four-pages.docx",
                    Format         = "pdf",
                    ConvertOptions = new PdfConvertOptions
                    {
                        WatermarkOptions = watermark
                    },
                    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 void TestConversionFontSubs()
        {
            // Prepare convert settings
            var loadOptions = new OneLoadOptions
            {
                FontSubstitutes = new Dictionary <string, string>
                {
                    { "Tahoma", "Arial" }, { "Times New Roman", "Arial" }
                }
            };

            var settings = new ConvertSettings
            {
                FilePath    = TestFiles.OneNote.FullName,
                Format      = "pdf",
                LoadOptions = loadOptions,
                OutputPath  = "converted"
            };


            // Convert to specified format
            var response = ConvertApi.ConvertDocument(new ConvertDocumentRequest(settings));
        }
Exemple #23
0
        public void ConvertDocumentTest(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,
                OutputPath     = "converted"
            };

            var result = ConvertApi.ConvertDocument(new ConvertDocumentRequest(settings));

            Assert.NotNull(result);
            Assert.Greater(result.Count, 0);
            var convertedExtension = Path.GetExtension(result[0].Name);

            Assert.NotNull(convertedExtension);
            Assert.AreEqual(targetFormat, convertedExtension.Substring(1));
        }
Exemple #24
0
        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
                    {
                        FieldLabels = new List <FieldLabel>
                        {
                            new FieldLabel {
                                Field = FieldLabel.FieldEnum.From, Label = "Sender"
                            },
                            new FieldLabel {
                                Field = FieldLabel.FieldEnum.To, Label = "Receiver"
                            }
                        }
                    },
                    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);
            }
        }