Skip to footer content
USING IRONPDF

How to Create PDFs Using Aspose.PDF

Both Aspose PDF and IronPDF enable you to create PDF documents programmatically, with IronPDF offering simpler HTML-to-PDF conversion using Chrome rendering while Aspose PDF provides granular control through its document object model.

IronPDF C# PDF Library homepage banner showing key features including HTML to PDF conversion, PDF editing capabilities, flexible deployment options, and free trial offer

What Prerequisites Do You Need?

Before starting to create a PDF file, ensure you have:

  • .NET Framework 4.6.2+ or .NET Core 3.1+
  • Visual Studio 2019 or compatible IDE
  • Basic knowledge of C# programming
  • NuGet Package Manager configured
  • Administrative privileges for package installation

For cloud deployment, additional requirements include proper container configuration and runtime permissions. Both libraries support Windows, Linux, and macOS environments with specific installation considerations for each platform.

Cross-platform support diagram showing compatibility with C#, F#, and VB.NET across multiple .NET versions, operating systems, and deployment environments including Windows, Linux, Mac, Docker, Azure, and AWS

How Do You Install Aspose PDF and IronPDF?

How Do You Install Aspose PDF via Package Manager Console?

Open the Package Manager Console in Visual Studio and run the following command:

PM> Install-Package Aspose.PDF
PM> Install-Package Aspose.PDF
This command is a package manager command for installing a NuGet package and is not directly translatable to VB.NET code. If you are looking to use the Aspose.PDF library in a VB.NET project, you would typically add the package via the NuGet Package Manager in Visual Studio or use a similar command in the Package Manager Console. If you have specific C# code using Aspose.PDF that you need converted to VB.NET, please provide that code.
$vbLabelText   $csharpLabel

The installation process downloads Aspose.PDF along with its dependencies. The library requires approximately 150MB of disk space and includes complete documentation. For advanced installation scenarios, you may need to configure additional dependencies manually.

Package Manager Console showing successful installation of Aspose.PDF version 25.10.0 and its dependencies in Visual Studio

How Do You Install IronPDF?

Use the same method to install IronPDF:

PM> Install-Package IronPdf
PM> Install-Package IronPdf
SHELL

The IronPDF installation automatically includes the Chrome rendering engine and all necessary dependencies. For Docker deployments, additional configuration may be required to ensure proper rendering capabilities.

Package Manager Console showing the installation progress of IronPDF NuGet package with multiple dependencies being downloaded

Why Does IronPDF Include an Embedded Chrome Engine?

IronPDF includes an embedded Chrome engine for superior HTML rendering, with support for Windows, Linux, macOS, Docker containers, and cloud platforms. This ensures pixel-perfect rendering matching what you see in Chrome browser, including full support for modern CSS3, JavaScript, and web fonts.

IronPDF feature comparison showing three key benefits: pixel-perfect rendering, 5-minute setup, and cross-platform compatibility with supporting details for each

How Do You Create Your First PDF Document?

Let's create PDF files with both libraries to understand their fundamental approaches. These code examples demonstrate the basic logic for PDF generation, demonstrating the different philosophies behind each library's API design.

How Does Aspose PDF Create Documents?

using Aspose.Pdf;
using Aspose.Pdf.Text;
// Create new instance of Document class
var document = new Document();
// Add pages to the document object
var page = document.Pages.Add();
// Create new TextFragment with Hello World text
var textFragment = new TextFragment("Hello World!");
textFragment.TextState.FontSize = 24;
// Add text to paragraphs collection
page.Paragraphs.Add(textFragment);
// Save the generated PDF document
document.Save("output.pdf");
using Aspose.Pdf;
using Aspose.Pdf.Text;
// Create new instance of Document class
var document = new Document();
// Add pages to the document object
var page = document.Pages.Add();
// Create new TextFragment with Hello World text
var textFragment = new TextFragment("Hello World!");
textFragment.TextState.FontSize = 24;
// Add text to paragraphs collection
page.Paragraphs.Add(textFragment);
// Save the generated PDF document
document.Save("output.pdf");
Imports Aspose.Pdf
Imports Aspose.Pdf.Text

' Create new instance of Document class
Dim document As New Document()
' Add pages to the document object
Dim page As Page = document.Pages.Add()
' Create new TextFragment with Hello World text
Dim textFragment As New TextFragment("Hello World!")
textFragment.TextState.FontSize = 24
' Add text to paragraphs collection
page.Paragraphs.Add(textFragment)
' Save the generated PDF document
document.Save("output.pdf")
$vbLabelText   $csharpLabel

This code creates PDF documents by building a document object model. You create a new document, add pages to the collection, and then add content to those pages. The Document class provides the foundation, while paragraphs hold your content. This Hello World example demonstrates the basic process. The approach requires understanding Aspose's object hierarchy and managing fonts explicitly.

What Does the Aspose PDF Output Look Like?

PDF viewer displaying a simple 'Hello World!' document created with Aspose.PDF, showing the evaluation watermark at the top

How Does IronPDF Create Documents?

using IronPdf;
// Create new instance of ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Convert HTML string to PDF file
var html = "<h1>Hello World!</h1>";
var pdf = renderer.RenderHtmlAsPdf(html);
// Save PDF files using SaveAs method
pdf.SaveAs("output.pdf");
using IronPdf;
// Create new instance of ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Convert HTML string to PDF file
var html = "<h1>Hello World!</h1>";
var pdf = renderer.RenderHtmlAsPdf(html);
// Save PDF files using SaveAs method
pdf.SaveAs("output.pdf");
Imports IronPdf

' Create new instance of ChromePdfRenderer
Dim renderer As New ChromePdfRenderer()

' Convert HTML string to PDF file
Dim html As String = "<h1>Hello World!</h1>"
Dim pdf = renderer.RenderHtmlAsPdf(html)

' Save PDF files using SaveAs method
pdf.SaveAs("output.pdf")
$vbLabelText   $csharpLabel

IronPDF takes a different approach — it renders HTML directly to PDF format using Chrome. This API allows you to convert web content and implement complex layouts easily. The library manages the complexity for you, making it simpler to achieve professional results. You can also render from files, URLs, or even Razor views.

What Does the IronPDF Output Look Like?

PDF viewer displaying a simple 'Hello World!' document with Iron Software watermarks in a diagonal pattern across the page

How Do You Create a Real-World Invoice PDF?

Here's complete code to create PDF files using both libraries for a practical invoice solution. Invoice generation represents one of the most common use cases for PDF libraries in business applications.

How Do You Build an Invoice with Aspose PDF?

using Aspose.Pdf;
using Aspose.Pdf.Text;
// Create new Document instance
var document = new Document();
var page = document.Pages.Add();
// Add title text
var title = new TextFragment("INVOICE");
title.TextState.FontSize = 28;
title.HorizontalAlignment = HorizontalAlignment.Center;
// Add to paragraphs
page.Paragraphs.Add(title);
// Create table object for invoice items
var table = new Table();
table.ColumnWidths = "200 100 100";
// Add header row to table
var headerRow = table.Rows.Add();
headerRow.Cells.Add("Description");
headerRow.Cells.Add("Quantity");
headerRow.Cells.Add("Price");
// Add data rows
var dataRow = table.Rows.Add();
dataRow.Cells.Add("Product A");
dataRow.Cells.Add("2");
dataRow.Cells.Add("$50.00");
// Add table to page paragraphs
page.Paragraphs.Add(table);
// Save the PDF document
document.Save("invoice.pdf");
using Aspose.Pdf;
using Aspose.Pdf.Text;
// Create new Document instance
var document = new Document();
var page = document.Pages.Add();
// Add title text
var title = new TextFragment("INVOICE");
title.TextState.FontSize = 28;
title.HorizontalAlignment = HorizontalAlignment.Center;
// Add to paragraphs
page.Paragraphs.Add(title);
// Create table object for invoice items
var table = new Table();
table.ColumnWidths = "200 100 100";
// Add header row to table
var headerRow = table.Rows.Add();
headerRow.Cells.Add("Description");
headerRow.Cells.Add("Quantity");
headerRow.Cells.Add("Price");
// Add data rows
var dataRow = table.Rows.Add();
dataRow.Cells.Add("Product A");
dataRow.Cells.Add("2");
dataRow.Cells.Add("$50.00");
// Add table to page paragraphs
page.Paragraphs.Add(table);
// Save the PDF document
document.Save("invoice.pdf");
Imports Aspose.Pdf
Imports Aspose.Pdf.Text

' Create new Document instance
Dim document As New Document()
Dim page = document.Pages.Add()

' Add title text
Dim title As New TextFragment("INVOICE")
title.TextState.FontSize = 28
title.HorizontalAlignment = HorizontalAlignment.Center

' Add to paragraphs
page.Paragraphs.Add(title)

' Create table object for invoice items
Dim table As New Table()
table.ColumnWidths = "200 100 100"

