Convert PDF to MobiXML with C# REST API

This short tutorial shows you how to convert PDF to MobiXML with C# REST API in the cloud. In order to export PDF to MobiXML format, we’re using Aspose.PDF for C# Cloud SDK. If you would like PDF to MobiXML Conversion in C# Low Code API then this can be achieved by using the below steps and code.

Prerequisite

Steps to Convert PDF to MobiXML in C# REST API

  1. Set Client ID and Client Secret for the API
  2. Create an object of PdfApi class with client credentials
  3. Specify input and output files
  4. Read the input PDF file and upload it to a cloud storage
  5. Call PutPdfInStorageToMobiXml method to Convert PDF to MobiXML using REST API
  6. Download and Save the output MobiXML file on the local disk

Code for PDF to MobiXML Conversion in C# Low Code API

using System;
using System.IO;
using Aspose.Pdf.Cloud.Sdk.Api;
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Aspose.PDF.Cloud.Examples.Kb
{
public class PdfToMobiXml
{
public static void ConvertPdfToMobiXml()
{
try
{
PdfApi pdfApi = new PdfApi("Client Secret", "Client Id");
string localPath = @"C:\PDF\";
string srcFileName = "Sample.pdf";
string outputFile = "PDFtoMobi.mobi";
// Upload source file to the cloud storage
FilesUploadResult result = pdfApi.UploadFile(srcFileName, File.Open(localPath + srcFileName, FileMode.Open));
AsposeResponse response = pdfApi.PutPdfInStorageToMobiXml(srcFileName, outputFile);
// Download output file from Cloud Storage
var stream = pdfApi.DownloadFile(outputFile, null, null);
using (var fileStream = File.Create(localPath + outputFile))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
}
}
}

The code snippet given on this page assists you to convert PDF to MobiXML with C# REST API. You merely need to upload PDF file with the help of the Aspose.PDF REST API SDK for C# and download the output MobiXML file to save it locally by using the Aspose conversion API online.

This PDF to MobiXML Conversion feature can be put to use with any no code or low code apps on any operating system.

You may also check out another similar feature at the following page: How to Convert PDF to PDFA with C# REST API.

 English