PRODUCT COMPARISONS

A Comparison Between IronPDF & PDFSharpCore

Published March 6, 2024
Share:

Creating and managing PDFs is a common requirement in software development. Developers often need libraries, available as the NuGet packages, that can effortlessly generate, edit, and manipulate PDFs. IronPDF and PDFSharpCore are two prominent libraries in the .NET language ecosystem that serve this purpose. This article, relevant for Visual Studio users, dives into both, highlighting their features, differences, and how they can be utilized in .NET projects.

Introduction to IronPDF and PDFSharpCore

IronPDF is a comprehensive .NET library designed for developers to effortlessly create, edit, and convert PDF documents. It offers a wide range of functionalities for creating, editing, and converting such documents. IronPDF supports .NET Core and frameworks, making it versatile for various applications, including web and desktop.

PDFSharpCore library is a partial port of the original PDFsharp library. It targets .NET Core additionally MigraDoc foundation, focusing on creating and processing PDF documents without relying on Windows libraries. This makes it suitable for cross-platform projects, running on Linux, MacOS, and Windows.

Installation of IronPDF and PDFSharpCore

Installing IronPDF

To start using IronPDF in your project, you can easily install it via NuGet Package Manager. Follow these steps to install IronPDF:

  1. Open your project in Visual Studio.
  2. Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
  3. Search for IronPdf in the NuGet Manager.
    1. Select your project, then click on Install to add IronPDF to your project.

A Comparison Between IronPDF & PDFSharpCore: Figure 1 - IronPDF

Alternatively, you can use the Package Manager Console to install IronPDF with the following command:

Install-Package IronPdf

Installing PDFSharpCore

To install PDFSharpCore using NuGet, follow these instructions:

  1. Ensure your Visual Studio project is open.
  2. Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
  3. In the NuGet Package Manager, search for PDFSharpCore.
    1. Select your project and click Install to incorporate PDFSharpCore.

A Comparison Between IronPDF & PDFSharpCore: Figure 2 - PDFSharpCore

For developers preferring the Package Manager Console, PDFSharpCore can be installed with this command:

Install-Package PdfSharpCore

Creating PDF File: IronPDF vs. PDFSharpCore

IronPDF: Easy Creation and Manipulation

IronPDF simplifies the process of generating new PDF documents for developers. It provides an intuitive way to create PDFs directly from HTML content or web pages, streamlining the conversion of web content into portable document format files.

HTML String to PDF

IronPDF allows the creation of PDF documents from HTML strings using its ChromePdfRenderer class. This feature is especially useful when you need to generate PDFs dynamically from HTML templates or content generated within your application. Here's how you can convert an HTML string to a PDF document using IronPDF:

using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        License.LicenseKey = "License-Key";
        // Create a new instance of IronPdf.ChromePdfRenderer
        var Renderer = new ChromePdfRenderer();
        // HTML content with meaningful content
        string htmlContent = @"
                <h1>Report on Sales Performance</h1>
                <p>This report analyzes the sales performance for the first quarter of 2024.</p>
                <table>
                    <thead>
                        <tr>
                            <th>Month</th>
                            <th>Sales Revenue</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>January</td>
                            <td>$50,000</td>
                        </tr>
                        <tr>
                            <td>February</td>
                            <td>$55,000</td>
                        </tr>
                        <tr>
                            <td>March</td>
                            <td>$60,000</td>
                        </tr>
                    </tbody>
                </table>
                <p>This report highlights the positive growth in sales revenue over the quarter.</p>";
        // Render HTML content as PDF
        var PDF = Renderer.RenderHtmlAsPdf(htmlContent);
        // Save the PDF as example.pdf
        PDF.SaveAs("example.pdf");
        Console.WriteLine("PDF saved successfully.");
    }
}
using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        License.LicenseKey = "License-Key";
        // Create a new instance of IronPdf.ChromePdfRenderer
        var Renderer = new ChromePdfRenderer();
        // HTML content with meaningful content
        string htmlContent = @"
                <h1>Report on Sales Performance</h1>
                <p>This report analyzes the sales performance for the first quarter of 2024.</p>
                <table>
                    <thead>
                        <tr>
                            <th>Month</th>
                            <th>Sales Revenue</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>January</td>
                            <td>$50,000</td>
                        </tr>
                        <tr>
                            <td>February</td>
                            <td>$55,000</td>
                        </tr>
                        <tr>
                            <td>March</td>
                            <td>$60,000</td>
                        </tr>
                    </tbody>
                </table>
                <p>This report highlights the positive growth in sales revenue over the quarter.</p>";
        // Render HTML content as PDF
        var PDF = Renderer.RenderHtmlAsPdf(htmlContent);
        // Save the PDF as example.pdf
        PDF.SaveAs("example.pdf");
        Console.WriteLine("PDF saved successfully.");
    }
}
Imports IronPdf
Friend Class Program
	Shared Sub Main(ByVal args() As String)
		License.LicenseKey = "License-Key"
		' Create a new instance of IronPdf.ChromePdfRenderer
		Dim Renderer = New ChromePdfRenderer()
		' HTML content with meaningful content
		Dim htmlContent As String = "
                <h1>Report on Sales Performance</h1>
                <p>This report analyzes the sales performance for the first quarter of 2024.</p>
                <table>
                    <thead>
                        <tr>
                            <th>Month</th>
                            <th>Sales Revenue</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>January</td>
                            <td>$50,000</td>
                        </tr>
                        <tr>
                            <td>February</td>
                            <td>$55,000</td>
                        </tr>
                        <tr>
                            <td>March</td>
                            <td>$60,000</td>
                        </tr>
                    </tbody>
                </table>
                <p>This report highlights the positive growth in sales revenue over the quarter.</p>"
		' Render HTML content as PDF
		Dim PDF = Renderer.RenderHtmlAsPdf(htmlContent)
		' Save the PDF as example.pdf
		PDF.SaveAs("example.pdf")
		Console.WriteLine("PDF saved successfully.")
	End Sub
End Class
VB   C#

A Comparison Between IronPDF & PDFSharpCore: Figure 3 - PDF Report Send Output

HTML File to PDF

IronPDF also supports converting entire HTML files into PDF documents. This is particularly useful for converting static HTML pages or templates stored as files into PDF format. Here's a code example of how to convert an HTML file to a PDF document:

using IronPdf;
class Program
{
    void Main(string [] args)
    {
        License.LicenseKey = "License-Key";
        // Create a new instance of IronPdf.ChromePdfRenderer
        var Renderer = new ChromePdfRenderer();
        // Render HTML content as PDF
        var PDF = Renderer.RenderHtmlFileAsPdf(@"C:\Users\Tayyab Ali\Desktop\example.html");
        PDF.SaveAs("example.pdf");
        Console.WriteLine("PDF saved successfully.");
    }
}
using IronPdf;
class Program
{
    void Main(string [] args)
    {
        License.LicenseKey = "License-Key";
        // Create a new instance of IronPdf.ChromePdfRenderer
        var Renderer = new ChromePdfRenderer();
        // Render HTML content as PDF
        var PDF = Renderer.RenderHtmlFileAsPdf(@"C:\Users\Tayyab Ali\Desktop\example.html");
        PDF.SaveAs("example.pdf");
        Console.WriteLine("PDF saved successfully.");
    }
}
Imports IronPdf
Friend Class Program
	Private Sub Main(ByVal args() As String)
		License.LicenseKey = "License-Key"
		' Create a new instance of IronPdf.ChromePdfRenderer
		Dim Renderer = New ChromePdfRenderer()
		' Render HTML content as PDF
		Dim PDF = Renderer.RenderHtmlFileAsPdf("C:\Users\Tayyab Ali\Desktop\example.html")
		PDF.SaveAs("example.pdf")
		Console.WriteLine("PDF saved successfully.")
	End Sub
End Class
VB   C#

A Comparison Between IronPDF & PDFSharpCore: Figure 4 - PDF Output

URL to PDF

Converting web pages to PDFs is another powerful feature of IronPDF. This capability is invaluable for capturing live web content, including styling and media, directly into a PDF document. To convert a web URL to a PDF document, you can use the following code:

using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        License.LicenseKey = "License-Key";
        // Create a new instance of IronPdf.ChromePdfRenderer
        var Renderer = new ChromePdfRenderer();
        Renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A2;
        // Render HTML content as PDF
        var PDF = Renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework");
        // Save the PDF as example.pdf
        PDF.SaveAs("webpage.pdf");
        Console.WriteLine("PDF saved successfully.");
    }
}
using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        License.LicenseKey = "License-Key";
        // Create a new instance of IronPdf.ChromePdfRenderer
        var Renderer = new ChromePdfRenderer();
        Renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A2;
        // Render HTML content as PDF
        var PDF = Renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework");
        // Save the PDF as example.pdf
        PDF.SaveAs("webpage.pdf");
        Console.WriteLine("PDF saved successfully.");
    }
}
Imports IronPdf
Friend Class Program
	Shared Sub Main(ByVal args() As String)
		License.LicenseKey = "License-Key"
		' Create a new instance of IronPdf.ChromePdfRenderer
		Dim Renderer = New ChromePdfRenderer()
		Renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A2
		' Render HTML content as PDF
		Dim PDF = Renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework")
		' Save the PDF as example.pdf
		PDF.SaveAs("webpage.pdf")
		Console.WriteLine("PDF saved successfully.")
	End Sub
End Class
VB   C#

A Comparison Between IronPDF & PDFSharpCore: Figure 5 - URL to PDF Output

PDFSharpCore: Flexibility and Control

PDFSharpCore, being a partial port of PDFsharp for .NET Core, offers detailed control over the process to create PDF documents. It doesn't directly convert HTML to PDF but provides extensive features for generating a new document from scratch or modifying existing PDF files. Here's a basic example using PDFSharpCore:

var doc = new PdfDocument();
var page = doc.AddPage();
var graphics = XGraphics.FromPdfPage(page);
var font = new XFont("Verdana", 20, XFontStyle.Bold);
graphics.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);
doc.Save("newdocument.pdf");
var doc = new PdfDocument();
var page = doc.AddPage();
var graphics = XGraphics.FromPdfPage(page);
var font = new XFont("Verdana", 20, XFontStyle.Bold);
graphics.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);
doc.Save("newdocument.pdf");
Dim doc = New PdfDocument()
Dim page = doc.AddPage()
Dim graphics = XGraphics.FromPdfPage(page)
Dim font = New XFont("Verdana", 20, XFontStyle.Bold)
graphics.DrawString("Hello, World!", font, XBrushes.Black, New XRect(0, 0, page.Width, page.Height), XStringFormats.Center)
doc.Save("newdocument.pdf")
VB   C#

A Comparison Between IronPDF & PDFSharpCore: Figure 6 - PDFSharpCore Output

Handling Complex PDF Tasks: Advanced Features

IronPDF Advanced Features

IronPDF stands out when dealing with advanced PDF tasks. It offers features such as:

PDF/A Compliance: IronPDF's capability to generate PDF/A-compliant documents is essential for businesses that require long-term digital preservation. This feature ensures that PDF files are produced in a manner that meets strict archiving standards, preserving documents' integrity over time.

using IronPdf;
// Open a PDF 
PdfDocument pdf = PdfDocument.FromFile("example.pdf");
// Save the PDF/A-3b
pdf.SaveAsPdfA("PDFA-Document.pdf", PdfAVersions.PdfA3);
using IronPdf;
// Open a PDF 
PdfDocument pdf = PdfDocument.FromFile("example.pdf");
// Save the PDF/A-3b
pdf.SaveAsPdfA("PDFA-Document.pdf", PdfAVersions.PdfA3);
Imports IronPdf
' Open a PDF 
Private pdf As PdfDocument = PdfDocument.FromFile("example.pdf")
' Save the PDF/A-3b
pdf.SaveAsPdfA("PDFA-Document.pdf", PdfAVersions.PdfA3)
VB   C#

Watermarking and Security: IronPDF provides robust tools for adding watermarks to PDF documents, which is crucial for branding and copyright protection. Additionally, it supports comprehensive security features, including the ability to encrypt PDF files, set user permissions, and add digital signatures. This ensures that sensitive information remains secure and that document integrity is maintained.

using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello, IronPdf!</h1></body></html>");
        pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE WATERMARK</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
        pdf.SecuritySettings.OwnerPassword = "top-secret"; // password to edit the pdf
        pdf.SecuritySettings.UserPassword = "sharable"; // password to open the pdf
        pdf.SaveAs("CombinedPDF.pdf");
        Console.WriteLine("PDF generated successfully!");
    }
}
using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello, IronPdf!</h1></body></html>");
        pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE WATERMARK</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
        pdf.SecuritySettings.OwnerPassword = "top-secret"; // password to edit the pdf
        pdf.SecuritySettings.UserPassword = "sharable"; // password to open the pdf
        pdf.SaveAs("CombinedPDF.pdf");
        Console.WriteLine("PDF generated successfully!");
    }
}
Imports IronPdf
Friend Class Program
	Shared Sub Main(ByVal args() As String)
		Dim renderer = New ChromePdfRenderer()
		Dim pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello, IronPdf!</h1></body></html>")
		pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE WATERMARK</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
		pdf.SecuritySettings.OwnerPassword = "top-secret" ' password to edit the pdf
		pdf.SecuritySettings.UserPassword = "sharable" ' password to open the pdf
		pdf.SaveAs("CombinedPDF.pdf")
		Console.WriteLine("PDF generated successfully!")
	End Sub
End Class
VB   C#

A Comparison Between IronPDF & PDFSharpCore: Figure 7 - Password Protected PDF Output

Editing and Merging PDFs: IronPDF goes beyond creation, offering functionalities to edit content within existing PDF files. This can include text editing, image manipulation, and layout adjustments. Moreover, its merging capability allows for the merging of multiple PDF documents into a single file, simplifying document management and distribution.

using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        const string html_a = @"<p> [PDF_A] </p>
            <p> [PDF_A] 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> [PDF_A] 2nd Page</p>";
        const string html_b = @"<p> [PDF_B] </p>
            <p> [PDF_B] 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> [PDF_B] 2nd Page</p>";
        const string html_c =
            @"<p> Hello Iron </p>
            <p> This is 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> This is 2nd Page</p>
            <div style='page-break-after: always;'></div>
            <p> This is 3rd Page</p>";
        var renderer = new ChromePdfRenderer();
        var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
        var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
        var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
        var pdfdoc_c = renderer.RenderHtmlAsPdf(html_c);
        merged.AppendPdf(pdfdoc_c);
        merged.SaveAs("CombinedDocument.pdf");
        Console.WriteLine("PDF generated successfully!");
    }
}
using IronPdf;
class Program
{
    static void Main(string [] args)
    {
        const string html_a = @"<p> [PDF_A] </p>
            <p> [PDF_A] 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> [PDF_A] 2nd Page</p>";
        const string html_b = @"<p> [PDF_B] </p>
            <p> [PDF_B] 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> [PDF_B] 2nd Page</p>";
        const string html_c =
            @"<p> Hello Iron </p>
            <p> This is 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> This is 2nd Page</p>
            <div style='page-break-after: always;'></div>
            <p> This is 3rd Page</p>";
        var renderer = new ChromePdfRenderer();
        var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
        var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
        var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
        var pdfdoc_c = renderer.RenderHtmlAsPdf(html_c);
        merged.AppendPdf(pdfdoc_c);
        merged.SaveAs("CombinedDocument.pdf");
        Console.WriteLine("PDF generated successfully!");
    }
}
Imports IronPdf
Friend Class Program
	Shared Sub Main(ByVal args() As String)
		Const html_a As String = "<p> [PDF_A] </p>
            <p> [PDF_A] 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> [PDF_A] 2nd Page</p>"
		Const html_b As String = "<p> [PDF_B] </p>
            <p> [PDF_B] 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> [PDF_B] 2nd Page</p>"
		Const html_c As String = "<p> Hello Iron </p>
            <p> This is 1st Page </p>
            <div style='page-break-after: always;'></div>
            <p> This is 2nd Page</p>
            <div style='page-break-after: always;'></div>
            <p> This is 3rd Page</p>"
		Dim renderer = New ChromePdfRenderer()
		Dim pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)
		Dim pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)
		Dim merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b)
		Dim pdfdoc_c = renderer.RenderHtmlAsPdf(html_c)
		merged.AppendPdf(pdfdoc_c)
		merged.SaveAs("CombinedDocument.pdf")
		Console.WriteLine("PDF generated successfully!")
	End Sub
End Class
VB   C#

A Comparison Between IronPDF & PDFSharpCore: Figure 8 - Edit PDF Output

PDFSharpCore Advanced Features

PDFSharpCore, while more focused on the basics, still offers capabilities for complex tasks, such as:

Document Modification: PDFSharpCore facilitates the modification of existing PDF documents. This includes tasks such as adding or removing pages, updating text, and inserting images.

using PdfSharpCore.Pdf;
using PdfSharpCore.Pdf.IO;
// Open an existing PDF document
var inputDocument = PdfReader.Open("input.pdf", PdfDocumentOpenMode.Modify);
// Modify the first page
var page = inputDocument.Pages [0];
var graphics = XGraphics.FromPdfPage(page);
var font = new XFont("OpenSans", 20, XFontStyle.Bold);
graphics.DrawString("Added Text", font, XBrushes.Black, new XPoint(50, 100));
// Save the modified document
inputDocument.Save("modified.pdf");
using PdfSharpCore.Pdf;
using PdfSharpCore.Pdf.IO;
// Open an existing PDF document
var inputDocument = PdfReader.Open("input.pdf", PdfDocumentOpenMode.Modify);
// Modify the first page
var page = inputDocument.Pages [0];
var graphics = XGraphics.FromPdfPage(page);
var font = new XFont("OpenSans", 20, XFontStyle.Bold);
graphics.DrawString("Added Text", font, XBrushes.Black, new XPoint(50, 100));
// Save the modified document
inputDocument.Save("modified.pdf");
Imports PdfSharpCore.Pdf
Imports PdfSharpCore.Pdf.IO
' Open an existing PDF document
Private inputDocument = PdfReader.Open("input.pdf", PdfDocumentOpenMode.Modify)
' Modify the first page
Private page = inputDocument.Pages (0)
Private graphics = XGraphics.FromPdfPage(page)
Private font = New XFont("OpenSans", 20, XFontStyle.Bold)
graphics.DrawString("Added Text", font, XBrushes.Black, New XPoint(50, 100))
' Save the modified document
inputDocument.Save("modified.pdf")
VB   C#

Graphics and Drawing: The library utilizes the same drawing routines available in PDFSharp, enabling developers to incorporate complex graphic elements into PDF documents. This includes drawing shapes, using different fonts, and applying color.

using PdfSharpCore.Drawing;
using PdfSharpCore.Pdf;
// Create a new PDF document
var document = new PdfDocument();
var page = document.AddPage();
var graphics = XGraphics.FromPdfPage(page);
// Draw a rectangle
graphics.DrawRectangle(XPens.Black, XBrushes.SkyBlue, 40, 100, 250, 120);
// Draw text
var font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
graphics.DrawString("Hello, PDFSharpCore!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);
// Save the document
document.Save("drawing.pdf");
using PdfSharpCore.Drawing;
using PdfSharpCore.Pdf;
// Create a new PDF document
var document = new PdfDocument();
var page = document.AddPage();
var graphics = XGraphics.FromPdfPage(page);
// Draw a rectangle
graphics.DrawRectangle(XPens.Black, XBrushes.SkyBlue, 40, 100, 250, 120);
// Draw text
var font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
graphics.DrawString("Hello, PDFSharpCore!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);
// Save the document
document.Save("drawing.pdf");
Imports PdfSharpCore.Drawing
Imports PdfSharpCore.Pdf
' Create a new PDF document
Private document = New PdfDocument()
Private page = document.AddPage()
Private graphics = XGraphics.FromPdfPage(page)
' Draw a rectangle
graphics.DrawRectangle(XPens.Black, XBrushes.SkyBlue, 40, 100, 250, 120)
' Draw text
Dim font = New XFont("Verdana", 20, XFontStyle.BoldItalic)
graphics.DrawString("Hello, PDFSharpCore!", font, XBrushes.Black, New XRect(0, 0, page.Width, page.Height), XStringFormats.Center)
' Save the document
document.Save("drawing.pdf")
VB   C#

A Comparison Between IronPDF & PDFSharpCore: Figure 9 - Graphics Output

PDF Generation from Data: PDFSharpCore excels in creating PDF documents dynamically from application data. This is especially beneficial for generating reports, invoices, or any document that requires the inclusion of dynamic data.

using PdfSharpCore.Drawing;
using PdfSharpCore.Pdf;
// Create a new PDF document
var document = new PdfDocument();
var page = document.AddPage();
var graphics = XGraphics.FromPdfPage(page);
var font = new XFont("Arial", 12);
// Simulate generation
var data = new List<string> { "Data 1", "Data 2", "Data 3" };
// Generate PDF from data
var yPos = 20;
foreach (var item in data)
{
    graphics.DrawString(item, font, XBrushes.Black, new XRect(0, yPos, page.Width, page.Height), XStringFormats.TopLeft);
    yPos += 20;
}
// Save the document
document.Save("data-generated.pdf");
using PdfSharpCore.Drawing;
using PdfSharpCore.Pdf;
// Create a new PDF document
var document = new PdfDocument();
var page = document.AddPage();
var graphics = XGraphics.FromPdfPage(page);
var font = new XFont("Arial", 12);
// Simulate generation
var data = new List<string> { "Data 1", "Data 2", "Data 3" };
// Generate PDF from data
var yPos = 20;
foreach (var item in data)
{
    graphics.DrawString(item, font, XBrushes.Black, new XRect(0, yPos, page.Width, page.Height), XStringFormats.TopLeft);
    yPos += 20;
}
// Save the document
document.Save("data-generated.pdf");
Imports PdfSharpCore.Drawing
Imports PdfSharpCore.Pdf
' Create a new PDF document
Private document = New PdfDocument()
Private page = document.AddPage()
Private graphics = XGraphics.FromPdfPage(page)
Private font = New XFont("Arial", 12)
' Simulate generation
Private data = New List(Of String) From {"Data 1", "Data 2", "Data 3"}
' Generate PDF from data
Private yPos = 20
For Each item In data
	graphics.DrawString(item, font, XBrushes.Black, New XRect(0, yPos, page.Width, page.Height), XStringFormats.TopLeft)
	yPos += 20
Next item
' Save the document
document.Save("data-generated.pdf")
VB   C#

Conclusion

A Comparison Between IronPDF & PDFSharpCore: Figure 10 - Licensing

When it comes to integrating PDF functionality into your .NET projects, the choice between IronPDF and PDFSharpCore merits careful consideration, with a particular edge going to IronPDF for several compelling reasons. IronPDF distinguishes itself with a more extensive array of features and capabilities, especially for developers prioritizing web applications and comprehensive PDF processing needs.

IronPDF excels in its ease of use and flexibility, enabling developers to effortlessly convert HTML to PDFs, a crucial feature for modern web applications where content is frequently generated and presented in HTML format. Moreover, IronPDF supports advanced PDF features like editing, merging, security, and compliance with PDF/A standards, providing a robust toolkit for managing complex PDF operations.

IronPDF distinguishes itself not only through its comprehensive suite of features but also by offering a free trial, allowing developers to explore its capabilities firsthand without any initial investment. For those ready to integrate IronPDF into their development workflow, licensing begins at $749.

< PREVIOUS
A Comparison of Splitting PDF in C# Between iTextSharp and IronPDF
NEXT >
A Comparison Between IronPDF & Apryse C#

Ready to get started? Version: 2024.12 just released

Free NuGet Download Total downloads: 11,622,374 View Licenses >