Skip to content

Commit a10bbcc

Browse files
Merge pull request #2444 from syncfusion-content/1016280-ugm
1016280-ugm: Added missing details in PDF library.
2 parents b3838a0 + 9802844 commit a10bbcc

20 files changed

Lines changed: 280 additions & 13 deletions

Document-Processing-toc.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,6 +3233,9 @@
32333233
<li>
32343234
<a href="/document-processing/pdf/conversions/html-to-pdf/net/docker">Docker</a>
32353235
</li>
3236+
<li>
3237+
<a href="/document-processing/pdf/conversions/html-to-pdf/net/Convert-HTML-to-PDF-in-Windows-Server">Windows Server</a>
3238+
</li>
32363239
<li>
32373240
<a href="/document-processing/pdf/conversions/html-to-pdf/net/Convert-HTML-to-PDF-in-GCP">Google Cloud Platform (GCP)</a>
32383241
<ul>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Convert HTML to PDF on the Windows Server | Syncfusion
3+
description: Learn how to convert HTML to PDF on a Windows Server using IIS Manager with clear and simple guidance.
4+
platform: document-processing
5+
control: PDF
6+
documentation: UG
7+
keywords: create pdf on windows server, generate pdf on windows server, syncfusion html to pdf, host pdf converter in iis
8+
---
9+
10+
# Convert HTML to PDF on the Windows Server using IIS Manager
11+
12+
The Syncfusion<sup>&reg;</sup> HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML to PDF using C#. Using this library, convert HTML to PDF document on the Windows Server using IIS Manager.
13+
14+
## Steps to convert HTML to PDF on the windows server using IIS manager
15+
16+
Step 1: Create a new C# ASP.NET Web Application (.NET Framework) project.
17+
![Create ASP.NET MVC application](htmlconversion_images/aspnetmvc1.png)
18+
19+
Step 2: In the Create a new ASP.NET Web Application window, choose the MVC template and click Next to proceed.
20+
![Configuration window](htmlconversion_images/aspnetmvc3.png)
21+
22+
Step 3: Install [Syncfusion.HtmlToPdfConverter.Net.Windows](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/).
23+
![NuGet Package](htmlconversion_images/nuget-package-window.png)
24+
25+
Step 4: Include the following namespaces in the HomeController.cs file.
26+
27+
{% highlight c# tabtitle="C#" %}
28+
29+
using Syncfusion.Pdf;
30+
using Syncfusion.HtmlConverter;
31+
using System.IO;
32+
33+
{% endhighlight %}
34+
35+
Step 5: Add a new button in the Index.cshtml as shown below.
36+
37+
{% highlight c# tabtitle="C#" %}
38+
39+
@{Html.BeginForm("ExportToPDF", "Home", FormMethod.Post);
40+
{
41+
<div>
42+
<input type="submit" value="Convert PDF" style="width:150px;height:27px" />
43+
</div>
44+
}
45+
Html.EndForm();
46+
}
47+
48+
{% endhighlight %}
49+
50+
Step 6: Add a new action method named ExportToPDF in HomeController.cs and include the below code example to convert HTML to PDF document using [Convert](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html#Syncfusion_HtmlConverter_HtmlToPdfConverter_Convert_System_String_) method in [HtmlToPdfConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class.
51+
52+
{% highlight c# tabtitle="C#" %}
53+
54+
//Initialize HTML to PDF converter.
55+
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
56+
//Convert URL to PDF document.
57+
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");
58+
//Create memory stream.
59+
MemoryStream stream = new MemoryStream();
60+
//Save the document to memory stream.
61+
document.Save(stream);
62+
document.Close(true);
63+
return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf");
64+
65+
{% endhighlight %}
66+
67+
Step 7: Run the project and verify that the HTML‑to‑PDF conversion functions correctly in the local environment.
68+
69+
## Publish the project to a Windows Server using IIS
70+
71+
Step 1: Publish the project to a local folder by right‑clicking the project, selecting **Publish**, choosing the **Folder** option, and clicking **Next**.
72+
![IIS Folder](htmlconversion_images/IIS-Folder.png)
73+
74+
Step 2: Provide the folder path where the project should be published.
75+
![IIS Folder Path](htmlconversion_images/IIS-Browser.png)
76+
77+
Step 3: After creating the publish profile, Visual Studio opens the Publish dashboard. Review the target location, configuration, and other settings, and adjust them if necessary. Once everything looks correct, click **Publish** to deploy the application to the selected destination.
78+
![IIS Publish](htmlconversion_images/IIS-Publish.png)
79+
80+
Step 4: It will generate and publish all necessary files to the local publish directory.
81+
![IIS Local Folder Path](htmlconversion_images/IIS-localfolder.png)
82+
83+
Step 5: Copy the published output folder to the server and host the application in IIS.
84+
i.Open **IIS Manager** on the server and create a new website.
85+
86+
ii.Enter a **site name** and select the **physical path** that points to the published output folder on the server.
87+
![IIS Website](htmlconversion_images/IIS-Website.png)
88+
89+
iii. Obtain the server’s IP address after adding the website in the local IIS server.
90+
91+
iv. From your local computer, browse the website using the server’s IP address and port number. Once the site loads successfully, export the webpage to PDF.
92+
![IIS Browser](htmlconversion_images/IIS-RunBrowser.png)
93+
94+
A complete working sample is available for download from [GitHub](https://github.com/SyncfusionExamples/html-to-pdf-csharp-examples/tree/master/ASP.NET%20Core).
95+
96+
Click the button to convert the Syncfusion<sup>&reg;</sup> webpage into a PDF document. The generated PDF will appear as shown below.
97+
![IIS Output document](htmlconversion_images/IIS-Output.png)
18.7 KB
Loading
29 KB
Loading
69.4 KB
Loading
25.7 KB
Loading
23.6 KB
Loading
58.3 KB
Loading
58.6 KB
Loading
74 KB
Loading

0 commit comments

Comments
 (0)