How to convert the WinForms PDF to HTML using the C#?
The Syncfusion® .NET PDF library supports conversion of PDF documents to HTML with the help of XPDF, an open-source viewer library for PDF documents. We have customized XPDF to enable PDF-to-HTML conversion, and our implementation supports preserving HTML content as flow layout with relative positioning. Additionally, we have made improvements to the process of preserving images during the conversion in our Winforms PDF feature tour page.
Steps to convert HTML to PDF programmatically:
- Create a new window Forms Application project.
- Currently, we do not offer a NuGet package specifically for PDF-to-HTML conversion in applications. To utilize this feature, the following assemblies should be added as references:
• Syncfusion.PdfToHtmlConverter.OPX
• Syncfusion.PdfToHtmlWrapper
The assemblies for PDF-to-HTML conversion can be found in the "Assemblies" folder of the HTML to PDF sample project.
Then, Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.
- Include the following namespaces in the Form1.cs file.
using System; using System.IO; using System.Windows.Forms; using Syncfusion.Pdf.Parsing; using Syncfusion.PdfToHtmlConverter;
- Use the following code sample to convert PDF to HTML file.
//Initializing PDF to HTML converter. PdfToHtmlConverter converter = new PdfToHtmlConverter(); //Initializing and applying PDF to HTML converter settings. PdfToHtmlConverterSettings setting = new PdfToHtmlConverterSettings(); setting.IsFrame = false; setting.AbsolutePositioning = false; converter.Settings = setting; //Loading the input PDF document. PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); //Converting PDF to HTML file. converter.Convert("Input.pdf", "Output.html", loadedDocument.Pages.Count); //Close the PDF document. loadedDocument.Close(true);
By executing the program, you will get the HTML document as follows.
A complete work sample can be downloaded from the GitHub.
Refer here to explore the rich set of Syncfusion Essential® PDF features.
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message.
Conclusion
I hope you enjoyed learning about how to convert the WinForms PDF to HTML using the C#.
You can refer to our Winforms PDF feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!