HTML to PDF
The Documentize PDF Converter for .NET provides robust capabilities for converting documents between HTML to PDF format, ideal for web applications, archiving, and report generation. With multiple options for handling resources and layouts, the converter adapts to various project requirements.
Converting HTML to PDF
Transform HTML content into high-quality PDFs, perfect for generating printable reports, archiving web content, or creating shareable document formats. To convert an HTML document to a PDF, follow these steps:
- Configure Options: Use
HtmlToPdfOptionsto define layout and media settings. - Specify Paths: Set input HTML and output PDF file paths.
- Execute the Conversion: Run the
Convertmethod ofPdfConverterto convert the file.
Example: Convert HTML to PDF
1// Create HtmlToPdfOptions
2var options = new HtmlToPdfOptions();
3// Add input file path
4options.AddInput(new FileDataSource("path_to_input.html"));
5// Set output file path
6options.AddOutput(new FileDataSource("path_to_output.pdf"));
7//Perform the process
8PdfConverter.Convert(options);Additional Options for HTML to PDF Conversion
Media Type:
HtmlMediaType.Print: Ideal for generating PDFs suited for printing.HtmlMediaType.Screen: Use when converting content designed for digital viewing.
Layout Adjustments:
PageLayoutOption: Adjusts how HTML content fits the PDF layout, likeScaleToPageWidthto ensure the content scales to the PDF width.IsRenderToSinglePage: Enables rendering the entire HTML content on a single PDF page if needed for concise presentations.
This converter is versatile for a variety of applications, from generating PDF reports based on web content to converting archives of PDF documents for web-based accessibility. For more advanced configurations, refer to the full Documentize documentation.