' Add header row to table
Dim headerRow = table.Rows.Add()
headerRow.Cells.Add("Description")
headerRow.Cells.Add("Quantity")
headerRow.Cells.Add("Price")

' Add data rows
Dim dataRow = table.Rows.Add()
dataRow.Cells.Add("Product A")
dataRow.Cells.Add("2")
dataRow.Cells.Add("$50.00")

' Add table to page paragraphs
page.Paragraphs.Add(table)

' Save the PDF document
document.Save("invoice.pdf")
$vbLabelText   $csharpLabel

The Aspose PDF .NET API requires building each element programmatically. You create the document object, add pages, and then add content to the paragraphs collection. This approach provides clear benefits when you need precise control but requires more code to achieve complex layouts. For more advanced features like adding headers and footers or custom margins, additional configuration is needed.

How Do You Build an Invoice with IronPDF?

using IronPdf;
var renderer = new ChromePdfRenderer();
// Configure PDF output settings
renderer.RenderingOptions.MarginTop = 25;
renderer.RenderingOptions.MarginBottom = 25;
// HTML string with invoice content
var html = @"
<html>
<head>
    <style>
        table { width: 100%; }
        th, td { padding: 8px; }
    </style>
</head>
<body>
    <h1>INVOICE</h1>
    <table>
        <tr>
            <th>Description</th>
            <th>Quantity</th>
            <th>Price</th>
        </tr>
        <tr>
            <td>Product A</td>
            <td>2</td>
            <td>$50.00</td>
        </tr>
    </table>
</body>
</html>";
// Generate PDF from HTML
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("invoice.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
// Configure PDF output settings
renderer.RenderingOptions.MarginTop = 25;
renderer.RenderingOptions.MarginBottom = 25;
// HTML string with invoice content
var html = @"
<html>
<head>
    <style>
        table { width: 100%; }
        th, td { padding: 8px; }
    </style>
</head>
<body>
    <h1>INVOICE</h1>
    <table>
        <tr>
            <th>Description</th>
            <th>Quantity</th>
            <th>Price</th>
        </tr>
        <tr>
            <td>Product A</td>
            <td>2</td>
            <td>$50.00</td>
        </tr>
    </table>
</body>
</html>";
// Generate PDF from HTML
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("invoice.pdf");
Imports IronPdf

Dim renderer As New ChromePdfRenderer()
' Configure PDF output settings
renderer.RenderingOptions.MarginTop = 25
renderer.RenderingOptions.MarginBottom = 25
' HTML string with invoice content
Dim html As String = "
<html>
<head>
    <style>
        table { width: 100%; }
        th, td { padding: 8px; }
    </style>
</head>
<body>
    <h1>INVOICE</h1>
    <table>
        <tr>
            <th>Description</th>
            <th>Quantity</th>
            <th>Price</th>
        </tr>
        <tr>
            <td>Product A</td>
            <td>2</td>
            <td>$50.00</td>
        </tr>
    </table>
</body>
</html>"
' Generate PDF from HTML
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("invoice.pdf")
$vbLabelText   $csharpLabel

With IronPDF, you write standard HTML and the implementation handles the rendering automatically. This method makes it easier to create PDF files with professional layouts. Your application can immediately use this feature by referencing external stylesheets, adding images, and including links. The rendering options provide fine control over the output, including custom paper sizes, page orientation, and print CSS.

What Does the Invoice Output Look Like?

Example of a basic PDF invoice generated programmatically, displaying product information in a table format with visible watermark overlay

What Advanced Features Are Available?

Both libraries offer extensive capabilities beyond basic PDF creation. Understanding these advanced features helps you determine which library best suits your specific requirements.

How Do You Convert Web Pages to PDF?

using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_91___");
pdf.SaveAs("website.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_91___");
pdf.SaveAs("website.pdf");
Imports IronPdf

Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_91___")
pdf.SaveAs("website.pdf")
$vbLabelText   $csharpLabel

IronPDF excels at URL to PDF conversion, handling complex websites with JavaScript, cookies, and authentication. The Chrome engine ensures accurate rendering of modern web applications, including Angular and React sites.

How Do You Add Security to PDFs?

using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
// Implement security settings
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// Save secured file
pdf.SaveAs("secured.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
// Implement security settings
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// Save secured file
pdf.SaveAs("secured.pdf");
Imports IronPdf

Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
' Implement security settings
pdf.SecuritySettings.UserPassword = "user123"
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights
' Save secured file
pdf.SaveAs("secured.pdf")
$vbLabelText   $csharpLabel

IronPDF provides intuitive methods to add security, headers, footers, and other features to your PDF documents. You can also delete pages, merge files, or extract content. Advanced security features include digital signatures, encryption, and metadata management.

What Does a Secured PDF Look Like?

Password protection dialog box for a secured PDF file showing a password input field and submit button

Additional Advanced Features

IronPDF supports numerous advanced scenarios including:

Which Library Should You Choose?

When Should You Use IronPDF?

IronPDF excels when you:

Feature comparison chart showing four categories of PDF functionality: Create PDFs, Convert PDFs, Edit PDFs, and Sign and Secure PDFs, with detailed feature lists under each category

When Should You Use Aspose PDF?

Aspose PDF for .NET applications works well when you:

  • Create PDFs from scratch programmatically
  • Need granular control over document model
  • Work with complex PDF manipulations
  • Import existing PDF files for processing
  • Require specific PDF format compliance
  • Build document-centric applications

Performance Considerations

IronPDF's Chrome engine provides excellent performance for HTML rendering, while Aspose PDF may perform better for purely programmatic PDF generation. For async operations, both libraries offer complete support. Consider memory usage and rendering timeouts for large-scale deployments.

How Do the Licenses Compare?

IronPDF offers straightforward licensing starting at $799, including support and updates. The free trial includes all features without watermarks for development and testing. License deployment is simple with multiple configuration options.

IronPDF licensing page showing four pricing tiers (Lite, Plus, Professional, and Unlimited) with discounted prices and features for each plan

Aspose PDF starts at $1,199 with additional costs for support. Both libraries offer evaluation versions for testing purposes. IronPDF provides more flexible licensing options including project-based and SaaS licensing models.

Conclusion

Both libraries effectively create PDF documents in C#. Aspose PDF provides granular control through its document object model and TextFragment class, while IronPDF shines with HTML-to-PDF conversion using familiar web technologies.

For most modern .NET applications, IronPDF offers better value with its intuitive API, superior HTML rendering, included support, and the ability to create PDF files using simple code. Whether you need to load web pages, add images, or implement complex layouts, IronPDF's Chrome-based function simplify the process. The library's extensive feature set covers everything from basic PDF creation to advanced signing and security.

IronPDF also includes drawing capabilities and can reproduce complex designs. For questions, contact their engineering team or search their documentation to resolve any issues. The library supports various deployment scenarios including Azure Functions, AWS Lambda, and Blazor applications.

Start with IronPDF's free trial to evaluate how it can meet your PDF generation needs. Access all features to create, convert, and manipulate PDF files in your .NET solution.

Frequently Asked Questions

What is the primary purpose of using Aspose C# and IronPDF for PDF creation?

The primary purpose of using Aspose C# and IronPDF is to create PDF files programmatically for modern .NET applications, such as generating invoices, reports, or converting web content to PDF format.

How does IronPDF enhance PDF creation in .NET applications?

IronPDF enhances PDF creation in .NET applications by providing comprehensive tools and code examples that simplify the process, making it easier for developers to generate and manipulate PDFs.

Can I use IronPDF to convert web content into a PDF format?

Yes, IronPDF allows you to convert web content into PDF format seamlessly, which is ideal for creating accurate and professional-looking documents from HTML sources.

What are some typical use cases for generating PDFs using IronPDF?

Typical use cases for generating PDFs using IronPDF include creating invoices, generating reports, and converting web pages or HTML content into PDF documents.

Does IronPDF offer complete code examples for developers?

Yes, IronPDF provides complete code examples to assist developers in efficiently using the library to create and manage PDF files.

Is it possible to integrate IronPDF with other .NET libraries for enhanced functionality?

Yes, IronPDF can be integrated with other .NET libraries, such as Aspose C#, to enhance the functionality and capabilities of PDF creation and manipulation.

What are the advantages of using IronPDF over other PDF libraries?

Advantages of using IronPDF include its ease of use, comprehensive documentation, and the availability of complete code examples, which make it a versatile choice for developers.

Can IronPDF handle complex PDF generation tasks such as adding watermarks or headers?

Yes, IronPDF can handle complex PDF generation tasks, including adding watermarks, headers, and footers to documents, providing flexibility in document customization.

Is IronPDF suitable for beginners in .NET development?

IronPDF is suitable for both beginners and experienced developers, as it offers user-friendly features and detailed documentation to guide users through the PDF creation process.

How does IronPDF ensure the quality of generated PDF documents?

IronPDF ensures high-quality PDF documents by offering robust tools for precise layout control and support for a wide range of PDF features and standards.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More