Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active September 6, 2021 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/860f1ce0e358bfbb8c3828d61e290e4c to your computer and use it in GitHub Desktop.
Save aspose-cloud/860f1ce0e358bfbb8c3828d61e290e4c to your computer and use it in GitHub Desktop.
Code snippets for converting MOBI to EPUB using C# .NET
Code snippets for converting MOBI to EPUB using Aspose.Words Cloud SDK For .NET
// Get ClientID from https://dashboard.aspose.cloud/
string clientSecret = "caac6e3d4a4724b2feb53f4e460eade3";
string clientID = "4ccf1790-accc-41e9-8d18-a78dbb2ed1aa";
// create an instance of Configuration while providing your Client credentials
var config = new Configuration{ ClientId = clientID, ClientSecret = clientSecret };
// initialize WordsApi instnace using Configuration argument
var wordsApi = new WordsApi(config);
String inputFile = "famouspaintings.mobi";
String resultant = "conveted.epub";
String format = "EPUB";
try
{
using (var inputStream = new FileStream("/Users/nshahbaz/Downloads/" + inputFile, FileMode.Open))
{
// create file upload reqest instance
var uploadFileRequest = new UploadFileRequest(inputStream, inputFile);
// upload MOBI file to Cloud storage
wordsApi.UploadFile(uploadFileRequest);
// Create DocumentWithFormatRequest instance using input file, output format
// and resultant EPUB file name as arguments
var response = new GetDocumentWithFormatRequest(inputFile, format, null, null, null, null, resultant);
// initiate the document conversion operation
Stream result = wordsApi.GetDocumentWithFormat(response);
if (result != null && result.Equals("OK"))
{
Console.WriteLine("Successfully converted MOBI to EPUB !");
}
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment