XHTML is a stricter and XML based version of the HTML files. It was developed to enhance interoperability with different data formats. Whereas, PDF files are popular owing to their support in multiple platforms and operating systems. In some cases, you may need to convert an XHTML file to PDF format. Accordingly, this article covers how to convert an XHTML file to a PDF document programmatically in C#.
XHTML to PDF Converter – C# .NET API Installation
Aspose.HTML for .NET API can be used to create, edit, or convert several web-related file formats including HTML, EPUB, SVG, etc. You may configure the API by downloading its reference files from the New Releases page or with the NuGet installation command below:
PM> Install-Package Aspose.Html
Convert XHTML to PDF File in C#
XHTML documents could provide extensibility by including fragments from other XML-based languages. You can convert an XHTML file to the PDF format by following the steps below:
- Load the input XHTML file.
- Initialize an instance of the PdfSaveOptions class.
- Convert the XHTML to PDF file with ConvertHTML method.
The following code sample shows how to convert an XHTML file to PDF programmatically in C#:
Explore Aspose.HTML for .NET API
The documentation space explains various other features of the API to work with web and internet-related file formats. You can explore different options for web crawling, downloading, or converting files.
Get Free License
You can evaluate the API without any evaluation restrictions by requesting a free temporary license.
In this article, you have understood the conversion process of XHTML to PDF document in C# based applications over the .NET or .NET Core framework. Furthermore, you may write to us at the forum in case of any inquiries.