How to Render HTML Zip File to PDF
Some projects use ZIP packages for more efficient storage and transfer. If a user wants to render an HTML file contained within a ZIP, there's no need to manually extract its contents. With IronPDF, you can render the entire project including all assets directly from the ZIP file. In this article, we’ll demonstrate how to convert an HTML ZIP package into a PDF with ease.
Get started with IronPDF
!!!--LIBRARY_DOWNLOAD_BLOCK--!!!
How to Render HTML ZIP File to PDF

- Download IronPDF Library for HTML ZIP file to PDF Conversion
- Instantiate the ChromePdfRenderer class
- Call RenderZipFileAsPdf to conver the HTML ZIP file into a PDF
- Pass the HTML ZIP file and the path to the html file to the renderer
- Save and download the PDF
Convert HTML ZIP File to PDF Example
Below is an example of utilizing the RenderZipFileAsPdf
method to convert the HTML ZIP file into a PDF. The RenderZipFileAsPdf
method takes in two parameters: the path to the ZIP file and the HTML file name within the ZIP file.
After converting it, we then save the PDF as output.pdf
.
Input File
This is the htmlSample.html
HTML file that the code renders:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample HTML with External CSS and JS</title>
<!-- Link to External CSS -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Welcome to the Sample Page!</h1>
<p id="greeting">Click the button to change the background color and greeting text.</p>
<button id="changeButton">Change Background</button>
</div>
<!-- Link to External JavaScript -->
<script src="script.js"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample HTML with External CSS and JS</title>
<!-- Link to External CSS -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Welcome to the Sample Page!</h1>
<p id="greeting">Click the button to change the background color and greeting text.</p>
<button id="changeButton">Change Background</button>
</div>
<!-- Link to External JavaScript -->
<script src="script.js"></script>
</body>
</html>
Here's a quick preview on how it looks on a Chromium browser.
Code Example
:path=/static-assets/pdf/content-code-examples/how-to/html-zip-file-to-pdf.cs
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderZipFileAsPdf("htmlSample.zip", @"htmlSample.html");
pdf.SaveAs("output.pdf");
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderZipFileAsPdf("htmlSample.zip", "htmlSample.html")
pdf.SaveAs("output.pdf")
Result
This is the final output from the code above.