This provides a .NET wrapper library for CloudConvert API
C# Shell
Latest commit 54d16d7 Apr 7, 2015 @justinyoo justinyoo Version up to 0.5.1.1
Permalink
Failed to load latest commit information.
Documents/Properties Version up to 0.5.1.1 Apr 7, 2015
SourceCodes Version up to 0.5.1.1 Apr 7, 2015
.gitignore Initial commit Mar 18, 2015
LICENSE Initial commit Mar 18, 2015
README.md Version up to 0.5.1.1 Apr 7, 2015

README.md

CloudConvert.NET

CloudConver.NET provides a .NET wrapper library for CloudConvert API.

Package Status

  • CloudConvert.NET

Getting Started

CloudConvert.NET is easy to use. The following example code is to show how to convert a Markdown document to an MS Word one and store it to OneDrive.

Parameters

Firstly, all relevant settings and parameters need to be prepared beforehand.

var settings = ConverterSettings.CreateInstance();
var wrapper = new ConverterWrapper(settings);
var formats = new Formats();
var input = new InputParameters()
            {
              InputFormat = formats.Document.Md,
              InputMethod = InputMethod.Download,
              Filepath = "https://raw.githubusercontent.com/aliencube/CloudConvert.NET/dev/README.md",
              Filename = "README.md",
            };
var output = new OutputParameters()
             {
               DownloadMethod = DownloadMethod.False,
               OutputStorage = OutputStorage.OneDrive,
             };
var conversion = new ConversionParameters()
                 {
                   OutputFormat = formats.Document.Docx,
                   ConverterOptions = new MarkdownConverterOptions()
                                      {
                                        InputMarkdownSyntax = MarkdownSyntaxType.Auto
                                      },
                 };

Convert

Once the settings and parameters are ready, just call ConvertAsync method to get the result.

// Convert asynchronously
var response = await wrapper.ConvertAsync(input, output, conversion);

// Convert synchronously
var response = wrapper.ConvertAsync(input, output, conversion).Result;

Settings

As you can see the above example codes, configuration settings needs to be instantiated first by calling:

var settings = ConverterSettings.CreateInstance();

This settings instance comes from either converterSettings section or appSettings section on App.config or Web.config. It firstly look for the converterSettings section and, if no converterSettings section is found, then look for the appSettings section.

<configuration>
  <configSections>
    <section name="converterSettings" type="Aliencube.CloudConvert.Wrapper.ConverterSettings, Aliencube.CloudConvert.Wrapper" requirePermission="false" />
  </configSections>

  <converterSettings>
    <basic processUrl="https://api.cloudconvert.com/process" useHeader="true">
      <apiKey value="3qNaQa9iNGOzFv4a2HWtFBWNFGJyyQiBoYtnJLrCUAUppnMzcvZrV7SYKF1_Q4P55zcnFbZni14poKBmCT-BaQ" />
    </basic>
  </converterSettings>
</configuration>

If you want to simply use the appSettings section, you can do the following instead:

<configuration>
  <appSettings>
    <add key="ApiKey" value="3qNaQa9iNGOzFv4a2HWtFBWNFGJyyQiBoYtnJLrCUAUppnMzcvZrV7SYKF1_Q4P55zcnFbZni14poKBmCT-BaQ" />
    <add key="UseHeader" value="true" />
    <add key="ProcessUrl" value="https://api.cloudconvert.com/process" />
  </appSettings>
</configuration>

You can choose whether to put API key – header or request body – by setting the useHeader value.

NOTE: Make sure that:

  • The API key MUST be changed to yours before running this code; otherwise you'll get an error. The API key can be obtained from https://cloudconvert.com/user/profile, once you login.
  • If you want to store your converted result into Goodle Drive, Dropbox or OneDrive, your account should be linked to those services beforehand.

Converter Options

Acknowledgement: Not all strongly-type converter options are ready. The rest options will be added in the later version, gradually. In the meantime, you can still add converter options with Dictionary<string, object> object for other converter types.

List of Classes for Converter Options

  • MarkdownConverterOptions

Usages

This is the sample code using the strongly-typed MarkdownConverterOptions class:

var conversion = new ConversionParameters()
                 {
                   OutputFormat = this._formats.Document.Docx,
                   ConverterOptions = new MarkdownConverterOptions()
                                      {
                                        InputMarkdownSyntax = MarkdownSyntaxType.Auto
                                      },
                 };

Alternatively, you can use the Dictionary<string, object> object instead:

var conversion = new ConversionParameters()
                 {
                   OutputFormat = this._formats.Document.Docx,
                   ConverterOptions = new Dictionary<string, object>()
                                      {
                                        { "input_markdown_syntax", MarkdownSyntaxType.Auto },
                                      },
                 };

Contribution

Your contributions are always welcome! All your work should be done in your forked repository. Once you finish your work, please send us a pull request onto our dev branch for review.

License

CloudConver.NET is released under MIT License

The MIT License (MIT)

Copyright (c) 2015 aliencube.org

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.