Syncfusion PDF Viewer Comparison for HTML to PDF
Developers need simple, easy-to-read functions and short lines of code to work with PDF documents in C# projects. Handling PDFs, including generating, editing, deleting, manipulating and customizing document outputs in .NET, can be done efficiently with the right library.
There are many PDF software libraries in the market, and today we'll compare how to work with Syncfusion and IronPDF.
Overview
Syncfusion PDF Viewer
Syncfusion is a software development company which provides different components (3rd party tools) for developers. Today we'll look specifically at their Syncfusion PDF Viewer, used to work with PDF files, and the HTML to PDF Converter to handle generating PDF documents from an HTML source.
IronPDF C# PDF Library
IronPDF is a component by IronSoftware for .NET developers. It provides a simple and intelligent method to convert any type of HTML page into PDF format, easily generating any type of PDF file with just a few lines of code. In addition, it provides capabilities to add any type of data to the PDF page programmatically, including headers, footers, watermarks or bookmarks.
Comparing IronPDF vs. Syncfusion PDF Viewer
As developers, we try our best to choose components that provide the best way to achieve our target in as few lines of efficient and successful code as possible. To compare working with PDFs, we'll look at the two products, how they deal with PDF files, and compare the functionalities for you to decide what's best for your project.
IronPDF | Syncfusion PDF Viewer |
---|---|
Converts HTML file to PDF using C# with IronPDF | Converts HTML file to PDF with Syncfusion using C# |
IronPDF support for ASP.NET Core with Windows, Linux, and MacOS | Syncfusion support for ASP.NET Core with Windows, Linux, and MacOS |
Provides functions to Enable and Disable Javascript | Provides functions to Enable and Disable Javascript |
No need to give any folder path | Preqrequisite: must install a BlinkBinaries folder path |
One library to deal with PDF files | Different libraries for each process, i.e. watermark or header and footer |
Full support for Mac, Linux and Azure. Coding structure remains the same for all. | Full support for Mac, Linux, and Azure. Coding structure and libraries vary on the basis of the operating system. That's why it provides Blink, Webkit and IE rendering Engines. |
Simple, pre-defined functions for setting Header, Footer or Watermark etc.; no need to work with Graphics. | Header, Footer or Watermark etc. needs to be set using a Graphics library with many lines of code |
We can use Print Media Type for IE rendering engine. | It does not allow to use Print Media Type for IE rendering engine. |
We can make Bookmarks for IE rendering engine. | It does not Allow to make Bookmarks for IE rendering engine. |
We can make SVG to PDF IE for rendering engine. | We can't make SVG to PDF IE for rendering engine. |
Free for unlimited development. | Provide just 30 days trial. |
Less expensive license pricing. | More expensive license pricing. |
Get Started
1. IronPDF Free C# HTML to PDF Library
We'll be looking at some different methods and project use cases for HTML to PDF, which you can follow along by downloading the IronPDF C# HTML to PDF library, always free for development.
1.1 Install IronPDF via NuGet Packager
Using NuGet Package Manager in your Visual Studio project, you can browse for ironpdf
and install it.
PM > Install-Package IronPdf
1.2. Download IronPdf.dll
Alternatively, you can download IronPDF.dll and add its reference in your project.
IronPDF classes can be accessed using the IronPdf
namespace.
1.3. IronPDF Platform Support
.NET framework 4.0 or above on
- Windows
- Azure
.NET Standard 2.0 & Core 2 & 3 on
- Windows
- MacOS
- Linux
- Azure
Cloud hosting services included
- Microsoft Azure
- Docker
- AWS
Can be used with
- ASP.Net MVC Application
- ASP.Net Web Forms Application
- Console Application
- Cloud Application
- Service
- Function
- Desktop Application.
1.4. IronPDF Dependencies
1.4.1. For .NET Framework 4.0 or above
- Iron.Assets.Rendering.Windows (>= 20.0.0)
1.4.2. For .NET Standard 2.0 or above
Iron.Assets.Rendering.Universal (>= 20.0.0)
- System.Drawing.Common (>= 4.7.0)
2. Syncfusion PDF Viewer & Converter
Syncfusion is a component provider offering different types of components for software development. Today we'll be looking at the PDF Viewer and HTML to PDF Converter products.
If you wish to do your own comparison, you can download the Syncfusion components following the steps below and examine the code yourself. We also provide full code examples and analysis so you don't have to install both software components.
2.1. Syncfusion PDF Viewer
PDF viewer is a famous component of Syncfusion used to deal with PDF files. The main feature of this component is that there is no need for Adobe dependency in your target machine. You can Create, Edit and Read PDF files in your .NET application programmatically. It also provides PDF viewer controls to view, review and print PDF files. We can compress or optimize PDF files to minimize file size. It provides a way by which you can convert Excel, Word, PowerPoint, HTML or Images to PDF files.
2.2. Syncfusion HTML to PDF Converter
The HTML to PDF Converter is a Syncfusion component for converting any type of HTML page into a PDF file. It is also possible to convert a specific section of a HTML page into a PDF file by section id. In addition, we also can convert specific images of particular websites to PDF by using its URL. Let's understand how to use it in our projects.
2.3. Install the HTML to PDF Converter
Firstly, we need to install HTML to PDF
converter in our machine. We can install it by downloading Syncfusion HTML to PDF Converter dll or adding its reference by using the NuGet package manager of our .NET project with the following command line:
>PM> Install-Package Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet
After installation we need to add following references in the project:
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
Note: After HTML to PDF converter installation, a folder will be created in the path C:\Program Files (x86)\Syncfusion\HTMLConverter\18.2.0.44\BlinkBinaries
. You need to copy this path and use it in the project.
Compare the Code
3. Compare: Convert HTML String to PDF
It is very important to have the functionality to create a PDF file from HTML string in the business application development. It's best to use an efficient component (3rd party tool) to save time. Let's examine the outputs and let you determine the best one.
3.1. Generate PDF File from HTML String with IronPDF
Firstly, we will see how IronPDF works to generate PDF files by HTML string in C#
using IronPdf;
{
//create rendering converter
var converter = new HtmlToPdf();
//HTML text
string HTML_Str = "<h1>Welcome To IronPDF</h1> <h2>HTML String to PDF</h2> <h3>Hello World!</h3>";
//convert HTML string to PDF file
var PDF = converter.RenderHtmlAsPdf(HTML_Str);
//Save the file
PDF.SaveAs("sample.pdf");
}
using IronPdf;
{
//create rendering converter
var converter = new HtmlToPdf();
//HTML text
string HTML_Str = "<h1>Welcome To IronPDF</h1> <h2>HTML String to PDF</h2> <h3>Hello World!</h3>";
//convert HTML string to PDF file
var PDF = converter.RenderHtmlAsPdf(HTML_Str);
//Save the file
PDF.SaveAs("sample.pdf");
}
Private ReadOnly Property IronPdf() As using
'create rendering converter
Dim converter = New HtmlToPdf()
'HTML text
Dim HTML_Str As String = "<h1>Welcome To IronPDF</h1> <h2>HTML String to PDF</h2> <h3>Hello World!</h3>"
'convert HTML string to PDF file
Dim PDF = converter.RenderHtmlAsPdf(HTML_Str)
'Save the file
PDF.SaveAs("sample.pdf")
End Property
The following Screenshot is of the newly generated PDF file by the above IronPDF code:
3.2. Generate PDF File from HTML String with Syncfusion
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
{
//create converter and specify rendering engine
HtmlToPdfConverter Converter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
// initialize blink converter settings
BlinkConverterSettings Settings = new BlinkConverterSettings();
//HTML text
string HTML_Str = "<h1>Welcome To Syncfusion PDF Viewer</h1> <h2>HTML String to PDF</h2> <h3>Hello World!</h3>";
//Assign BlinkBinaries Folder Path
Settings.BlinkPath = "BlinkBinaries folder Path";
//Assign the setting to converter
Converter.ConverterSettings = Settings;
string baseUrl = "images and files folder Path";
//convert HTML string to PDF file
PdfDocument PDF = Converter.Convert(HTML_Str, baseUrl);
//Save the file
PDF.Save("sample.pdf");
//Close currently open document
PDF.Close(true);
}
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
{
//create converter and specify rendering engine
HtmlToPdfConverter Converter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
// initialize blink converter settings
BlinkConverterSettings Settings = new BlinkConverterSettings();
//HTML text
string HTML_Str = "<h1>Welcome To Syncfusion PDF Viewer</h1> <h2>HTML String to PDF</h2> <h3>Hello World!</h3>";
//Assign BlinkBinaries Folder Path
Settings.BlinkPath = "BlinkBinaries folder Path";
//Assign the setting to converter
Converter.ConverterSettings = Settings;
string baseUrl = "images and files folder Path";
//convert HTML string to PDF file
PdfDocument PDF = Converter.Convert(HTML_Str, baseUrl);
//Save the file
PDF.Save("sample.pdf");
//Close currently open document
PDF.Close(true);
}
Imports Syncfusion.Pdf
Private ReadOnly Property Syncfusion_HtmlConverter() As using Implements Syncfusion.HtmlConverter
'create converter and specify rendering engine
Dim Converter As New HtmlToPdfConverter(HtmlRenderingEngine.Blink)
' initialize blink converter settings
Dim Settings As New BlinkConverterSettings()
'HTML text
Dim HTML_Str As String = "<h1>Welcome To Syncfusion PDF Viewer</h1> <h2>HTML String to PDF</h2> <h3>Hello World!</h3>"
'Assign BlinkBinaries Folder Path
Settings.BlinkPath = "BlinkBinaries folder Path"
'Assign the setting to converter
Converter.ConverterSettings = Settings
Dim baseUrl As String = "images and files folder Path"
'convert HTML string to PDF file
Dim PDF As PdfDocument = Converter.Convert(HTML_Str, baseUrl)
'Save the file
PDF.Save("sample.pdf")
'Close currently open document
PDF.Close(True)
End Property
The following screenshot is of the newly generated PDF file by above Syncfusion code:
3.3. Comparison Conclusion
We have seen both programming structures and the provided functions. IronPDF has fewer lines of code, with simple naming. On the other hand, Syncfusion PDF Viewer has many lines of code with complex coding structure.
The IronPDF generated file looks more readable, because it automatically sets the margin from top,left, and right.
4. Compare: Generate PDF from URL
Let's look at another basic use case, needing to create a PDF file against any URL. For this purpose, we see both working code and functionalities.
4.1. URL to PDF with IronPDF
using IronPdf;
{
//create rendering converter
var converter = new IronPdf.HtmlToPdf();
//Specify URL
var PDF = converter.RenderUrlAsPdf("URL");
//Save the file
PDF.SaveAs("Path + name.pdf");
}
using IronPdf;
{
//create rendering converter
var converter = new IronPdf.HtmlToPdf();
//Specify URL
var PDF = converter.RenderUrlAsPdf("URL");
//Save the file
PDF.SaveAs("Path + name.pdf");
}
Private ReadOnly Property IronPdf() As using
'create rendering converter
Dim converter = New IronPdf.HtmlToPdf()
'Specify URL
Dim PDF = converter.RenderUrlAsPdf("URL")
'Save the file
PDF.SaveAs("Path + name.pdf")
End Property
4.2. URL to PDF with Syncfusion PDF Viewer
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
{
//create converter and specify rendering engine
HtmlToPdfConverter converter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
// initialize blink converter settings
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
//Assign BlinkBinaries Folder Path
blinkConverterSettings.BlinkPath ="BlinkBinaries Folder Path";
//Assign the setting to converter
converter.ConverterSettings = blinkConverterSettings;
//Specify URL
PdfDocument PDF = converter.Convert("URL");
//Save the file
PDF.Save("Path + name.pdf");
//Close document
PDF.Close(true);
}
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
{
//create converter and specify rendering engine
HtmlToPdfConverter converter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
// initialize blink converter settings
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
//Assign BlinkBinaries Folder Path
blinkConverterSettings.BlinkPath ="BlinkBinaries Folder Path";
//Assign the setting to converter
converter.ConverterSettings = blinkConverterSettings;
//Specify URL
PdfDocument PDF = converter.Convert("URL");
//Save the file
PDF.Save("Path + name.pdf");
//Close document
PDF.Close(true);
}
Imports Syncfusion.Pdf
Private ReadOnly Property Syncfusion_HtmlConverter() As using Implements Syncfusion.HtmlConverter
'create converter and specify rendering engine
Dim converter As New HtmlToPdfConverter(HtmlRenderingEngine.Blink)
' initialize blink converter settings
Dim blinkConverterSettings As New BlinkConverterSettings()
'Assign BlinkBinaries Folder Path
blinkConverterSettings.BlinkPath ="BlinkBinaries Folder Path"
'Assign the setting to converter
converter.ConverterSettings = blinkConverterSettings
'Specify URL
Dim PDF As PdfDocument = converter.Convert("URL")
'Save the file
PDF.Save("Path + name.pdf")
'Close document
PDF.Close(True)
End Property
Syncfusion Requires a BlinkBinaries Folder Path
What is the BlinkBinaries Folder Path)? Only required by Syncfusion.
When we use Syncfusion PDF viewer, it needs to use some basic prerequisite files and dlls (Dynamic Link Libraries
), which exist in BlinkBinaries folder
. This folder will automatically generate in C:\Program Files (x86)\Syncfusion\HTMLConverter
after installing the Syncusion PDF Viewer (HTML to PDF Converter). Sometimes, it creates some issues when we give a path from C:\
drive. in such case, we can copy BlinkBinaries
folder and paste in another drive and then give its path in the program.
IronPDF Does Not Require Specific Folder Paths
On the other hand, IronPDF does not have these types of requirements, because we do not need to add a specific folder path to the project, nor do we need a special installation on the server. IronPDF's focus is to minimize the developer work as much as possible and provide a way by which a developer can deal with PDF files without any dependency or prerequisites. So, using IronPDF, you just need to add a IronPDF.dll
file in your project and everything is in your hand.
4.3. Comparison Conclusion
The actual document output of both URL to PDF examples is the same, but we can see that there is a big coding difference between the two components.
IronPDF once again provides a simple structure with just a few lines of code. Using Syncfusion, on the other hand, means we have to write many lines of code and establish an extra process with requiring the BlinkBinaries Folder Path.
5. Compare: Add PDF Header and Footer
Let's look at another use case - we want to add a header
and footer
in the PDF file.
5.1. Add Header and Footer with IronPDF
using IronPdf;
{
var converter = new IronPdf.HtmlToPdf();
converter.PrintOptions.MarginTop = 100;
converter.PrintOptions.MarginTop = 50;
converter.PrintOptions.MarginBottom = 50;
converter.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;
//setting Header
converter.PrintOptions.Header = new SimpleHeaderFooter()
{
CenterText = "header title",
DrawDividerLine = true,
FontSize = 16,
};
//setting Footer
converter.PrintOptions.Footer = new SimpleHeaderFooter()
{
LeftText = "{date} {time}",
RightText = "Page {page} of {total-pages}",
DrawDividerLine = true,
FontSize = 14
};
var PDF = converter.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
PDF.SaveAs("Path + name.pdf");
}
using IronPdf;
{
var converter = new IronPdf.HtmlToPdf();
converter.PrintOptions.MarginTop = 100;
converter.PrintOptions.MarginTop = 50;
converter.PrintOptions.MarginBottom = 50;
converter.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;
//setting Header
converter.PrintOptions.Header = new SimpleHeaderFooter()
{
CenterText = "header title",
DrawDividerLine = true,
FontSize = 16,
};
//setting Footer
converter.PrintOptions.Footer = new SimpleHeaderFooter()
{
LeftText = "{date} {time}",
RightText = "Page {page} of {total-pages}",
DrawDividerLine = true,
FontSize = 14
};
var PDF = converter.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
PDF.SaveAs("Path + name.pdf");
}
Private ReadOnly Property IronPdf() As using
Dim converter = New IronPdf.HtmlToPdf()
converter.PrintOptions.MarginTop = 100
converter.PrintOptions.MarginTop = 50
converter.PrintOptions.MarginBottom = 50
converter.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print
'setting Header
converter.PrintOptions.Header = New SimpleHeaderFooter() With {
.CenterText = "header title",
.DrawDividerLine = True,
.FontSize = 16
}
'setting Footer
converter.PrintOptions.Footer = New SimpleHeaderFooter() With {
.LeftText = "{date} {time}",
.RightText = "Page {page} of {total-pages}",
.DrawDividerLine = True,
.FontSize = 14
}
Dim PDF = converter.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>")
PDF.SaveAs("Path + name.pdf")
End Property
When working with IronPDF, you can set the header and footer by predefined qualities using the following properties:
CenterText
to set the text of the header or footer in Center.LeftText
to set the text of the header or footer in Left side.RightText
to set the text of the header or footer in Right side.DrawDividerLine
to draw a line to separate the header or footer from the content.FontFamily
to set the font family.FontSize
to adjust the font size.Spacing
to set the space between the header and the content of page.
In order to minimize the work for us as developers, IronPDF also provides header and footer attributes that we may need to use in our daily lives.
{page}
to print the page number.{total-pages}
to print the total number of pages.{url}
to print the URL of rendered web page.{date}
to print the current date.{time}
to print the current time.{html-title}
to print the webpage title.{pdf-title}
to print the document title.
5.2. Add Header and Footer with Syncfusion
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf.Graphics;
{
PdfDocument PDF = new PdfDocument();
PdfPage pdfPage = PDF.Pages.Add();
RectangleF bounds = new RectangleF(0, 0, PDF.Pages[0].GetClientSize().Width, 50);
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 24);
PdfSolidBrush brush = new PdfSolidBrush(System.Drawing.Color.FromArgb(44, 71, 120));
//Setting Page Header
PdfPageTemplateElement header = new PdfPageTemplateElement(bounds);
header.Graphics.DrawString("Hello Title", font, brush, bounds);
PDF.Template.Top = header;
//Setting Page Footer
PdfPageTemplateElement footer = new PdfPageTemplateElement(bounds);
footer.Graphics.DrawString("Footer", font, brush, bounds);
PDF.Template.Bottom = footer;
//save the file
PDF.Save("Path + name.pdf");
}
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf.Graphics;
{
PdfDocument PDF = new PdfDocument();
PdfPage pdfPage = PDF.Pages.Add();
RectangleF bounds = new RectangleF(0, 0, PDF.Pages[0].GetClientSize().Width, 50);
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 24);
PdfSolidBrush brush = new PdfSolidBrush(System.Drawing.Color.FromArgb(44, 71, 120));
//Setting Page Header
PdfPageTemplateElement header = new PdfPageTemplateElement(bounds);
header.Graphics.DrawString("Hello Title", font, brush, bounds);
PDF.Template.Top = header;
//Setting Page Footer
PdfPageTemplateElement footer = new PdfPageTemplateElement(bounds);
footer.Graphics.DrawString("Footer", font, brush, bounds);
PDF.Template.Bottom = footer;
//save the file
PDF.Save("Path + name.pdf");
}
Imports Syncfusion.Pdf
Imports Syncfusion.HtmlConverter
Private ReadOnly Property Pdf_Graphics() As using Implements Syncfusion.Pdf.Graphics
Dim PDF As New PdfDocument()
Dim pdfPage As PdfPage = PDF.Pages.Add()
Dim bounds As New RectangleF(0, 0, PDF.Pages(0).GetClientSize().Width, 50)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 24)
Dim brush As New PdfSolidBrush(System.Drawing.Color.FromArgb(44, 71, 120))
'Setting Page Header
Dim header As New PdfPageTemplateElement(bounds)
header.Graphics.DrawString("Hello Title", font, brush, bounds)
PDF.Template.Top = header
'Setting Page Footer
Dim footer As New PdfPageTemplateElement(bounds)
footer.Graphics.DrawString("Footer", font, brush, bounds)
PDF.Template.Bottom = footer
'save the file
PDF.Save("Path + name.pdf")
End Property
Working with PDF Headers and Footers with Syncfusion PDF Viewer can be more deeply examined here.
5.3. Comparison Conclusion
When we use the Syncfusion PDF Viewer, we need to work with graphics to print the header and footer on PDF pages. It does not use the .NET graphics library, it has its own library and programming structure, which can be difficult to work with and requires an extra step.
For example, if we want to print the current page number of total pages, we would have to write the following lines of code Using Syncfusion PDF Viewer:
//font and brush are defined in above sample code
PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush);
PdfPageCountField count = new PdfPageCountField(font, brush);
PdfCompositeField compositeField = new PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count);
compositeField.Bounds = footer.Bounds;
compositeField.Draw(footer.Graphics, new PointF(470, 40));
PDF.Template.Bottom = footer;
//font and brush are defined in above sample code
PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush);
PdfPageCountField count = new PdfPageCountField(font, brush);
PdfCompositeField compositeField = new PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count);
compositeField.Bounds = footer.Bounds;
compositeField.Draw(footer.Graphics, new PointF(470, 40));
PDF.Template.Bottom = footer;
'font and brush are defined in above sample code
Dim pageNumber As New PdfPageNumberField(font, brush)
Dim count As New PdfPageCountField(font, brush)
Dim compositeField As New PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count)
compositeField.Bounds = footer.Bounds
compositeField.Draw(footer.Graphics, New PointF(470, 40))
PDF.Template.Bottom = footer
On the other hand, By using IronPDF, we can complete the same task with one line:
Page {page} of {total-pages}
Page {page} of {total-pages}
Page
If True Then
page
End If
[of]
If True Then
'INSTANT VB TODO TASK: The following line uses invalid syntax:
' total-pages}
The code comparison speaks for itself.
6. Compare: Add Watermark
Another common requirement is to add a WaterMark on the PDF file. Suppose that we want to add this watermark by the following aspects:
- on a specific page
- on selected pages
- on all pages.
Let's compare how to accomplish each of these while using the two different software components.
6.1. Add Watermark to 1 Specific Page with IronPDF
Let's create a URL to PDF document with multiple pages, but only add a watermark to one specific page, with the rest staying the same.
To add a WaterMark on a specific page, IronPDF provides the WatermarkPage()
function, and it takes different types of parameters to set the WaterMark.
We can define this function:
WatermarkPage(Text, PageIndex, WaterMarkLocation, Opacity, Rotation, Hyperlink);
WatermarkPage(Text, PageIndex, WaterMarkLocation, Opacity, Rotation, Hyperlink);
WatermarkPage(Text, PageIndex, WaterMarkLocation, Opacity, Rotation, Hyperlink)
Text
is a string which to be written as a WaterMark.PageIndex
is page number where WaterMark to be addedWaterMarkLocation
to set location of WaterMark text, it can be adjusted with the following:TopLeft
,TopCenter
,TopRight
,MiddleLeft
,MiddleCenter
,MiddleRight
,BottomLeft
,BottomCenter
,BottomRight
Opacity
is to set transparencyRotation
is to set angle of textHyperlink
to attach a link to the WaterMark
Text would be in HTML
format and we can set its styling properties using CSS
as:
string Text = "<h2 style='color:red'>Hello WaterMark</h2>";
string Text = "<h2 style='color:red'>Hello WaterMark</h2>";
Dim Text As String = "<h2 style='color:red'>Hello WaterMark</h2>"
Now, let's see the full example of how to add WaterMark on specific page using IronPDF in C#:
using IronPdf
{
var converter = new HtmlToPdf();
var pdf= converter.RenderUrlAsPdf("https://yandex.com/");
pdf.WatermarkPage("<h2 style='color:red'>Sample Water Mark</h2>", 0, PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45);
pdf.SaveAs("sample.pdf");
}
using IronPdf
{
var converter = new HtmlToPdf();
var pdf= converter.RenderUrlAsPdf("https://yandex.com/");
pdf.WatermarkPage("<h2 style='color:red'>Sample Water Mark</h2>", 0, PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45);
pdf.SaveAs("sample.pdf");
}
Private ReadOnly Property IronPdf() As using
Dim converter = New HtmlToPdf()
Dim pdf= converter.RenderUrlAsPdf("https://yandex.com/")
pdf.WatermarkPage("<h2 style='color:red'>Sample Water Mark</h2>", 0, PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45)
pdf.SaveAs("sample.pdf")
End Property
Here is a screenshot of the generated PDF document "sample.pdf":
6.2. Add Watermark to 1 Specific Page with Syncfusion
To add a watermark in a PDF file using Syncfusion, you must first learn how to work with the specific Syncfusion PDF graphics library. You can not use the Microsoft graphics library.
Note: If you are using the Syncfusion PDF Viewer, then you also need to add the BlinkBinaries
folder path in your project. This folder will be created after Syncfusion PDF viewer Installation in C:\Program Files (x86)\Syncfusion
. Here you can read the Syncfusion blinkbinaries tutorial.
Now, let's see the example of how to add a WaterMark on specific page using Syncfusion PDF viewer in C#.
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf.Graphics;
{
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
blinkConverterSettings.BlinkPath = "BlinkBinaries Folder Path";
htmlConverter.ConverterSettings = blinkConverterSettings;
PdfDocument document = htmlConverter.Convert("https://yandex.com/");
PdfPageBase pdfPage = document.Pages[0];
PdfGraphics graphics = pdfPage.Graphics;
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 15);
PdfGraphicsState state = graphics.Save();
graphics.SetTransparency(0.7f);
graphics.RotateTransform(-40);
graphics.DrawString("Sample Water Mark", font, PdfPens.Red, PdfBrushes.Red, new PointF(-100, 550));
document.Save("sample.pdf");
document.Close(true);
}
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf.Graphics;
{
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
blinkConverterSettings.BlinkPath = "BlinkBinaries Folder Path";
htmlConverter.ConverterSettings = blinkConverterSettings;
PdfDocument document = htmlConverter.Convert("https://yandex.com/");
PdfPageBase pdfPage = document.Pages[0];
PdfGraphics graphics = pdfPage.Graphics;
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 15);
PdfGraphicsState state = graphics.Save();
graphics.SetTransparency(0.7f);
graphics.RotateTransform(-40);
graphics.DrawString("Sample Water Mark", font, PdfPens.Red, PdfBrushes.Red, new PointF(-100, 550));
document.Save("sample.pdf");
document.Close(true);
}
Imports Syncfusion.Pdf
Imports Syncfusion.HtmlConverter
Private ReadOnly Property Pdf_Graphics() As using Implements Syncfusion.Pdf.Graphics
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.Blink)
Dim blinkConverterSettings As New BlinkConverterSettings()
blinkConverterSettings.BlinkPath = "BlinkBinaries Folder Path"
htmlConverter.ConverterSettings = blinkConverterSettings
Dim document As PdfDocument = htmlConverter.Convert("https://yandex.com/")
Dim pdfPage As PdfPageBase = document.Pages(0)
'INSTANT VB NOTE: The local variable graphics was renamed since Visual Basic will not allow local variables with the same name as their enclosing function or property:
Dim graphics_Conflict As PdfGraphics = pdfPage.Graphics
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 15)
Dim state As PdfGraphicsState = graphics_Conflict.Save()
graphics_Conflict.SetTransparency(0.7F)
graphics_Conflict.RotateTransform(-40)
graphics_Conflict.DrawString("Sample Water Mark", font, PdfPens.Red, PdfBrushes.Red, New PointF(-100, 550))
document.Save("sample.pdf")
document.Close(True)
End Property
With the following screenshot of the generated PDF document sample.pdf
:
6.3. Add Watermark to Selected Pages with IronPDF
IronPDF provides a simple way for when you need to add a WaterMark on many pages, but not all of them. For this purpose, we can use WatermarkPages()
, and it can be defined as:
WatermarkPages(Text, Array of page Indexes, WaterMarkLocation, Opacity, Rotation, Hyperlink);
WatermarkPages(Text, Array of page Indexes, WaterMarkLocation, Opacity, Rotation, Hyperlink);
WatermarkPages(Text, Array [of] page Indexes, WaterMarkLocation, Opacity, Rotation, Hyperlink)
In this function all of the parameters work the same as the above function, but with the new element of Array of page Indexes:
Array of page Indexes is an array of integers to define on which pages the WaterMark is to be added.
Just suppose that if we want to add WaterMark "Text" just on page "1", "3", "5" of the PDF file, then we woul do the following. The rest of the pages remain the same.
pdf.WatermarkPages("<h2 style='color:red'>SAMPLE</h2>", new[] {1,3,5 }, PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45);
pdf.WatermarkPages("<h2 style='color:red'>SAMPLE</h2>", new[] {1,3,5 }, PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45);
pdf.WatermarkPages("<h2 style='color:red'>SAMPLE</h2>", {1,3,5 }, PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45)
6.4. Add Watermark to Selected Pages with Syncfusion
There is no predefined function with Synfusion to apply a watermark to specific pages. Instead, it can be possible by making your own programming structure using loop
and conditions
. In this way, the programming structure becomes complex and we have to write many lines of code.
6.5. Add WaterMark on All Pages with IronPDF
IronPDF provides a predefined function for this common requirement, to add a WaterMark on all pages, named WatermarkAllPages()
. There is no need for iteration for adding the WaterMark on each page separately, just call the function once and the WaterMark would be added on each page of the PDF file. Let's see the following example:
using IronPdf
{
var converter = new HtmlToPdf();
var pdf= converter.RenderUrlAsPdf("URL");
pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>", PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45);
pdf.SaveAs("sample.pdf");
}
using IronPdf
{
var converter = new HtmlToPdf();
var pdf= converter.RenderUrlAsPdf("URL");
pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>", PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45);
pdf.SaveAs("sample.pdf");
}
Private ReadOnly Property IronPdf() As using
Dim converter = New HtmlToPdf()
Dim pdf= converter.RenderUrlAsPdf("URL")
pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>", PdfDocument.WaterMarkLocation.MiddleCenter, 50, -45)
pdf.SaveAs("sample.pdf")
End Property
6.6. Add WaterMark on All Pages with Syncfusion
In this case, if we use Syncfusion, again there is no predefined function for adding a WaterMark on all pages of a PDF file. But it is possible using SyncfusionPDF viewer.
It can be done by iterating the PDF page. In this way, the WaterMark will be added on an iterated page one by one. Iteration can be done using for
or while
loops. Let's see the following example of how to add WaterMark on all pages using Syncfusion PDF viewer.
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf.Graphics;
{
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
blinkConverterSettings.BlinkPath ="BlinkBinaries Folder Path";
blinkConverterSettings.EnableJavaScript = false;
htmlConverter.ConverterSettings = blinkConverterSettings;
PdfDocument document = htmlConverter.Convert("URL");
for (int i = 0; i < document.Pages.Count; i++)
{
PdfPageBase pdfPage = document.Pages[i];
PdfGraphics graphics = pdfPage.Graphics;
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
PdfGraphicsState state = graphics.Save();
graphics.SetTransparency(0.25f);
graphics.RotateTransform(-40);
graphics.DrawString("Sample", font, PdfPens.Red, PdfBrushes.Red, new PointF(-150, 450));
}
document.Save("sample.pdf");
document.Close(true);
}
using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf.Graphics;
{
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
blinkConverterSettings.BlinkPath ="BlinkBinaries Folder Path";
blinkConverterSettings.EnableJavaScript = false;
htmlConverter.ConverterSettings = blinkConverterSettings;
PdfDocument document = htmlConverter.Convert("URL");
for (int i = 0; i < document.Pages.Count; i++)
{
PdfPageBase pdfPage = document.Pages[i];
PdfGraphics graphics = pdfPage.Graphics;
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
PdfGraphicsState state = graphics.Save();
graphics.SetTransparency(0.25f);
graphics.RotateTransform(-40);
graphics.DrawString("Sample", font, PdfPens.Red, PdfBrushes.Red, new PointF(-150, 450));
}
document.Save("sample.pdf");
document.Close(true);
}
Imports Syncfusion.Pdf
Imports Syncfusion.HtmlConverter
Private ReadOnly Property Pdf_Graphics() As using Implements Syncfusion.Pdf.Graphics
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.Blink)
Dim blinkConverterSettings As New BlinkConverterSettings()
blinkConverterSettings.BlinkPath ="BlinkBinaries Folder Path"
blinkConverterSettings.EnableJavaScript = False
htmlConverter.ConverterSettings = blinkConverterSettings
Dim document As PdfDocument = htmlConverter.Convert("URL")
For i As Integer = 0 To document.Pages.Count - 1
Dim pdfPage As PdfPageBase = document.Pages(i)
'INSTANT VB NOTE: The local variable graphics was renamed since Visual Basic will not allow local variables with the same name as their enclosing function or property:
Dim graphics_Conflict As PdfGraphics = pdfPage.Graphics
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20)
Dim state As PdfGraphicsState = graphics_Conflict.Save()
graphics_Conflict.SetTransparency(0.25F)
graphics_Conflict.RotateTransform(-40)
graphics_Conflict.DrawString("Sample", font, PdfPens.Red, PdfBrushes.Red, New PointF(-150, 450))
Next i
document.Save("sample.pdf")
document.Close(True)
End Property
For more about how to iterate and add watermark with syncfusion you can read more.
7. Compare: Licensing
When we need to choose one product from two, pricing plays a very important role in deciding which product we should choose. We can't deny the importance of component license pricing. In business application development companies, it is very important how we might complete the project with minimum usage of resources and budget. For this purpose, we compare the licensing package of both IronPDF and Syncfusion.
IronPDF | Syncfusion PDF Viewer |
---|---|
One time license purchase fee | Yearly license fee |
$399 total for 1 developer | $995/year for 1 developer |
$449 total for 2 developers | $1990/year for 2 developers |
$499 total for 3 developers | $2985/year for 3 developers |
$599 total for unlimited developers | No unlimited developer license |
Explore IronPDF licensing options. | Read More about Syncfusion PDF Viewer licensing. |
IronPDF also provides useful packages for companies and agencies on the basis of number of developers, as well as SaaS and OEM redistribution options. You can read more about IronPDF licensing or get a personalized walkthrough for your license needs by contacting the team.
Alternatively, Syncfusion PDF Viewer does not have any predefined packages for companies, but it sets the price after knowing your company information on the spot.
8. Syncfusion Products List
Syncfusion is a component provider company which provides different types of components for software development. We take a look at some of their most popular components and supported platforms.
Components | Description | Web | Desktop | Android |
---|---|---|---|---|
PDF Viewer | Used to deal with PDF files to Create, Edit, Delete and Add extra features like Header, Footer or Watermark e.t.c. | JavaScript, Angular, React, Vue, Blazor, jQueryASP.NET MVC, ASP.NET Core, ASP.NET Web Forms | WinForms, WPF, Xamarin, UWP | Xamarin, UWP |
Excel Library | Used to deal with Microsoft Excel files programmatically in .NET projects. | Blazor, ASP.NET MVC, .NET Core, ASP.NET Web Forms | WinForms, WPF, Xamarin, UWP | Xamarin, UWP |
Charts | Used to display data on different type of chart for better visualization | JavaScript, Angular, React, Vue, Blazor, jQuery, ASP.NET MVC, ASP.NET Core, ASP.NET Web Forms | WinForms, WPF, Xamarin, UWP | Xamarin, Flutter, UWP |
DataGrid | Used to display different types of data in tabular form | JavaScript, Angular, React, Vue, Blazor, jQuery, ASP.NET MVC, ASP.NET Core, ASP.NET Web Forms | WinForms, WPF, Xamarin, UWP | Xamarin, Flutter, UWP |
ListView | Used for better visualization of data with UI views or different types of custom templates. | JavaScript, Angular, React, Vue, Blazor, jQuery, ASP.NET MVC, ASP.NET Core, ASP.NET Web Forms | WinForms, Xamarin | Xamarin |
Scheduler | Used to manage your schedule with calendar features. | JavaScript, Angular, React, Vue, Blazor, jQuery, ASP.NET MVC, ASP.NET Core, ASP.NET Web Forms | WinForms, WPF, Xamarin, UWP | Xamarin, Flutter, UWP |
Diagram | Used to facilitate a wide variety to draw different types of diagrams | JavaScript, Angular, React, Vue, Blazor, jQuery, ASP.NET MVC, ASP.NET Core, ASP.NET Web Forms | WinForms, WPF, Xamarin, UWP | Xamarin, UWP |
Read more about Syncfusion Supported platform and components.
Tutorial Quick Access
Download the C# HTML to PDF Quickstart Guide
Use the guide to make it easier to develop PDFs for .NET, including functions for manipulating, editing, generating, and saving PDFS in C# and VB.NET for your project.
Download the GuideRead the IronPDF Documentation
Explore the Object Reference for the IronPDF Library, with features, classes, method fields, namespaces, and enums.
View the Object Reference