Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active August 16, 2021 00:53
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/d5e286114af86075e905ebbf5dd2bf33 to your computer and use it in GitHub Desktop.
Save aspose-cloud/d5e286114af86075e905ebbf5dd2bf33 to your computer and use it in GitHub Desktop.
This Gist contains code snippets related to Convert PDF to HTML using C#
// 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#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment