Skip to content

Commit 81c477b

Browse files
committed
1016280-ugm: Added missing details in PDF library.
1 parent b3838a0 commit 81c477b

19 files changed

Lines changed: 277 additions & 13 deletions
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

Document-Processing/PDF/Conversions/HTML-To-PDF/NET/troubleshooting.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,22 +1560,44 @@ N> We have option to exclude the default Blink binaries from the installation pa
15601560

15611561
## How to Exclude BlinkBinaries or Runtime Files in Build or Deployment
15621562

1563-
The runtime files, or blink binaries, will be copied into a bin or published folder while building and publishing the application.
1564-
By including the <ExcludeAssets>native</ExcludeAssets> option in the package reference of the csproj file, you can exclude the runtime files or blink binaries from being copied into the bin or publish folder while building and publishing the application. But you need to place the BlinkBinaries in the server disk and set the BlinkPath in the BlinkConverterSettings to perform the conversion.
1563+
When you build or publish the application, the Syncfusion HTML‑to‑PDF converter automatically copies the Blink runtime files (BlinkBinaries) into the <i>bin</i> or <i>publish</i> output folder. These binaries are required for HTML‑to‑PDF conversion at runtime. However, in certain deployment scenarios—such as reducing the deployment size or using a shared/system‑installed Chromium—you can exclude these files and instead provide the Blink binaries manually on the host machine.
1564+
1565+
To exclude BlinkBinaries during the build process, configure your project file depending on whether you are using <b>.NET Core/.NET or .NET Framework</b>.
15651566

1566-
N> Using this approach, you can reduce the deployment size on your own servers.
1567+
<b>Exclude BlinkBinaries in .NET Core</b>
1568+
You can prevent runtime files from being included by restricting the package to <b>compile-only</b> assets using the <b>IncludeAssets</b> tag in the <b>PackageReference</b>. This stops all Blink runtime binaries from being copied into the output folder.
15671569

15681570
Refer to the following package reference:
15691571

15701572
{% tabs %}
15711573
{% highlight C# %}
15721574

15731575
<ItemGroup>
1574-
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="31.1.23">
1575-
<ExcludeAssets>native</ExcludeAssets>
1576+
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="32.1.21">
1577+
<IncludeAssets>compile;runtime</IncludeAssets>
15761578
</PackageReference>
15771579
</ItemGroup>
15781580

15791581
{% endhighlight %}
15801582
{% endtabs %}
15811583

1584+
By using <b>IncludeAssets="compile"</b>, only the required compile-time metadata is included, and all runtime dependencies (BlinkBinaries) are excluded from the final build or publish output.
1585+
1586+
N> If you exclude runtime files, you must manually place BlinkBinaries on the server and configure BlinkPath in BlinkConverterSettings for conversion to work.
1587+
1588+
<b>Exclude BlinkBinaries in .NET Framework Projects</b>
1589+
1590+
For .NET Framework applications, Blink runtime files are included through a .targets file referenced in the project.
1591+
To exclude BlinkBinaries, simply remove this import entry.
1592+
1593+
{% tabs %}
1594+
{% highlight C# %}
1595+
1596+
<Import Project="packages\Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.32.1.20\build\net462\Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.targets" Condition="Exists('packages\Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.32.1.20\build\net462\Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.targets')" />
1597+
1598+
{% endhighlight %}
1599+
{% endtabs %}
1600+
1601+
Removing this line prevents the Syncfusion<sup>&reg;</sup> build targets from copying BlinkBinaries and other runtime files into your bin folder during build or publish.
1602+
1603+
N> By excluding BlinkBinaries, you can significantly reduce the size of your deployment package, especially in server environments where disk usage and deployment time matter.

0 commit comments

Comments
 (0)