This article shows you how to use Spire.Cloud Web API to process an existing document (Word, Excel, PowerPoint, PDF) in a .NET application.
Step 1: Create an account and log in to our website (www.cloudxdocs.com).
Step 2: Click "My Apps" in the menu to acquire an App ID and an App Key.
Step 3: Upload your documents to "My Files" section. To facilitate document management, you can create an "input" folder and upload documents there, and an "output" folder for storing the processed documents.
Step 4: Create a .NET application and install Spire.Cloud.Sdk via NuGet. Refer to this article for detailed steps.
Step 5: Below is a code example showing you how to convert Word to PDF using the related interfaces provided by Spire.Cloud.Sdk. After execution of the following code, the generated PDF file will be saved under the "output" folder.
P.S. When calling some methods to process documents, you cannot specify an output path. At this time, the modification to the document will be overwritten on the original file.
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace ConvertWordToPdf
{
class Program
{
static string appId = "App Id";
static string appKey = "App Key";
static string baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration object based on App ID, App Key and base Url
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
//Create a ConvertApi object
static ConvertApi convertApi = new ConvertApi(wordConfiguration);
static void Main(string[] args)
{
//Specify the source document name
string name = "sample.docx";
//Specify the target file format to convert
string format = "pdf";
//Specify the output document path
string destFilePath = "output/ToPDF.pdf";
//Specify the original password, set to null if there is no password
string password = null;
//Specify the folder where the source document is stored
string folder = "input";
//Use the default storage, set to null
string storage = null;
//Call Convert method to convert Word to PDF
convertApi.Convert(name, format, destFilePath, password, folder, storage);
}
}
}