Skip to content

Instantly share code, notes, and snippets.

@groupdocs-cloud-gists
Last active August 4, 2024 09:33
Show Gist options
  • Save groupdocs-cloud-gists/11293cdf222491e570d0681603668f5a to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/11293cdf222491e570d0681603668f5a to your computer and use it in GitHub Desktop.
Embed HTML to PowerPoint
How to convert HTML to PowerPoint in C#
// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet
// Obtain your API credentials
string clientId = "XXXXXX-XXXXXXXXX-4088-9ca0-55c38f4b7f22";
string clientSecret1 = "XXXXXXXXXXXXXXXXXXXX";
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret.
var configurations = new Configuration(clientId, clientSecret1);
// Define the value of ApiBaseUrl to set the base url for HTML to PPT conversion API.
configuration.ApiBaseUrl = "https://api.groupdocs.cloud";
// Initialize an instance of the ConvertApi class with an object of Configuration class.
var apiInstance = new ConvertApi(configurations);
// load the input HTML from local drive
using (var stream = System.IO.File.OpenRead("sourceFile.html"))
{
// create an instance of FileApi
var fileUpload = new FileApi(configurations);
// upload the input HTML to cloud storage
fileUpload.UploadFile(new UploadFileRequest("input.html", stream));
// create ConvertSettings where we define the name of source HTML and the name for resultant PPT presentation
var settings = new ConvertSettings
{
StorageName = "default",
FilePath = "input.html",
Format = "ppt",
OutputPath = "Converted.ppt"
};
// Invoke the ConvertDocument method for HTML to PPT conversion.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
if (response != null && response.Equals("OK"))
{
// print success message
Console.WriteLine("The Web page successfully embedded into PowerPoint presentation !");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment