Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active February 7, 2022 16:56
How to Convert PDF to HTML in C#. For more infomration, please follow link: https://kb.aspose.com/pdf/net/how-to-convert-pdf-to-html-in-csharp/
using System;
using Aspose.Pdf;
namespace TestPDF
{
public class PdfToHtmlConverter
{
public static void Main(string[] args)
{
// Applying product license to create HTML from PDF in C#
License PdfLic = new License();
PdfLic.SetLicense("PDF.Product.Family.lic");
// Initialize document object load the source PDF for exporting to HTML
Document document = new Document("SourcePDF.pdf");
// Initialize HTML SaveOptions to set export options
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
// Split PDF to multiple HTML pages
htmlSaveOptions.SplitIntoPages = true;
htmlSaveOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.AlwaysSaveAsTTF;
// Managing SVG content
htmlSaveOptions.SpecialFolderForSvgImages = @"SvgSavePath";
// Managing Images inside PDF
htmlSaveOptions.SpecialFolderForAllImages = @"ImageSavePath";
// Create HTML from PDF using C#
document.Save("Generated_out.html",SaveFormat.Html);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment