HTML Converter
The Documentize HTML Converter for .NET provides robust capabilities for converting documents between PDF and HTML formats, ideal for web applications, archiving, and report generation. With multiple options for handling resources and layouts, the converter adapts to various project requirements.
PDF to HTML Conversion
Convert PDF files to HTML to make documents accessible for web-based viewing or integration into applications where HTML format is preferred.
HTML to PDF Conversion
Transform HTML content into high-quality PDFs, perfect for generating printable reports, archiving web content, or creating shareable document formats.
Converting PDF to HTML
To convert a PDF to HTML:
- Configure Options: Use
PdfToHtmlOptions
to customize output, choosing either embedded or external resources. - Define Input and Output Paths: Set the paths for your input PDF and output HTML.
- Execute the Conversion: Call the
Process
method ofHtmlConverter
to convert the file.
Example: Convert PDF to HTML with Embedded Resources
1// Step 1: Configure options for PDF to HTML conversion
2var options = new PdfToHtmlOptions(PdfToHtmlOptions.SaveDataType.FileWithEmbeddedResources);
3
4// Step 2: Set file paths
5options.AddInput(new FileDataSource("input.pdf"));
6options.AddOutput(new FileDataSource("output.html"));
7
8// Step 3: Run the conversion
9HtmlConverter.Process(options);
Available Options for PDF to HTML Conversion
- SaveDataType:
FileWithEmbeddedResources
: Generates a single HTML file with all resources embedded.FileWithExternalResources
: Saves resources separately, ideal for large HTML files.
Converting HTML to PDF
To convert an HTML document to a PDF, follow these steps:
- Configure Options: Use
HtmlToPdfOptions
to define layout and media settings. - Specify Paths: Set input HTML and output PDF file paths.
- Execute the Conversion: Run the
Process
method ofHtmlConverter
to convert the file.
Example: Convert HTML to PDF
1// Step 1: Configure options for HTML to PDF conversion
2var options = new HtmlToPdfOptions();
3
4// Step 2: Set file paths
5options.AddInput(new FileDataSource("input.html"));
6options.AddOutput(new FileDataSource("output.pdf"));
7
8// Step 3: Run the conversion
9HtmlConverter.Process(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, likeScaleToPageWidth
to 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.