This short tutorial guides you on how to convert MD to PDF using C#. It provides all the details to establish the environment, a step-by-step procedure, and a runnable sample code to write a complete MD to PDF converter using C#. You will also learn the customization of the output PDF file generated from this process.
Steps to convert MD to PDF using C#
- Establish the environment to use Aspose.HTML for .NET to convert MD to PDF
- Load the MD file and convert it to an HTML file using the ConvertMarkdown method
- Instantiate the PdfSaveOptions class object and set its properties
- Convert the resultant HTML file to PDF using the options set above
These steps describe the process to export MD file to PDF using C#. First, you have to load the source MD file and convert it to an HTML file as there are lot of options to convert an HTML file to PDF. Once the HTML file is ready, now you can set the properties for the output ODF file and convert the loaded HTML file to PDF using the customization options.
Code to convert MD file to PDF using C#
This code demonstrates the process to export MD to PDF using C#. Once the source MD file is converted to an HTML document using the Converter.ConvertMarkdown() method, you get all the features to manipulate this HTML document like setting the character set, style sheet, and title, and inserting or deleting nodes within the document. Similarly, the output PDF is customized like its horizontal resolution, vertical resolution, background color, and JPEG quality parameters are set however you can set other properties also like page setup, encryption, and CSS properties.
This tutorial has guided us to convert an MD file to a PDF file. If you want to learn the process to convert the an HTML file to an image, refer to the article on how to convert HTML to image in C#.