This gist explains the steps and code snippet on how to convert PDF file to HTML format using Aspose.PDF Cloud SDK for .NET.
For more information, please visit
This gist explains the steps and code snippet on how to convert PDF file to HTML format using Aspose.PDF Cloud SDK for .NET.
For more information, please visit
// get client credentials from https://dashboard.aspose.cloud/ | |
string clientSecret = "343ebf767f3f53537a45ced31d6be34f"; | |
string clientID = "b1a1b925-cbd0-40c3-b7d5-075c93601243"; | |
// create an instance of PdfApi | |
PdfApi pdfApi = new PdfApi(clientSecret, clientID); | |
// path of input PDF file | |
String inputFile = "/Users/nayyershahbaz/Downloads/Pak 1Q 2021.pdf"; | |
// name of file in Cloud storage | |
String resultantFile = "converted.zip"; | |
try | |
{ | |
using (Stream stream = System.IO.File.OpenRead(inputFile)) | |
{ | |
// initiate the PDF to HTML conversion | |
var response = pdfApi.PutPdfInRequestToHtml(resultantFile, file: stream); | |
// print the response code (200 in success) in console | |
Console.WriteLine(response); | |
} // stream ends here | |
} | |
catch (Exception ex) | |
{ | |
System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); | |
} |
// get client credentials from https://dashboard.aspose.cloud/ | |
string clientSecret = "343ebf767f3f53537a45ced31d6be34f"; | |
string clientID = "b1a1b925-cbd0-40c3-b7d5-075c93601243"; | |
// create an instance of PdfApi | |
PdfApi pdfApi = new PdfApi(clientSecret, clientID); | |
// path of input PDF file | |
String inputFile = "/Users/nayyershahbaz/Downloads/Pak 1Q 2021.pdf"; | |
// read the PDF file content into Stream instance | |
using var fs = new FileStream(inputFile, FileMode.Open, FileAccess.Read); | |
// name of file in cloud storage | |
String fileNameinStorage = "MyUploaded.pdf"; | |
try | |
{ | |
// upload PDF to cloud storage | |
pdfApi.UploadFile(fileNameinStorage, fs); | |
// perform the document conversion | |
var response = pdfApi.GetPdfInStorageToHtml(fileNameinStorage, folder: null); | |
// write result in consoile | |
Console.WriteLine(response); | |
} | |
catch (Exception ex) | |
{ | |
System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); | |
} |
// get client credentials from https://dashboard.aspose.cloud/ | |
string clientSecret = "343ebf767f3f53537a45ced31d6be34f"; | |
string clientID = "b1a1b925-cbd0-40c3-b7d5-075c93601243"; | |
// create an instance of PdfApi | |
PdfApi pdfApi = new PdfApi(clientSecret, clientID); | |
// path of input PDF file | |
String inputFile = "/Users/nayyershahbaz/Downloads/Pak 1Q 2021.pdf"; | |
// read the PDF file content into Stream instance | |
using var fs = new FileStream(inputFile, FileMode.Open, FileAccess.Read); | |
// name of file in cloud storage | |
String fileNameinStorage = "MyUploaded.pdf"; | |
// name of resultant file in Cloud storage | |
string resFileName = "result.zip"; | |
// upload the file to Cloud Storage | |
try | |
{ | |
// upload the file to cloud storage | |
pdfApi.UploadFile(fileNameinStorage, fs); | |
// perform the PDF to HTML conversion and save file in Cloud storage | |
var response = pdfApi.PutPdfInStorageToHtml(fileNameinStorage,resFileName, folder: null); | |
// print the response code in console | |
Console.WriteLine(response); | |
} | |
catch (Exception ex) | |
{ | |
System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); | |
} |
This Gist contains code snippets related to Convert PDF to HTML using C# |