Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
PDF, or Portable Document Format, is a file format developed by Adobe for easy document exchange. It ensures that documents look the same on any device, preserving formatting, fonts, and images. PDFs are secure, interactive, and compact, making them perfect for sharing while keeping the content intact.
C# PDF libraries are essential for developers working with PDFs. These tools help create, modify, and extract content from PDFs. They support features like form handling, and digital signatures, and work across different platforms, improving the efficiency of PDF processing. With C# PDF libraries, developers can add PDF functionality to their applications, making it easier to create, edit, and manage PDF documents programmatically.
In this article, we will compare two different approaches to working with PDFs: the IronPDF C# library and the Craftmypdf API. We'll look at their features, and functionality, provide code examples, and discuss their licenses.
CraftMyPDF is a versatile API designed to create PDF documents. It offers a web-based drag-and-drop editor, allowing you to design PDF templates directly in your browser. This feature is particularly useful for creating pixel-perfect PDFs from reusable templates and JSON data. The editor includes a rich set of layout components, supporting powerful expressions, advanced formatting, and data binding, making it a robust tool for various PDF generation needs.
Drag-and-Drop Editor: CraftMyPDF's intuitive drag-and-drop editor simplifies the creation of PDF templates. You can design templates without any coding knowledge, making it accessible to users of all skill levels. This editor allows you to add various elements such as text, images, and shapes, and customize their layout and appearance.
Template Reusability: The platform supports reusable templates, which can be a huge time-saver. Once a template is designed, it can be used repeatedly with different data sets, making it ideal for generating documents like invoices, reports, and certificates. You can edit it using PDF template editor.
JSON Data Integration: CraftMyPDF allows seamless integration with JSON data. This means you can feed dynamic data into your templates to generate customized PDF documents. This feature is particularly useful for applications that need to produce documents with variable content, such as personalized invoices or detailed reports.
Advanced Formatting and Expressions: The API supports advanced formatting options and expressions, enabling you to create complex documents. You can format dates, numbers, and currencies according to your specifications and use expressions to dynamically generate content based on your data.
API Integrations: CraftMyPDF can be integrated with various platforms using its REST API. It supports integration with no-code platforms like Zapier and Make.com, as well as custom applications. This flexibility allows developers to incorporate PDF generation capabilities into their workflows and automate document creation processes.
Fillable Components: The platform also supports fillable PDF components such as text fields, checkboxes, and dropdowns. This feature is essential for creating interactive forms that users can complete electronically.
IronPDF PDF Library for .NET Developers is a robust and versatile PDF library designed for .NET developers, providing extensive capabilities for generating, editing, and managing PDF documents. Written in C#, IronPDF simplifies the process of working with PDFs by allowing developers to generate pixel-perfect PDF documents from HTML, CSS, JavaScript, and image formats. Its integration with .NET makes it a powerful tool for any application requiring PDF functionality, from simple file generation to complex document manipulation.
HTML to PDF Conversion IronPDF excels in converting HTML, CSS, and JavaScript directly into PDF documents. This includes support for HTML5 and CSS3, ensuring that your web content looks as intended in the generated PDFs. The conversion process maintains pixel-perfect accuracy, making it ideal for web-to-print applications.
URL to PDF You can generate PDFs from any URL, allowing web pages to be saved as PDF files with ease. This feature is useful for archiving web content or generating reports from online data.
Image to PDF IronPDF supports converting various image formats, including JPG, PNG, GIF, BMP, and SVG, into PDF documents. This feature is handy for creating photo books, image galleries, or integrating visual content into your PDFs.
Form Filling and Data Extraction The library allows for both creating and filling PDF forms programmatically. Additionally, you can extract data from existing forms, enabling seamless data processing and integration with other systems.
Digital Signatures and Security IronPDF provides robust security features, including the ability to add digital signatures, set passwords, and define user permissions. This ensures that your PDF documents are secure and compliant with industry standards.
PDF Editing You can edit existing PDF documents by adding, copying, or deleting pages. You can do it by importing existing PDF files. IronPDF also allows for merging and splitting PDFs, making it a comprehensive tool for document management.
Annotations and Attachments IronPDF supports adding annotations such as sticky notes, and embedding attachments within PDF documents. This feature is useful for collaborative document reviews and adding supplementary information.
Headers, Footers, and Watermarks The library enables custom headers, footers, and watermarks to be added to your PDF documents. These elements can be generated from HTML, providing flexibility in design and content management.
Cross-Platform Compatibility IronPDF works seamlessly across various platforms, including Windows, macOS, Linux, Docker, Azure, and AWS. It supports .NET Core, .NET Standard, and .NET Framework, ensuring broad compatibility and ease of deployment in diverse environments.
Performance Optimization With full multithreading and asynchronous support, IronPDF optimizes performance for batch processing and high-volume PDF generation tasks. This ensures efficient use of resources and faster document processing.
Comprehensive Documentation and Support IronPDF comes with extensive documentation, tutorials, and examples, making it easy for developers to get started. The library also offers 24/5 technical support, helping users resolve issues promptly.
IronPDF is designed to enhance productivity and streamline PDF management within .NET applications. Its rich feature set, combined with ease of use and comprehensive support, makes it an invaluable tool for developers.
Creating a C# console application in Visual Studio involves several steps. Below is a detailed guide to help you set up and start your project.
First, make sure that Visual Studio is installed on your computer. Open Visual Studio by searching for it in the Start menu or by clicking its desktop icon.
Once Visual Studio is open, follow these steps to create a new project:
Click on "Create a new project" on the start page.
From the search results or list, select "Console App (.NET Core)" or "Console App (.NET Framework)", depending on your preference or the requirements of your project.
After selecting the console app template, you will need to configure your new project:
Project Name: Enter a name for your project. This will be the name of the folder where your project files will be saved.
Location: Choose the folder where you want to save your project.
Solution Name: This is typically the same as your project name, but you can change it if you plan to have multiple projects in one solution.
To get started with IronPDF, you have three main installation methods: using the NuGet Package Manager, the NuGet Package Manager Console, and downloading from the NuGet website.
First, let's talk about the NuGet Package Manager. If you're using Visual Studio, this method is straightforward and user-friendly. Open your project and right-click on the "References" or "Dependencies" node in Solution Explorer. Select "Manage NuGet Packages" from the context menu.
In the NuGet Package Manager, ensure the "Browse" tab is selected, then type "IronPDF" into the search box. Once you locate the IronPDF package, click "Install." This action will add the IronPDF library to your project and configure it for use.
Next, the NuGet Package Manager Console offers another convenient way to install IronPDF. To access this, go to the "Tools" menu in Visual Studio, choose "NuGet Package Manager," and then select "Package Manager Console." Type the following command in the console window:
Install-Package IronPdf
Install-Package IronPdf
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'Install-Package IronPdf
and press Enter. This command will download and install the IronPDF package directly into your project. This method is efficient for those who prefer working with command-line tools within the Visual Studio environment.
Lastly, you can download the IronPDF package directly from the NuGet website. This method is particularly useful if you need to manually manage package versions or if you're working in an environment where direct package management is restricted. Go to the NuGet website and search for "IronPDF." Download the package file (usually a .nupkg file).
Once downloaded, open your project in Visual Studio, right-click on "References" or "Dependencies," and select "Manage NuGet Packages." Click on the "Settings" icon, then choose "Add" to specify the path to your downloaded package. After adding the package source, return to the "Browse" tab, select your new source, and install IronPDF from there.
To use CraftMyPDF in your C# program, you first need to create an account, select the free plan for the API, and then integrate it into your application. Here’s how you can get started:
Sign Up Visit the CraftMyPDF website and sign up for a free account. Enter the required information to create your account.
Ensure you have the System.Net.Http, RestShart, and Newtonsoft JSON namespace available, as it is essential for making HTTP requests to the CraftMyPDF API.
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
IRON VB CONVERTER ERROR developers@ironsoftware.com
After that, we'll make an API call to the CraftMyPDF API.
var client = new RestClient("https://api.craftmypdf.com/v1/create");
var request = new RestRequest("https://api.craftmypdf.com/v1/create",Method.Post);
string apiKey = "API Key"; // Replace with your actual API key
string templateId = "Template ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
var client = new RestClient("https://api.craftmypdf.com/v1/create");
var request = new RestRequest("https://api.craftmypdf.com/v1/create",Method.Post);
string apiKey = "API Key"; // Replace with your actual API key
string templateId = "Template ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
IRON VB CONVERTER ERROR developers@ironsoftware.com
Creating PDFs programmatically allows you to automate the generation of documents such as reports, invoices, and certificates. IronPDF offers several methods to create PDFs in C#, including converting HTML strings, URLs, and HTML files into PDF documents. We will discuss the methods in more detail in the later sections.
Converting HTML to PDF is one of the most common use cases. It allows you to design your document using HTML and CSS and then convert it into a PDF. This method is highly flexible, as it supports modern web standards and ensures that the resulting PDF looks exactly as designed. Here’s a basic example of converting an HTML string to a PDF document using IronPDF:
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtml()
var renderer = new ChromePdfRenderer();
// Define your HTML string
string htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a sample PDF document created from an HTML string.</p>";
// Render the HTML as a PDF document
var pdfDocument = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF document
pdfDocument.SaveAs("html_output.pdf");
}
}
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtml()
var renderer = new ChromePdfRenderer();
// Define your HTML string
string htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a sample PDF document created from an HTML string.</p>";
// Render the HTML as a PDF document
var pdfDocument = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF document
pdfDocument.SaveAs("html_output.pdf");
}
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
In this example, the ChromePdfRenderer converts the provided HTML string into a PDF. The rendered PDF is then saved to the file system.
Another powerful feature of IronPDF is its ability to convert web pages into PDF documents directly from their URLs. This is particularly useful for archiving web pages or generating PDFs from dynamic web content. Below is an example of how to convert a URL to a PDF document:
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromUrl(string url)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the URL as a PDF document
var pdfDocument = renderer.RenderUrlAsPdf(url);
// Save the PDF document
pdfDocument.SaveAs("url_output.pdf");
}
}
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromUrl(string url)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the URL as a PDF document
var pdfDocument = renderer.RenderUrlAsPdf(url);
// Save the PDF document
pdfDocument.SaveAs("url_output.pdf");
}
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
This method takes a URL as input, renders the web page into a PDF, and saves the resulting document. It handles all web content, including HTML, CSS, JavaScript, and images, ensuring the PDF accurately reflects the original web page.
Converting an HTML file to a PDF is similar to converting an HTML string or URL. This method allows you to use local HTML files, making it convenient for generating PDFs from pre-existing web pages or templates stored on the file system. Here’s how you can convert an HTML file to a PDF:
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtmlFile(string filePath)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the HTML file as a PDF document
var pdfDocument = renderer.RenderHtmlFileAsPdf(filePath);
// Save the PDF document
pdfDocument.SaveAs("html_file_output.pdf");
}
}
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtmlFile(string filePath)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the HTML file as a PDF document
var pdfDocument = renderer.RenderHtmlFileAsPdf(filePath);
// Save the PDF document
pdfDocument.SaveAs("html_file_output.pdf");
}
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
In this example, the RenderHtmlFileAsPdf method is used to convert the content of an HTML file specified by its file path into a PDF document. The resulting PDF is then saved.
By leveraging these methods, you can utilize IronPDF to create PDFs from various sources of HTML content, providing a flexible and powerful solution for document generation in your C# applications. These methods ensure that you can easily integrate PDF creation capabilities, whether you're working with dynamic web content, local HTML files, or directly defined HTML strings.
CraftMyPDF provides a flexible API for generating PDFs from templates. To create a PDF using this API, you must first create a template in the CraftMyPDF dashboard. Once your template is ready, you can send a request to the API with the necessary data to generate the PDF. Here are the steps to achieve this.
Log in to CraftMyPDF Dashboard Sign in to your CraftMyPDF account and navigate to the dashboard.
Create a New Template Click on the "Create Template" button. Use the drag-and-drop editor to design your PDF template. You can include text, images, tables, and other elements as required.
After creating your template, you can use the following C# code to generate a PDF by sending a request to the CraftMyPDF API.
using System;
using System.Net;
using System.Threading.Tasks;
using RestSharp;
class Program
{
static async Task Main(string[] args)
{
var client = new RestClient("https://api.craftmypdf.com/v1/create");
var request = new RestRequest(Method.Post);
string apiKey = "API-Key"; // Replace with your actual API key
string templateId = "Template-ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
var body = new
{
data = new
{
invoice_number = "INV48321",
date = "2024-05-27",
due_date = "2024-06-27",
currency = "EUR",
discount = 10,
tax = 5,
company_name = "Tech Innovations Ltd",
email = "contact@techinnovations.com",
client = "Future Solutions GmbH",
client_address = "1234 Innovation Drive",
client_address2 = "Berlin",
client_address3 = "10115",
items = new[]
{
new { description = "Cloud Hosting Services", quantity = 12, unit_price = 75, total = 900 },
new { description = "Custom Web Application", quantity = 3, unit_price = 150, total = 450 },
new { description = "Technical Support", quantity = 15, unit_price = 30, total = 450 },
new { description = "Digital Marketing Campaign", quantity = 2, unit_price = 500, total = 1000 },
new { description = "SEO Optimization", quantity = 5, unit_price = 120, total = 600 }
},
gross_total = 3400
},
load_data_from = (string)null,
template_id = templateId,
version = 8,
export_type = "json",
expiration = 60,
output_file = "output.pdf",
is_cmyk = false,
image_resample_res = 600,
direct_download = 0,
cloud_storage = 1
};
request.AddJsonBody(body);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
if (response.IsSuccessful)
{
var content = response.Content;
dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
string fileUrl = result.file;
string localPath = "f:\\downloaded_output.pdf";
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(fileUrl, localPath);
}
Console.WriteLine($"PDF downloaded successfully to {localPath}");
}
else
{
Console.WriteLine($"Error: {response.Content}");
}
}
}
using System;
using System.Net;
using System.Threading.Tasks;
using RestSharp;
class Program
{
static async Task Main(string[] args)
{
var client = new RestClient("https://api.craftmypdf.com/v1/create");
var request = new RestRequest(Method.Post);
string apiKey = "API-Key"; // Replace with your actual API key
string templateId = "Template-ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
var body = new
{
data = new
{
invoice_number = "INV48321",
date = "2024-05-27",
due_date = "2024-06-27",
currency = "EUR",
discount = 10,
tax = 5,
company_name = "Tech Innovations Ltd",
email = "contact@techinnovations.com",
client = "Future Solutions GmbH",
client_address = "1234 Innovation Drive",
client_address2 = "Berlin",
client_address3 = "10115",
items = new[]
{
new { description = "Cloud Hosting Services", quantity = 12, unit_price = 75, total = 900 },
new { description = "Custom Web Application", quantity = 3, unit_price = 150, total = 450 },
new { description = "Technical Support", quantity = 15, unit_price = 30, total = 450 },
new { description = "Digital Marketing Campaign", quantity = 2, unit_price = 500, total = 1000 },
new { description = "SEO Optimization", quantity = 5, unit_price = 120, total = 600 }
},
gross_total = 3400
},
load_data_from = (string)null,
template_id = templateId,
version = 8,
export_type = "json",
expiration = 60,
output_file = "output.pdf",
is_cmyk = false,
image_resample_res = 600,
direct_download = 0,
cloud_storage = 1
};
request.AddJsonBody(body);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
if (response.IsSuccessful)
{
var content = response.Content;
dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
string fileUrl = result.file;
string localPath = "f:\\downloaded_output.pdf";
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(fileUrl, localPath);
}
Console.WriteLine($"PDF downloaded successfully to {localPath}");
}
else
{
Console.WriteLine($"Error: {response.Content}");
}
}
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
And it is the generated PDF document by the PDF Generation API CraftMyPdf:
Set Up RestClient and RestRequest A RestClient is instantiated with the CraftMyPDF API URL, and a RestRequest is created for the POST method to generate the PDF.
Add Headers The API key is added to the request headers for authentication. The content type is set to application/json.
Prepare Request Body The request body is created as a JSON object. It includes the data to populate the template fields, the template ID, and various options such as the export type and expiration.
Send Request The request is sent asynchronously using ExecuteAsync and it generates PDF documents based on the request body.
IronPDF offers various licensing options to cater to different user needs. The primary licenses include Lite, Professional, and Enterprise editions. The Lite license, priced at $749, is suitable for single developers working on one project. The Professional license costs $1,499 and supports multiple projects and developers, while the Enterprise license is designed for larger teams and more extensive deployment, is priced at $2,999. Each license is a one-time fee and includes one year of support and updates. Additionally, there is an OEM Redistribution License that allows for the distribution of IronPDF as part of a commercial product. IronPDF also provides a free trial for evaluation purposes.
CraftMyPDF operates on a subscription-based licensing model. It offers several plans, including a free tier suitable for small-scale and development purposes. The free plan allows limited usage of the API, which is ideal for testing and small projects. For higher usage, there are paid plans that provide increased API call limits and additional features. These paid plans are designed to scale with the needs of the business, offering flexibility and robust support. Users need to subscribe to these plans through the CraftMyPDF website and can manage their subscription and API keys via the user dashboard.
IronPDF offers extensive documentation and robust support to help users effectively utilize the library. The documentation is comprehensive and includes detailed guides, examples, and a QuickStart section to help new users get up and running quickly. Key sections cover basic usage, advanced configurations, and troubleshooting. Additionally, IronPDF provides support through various channels, including an extensive knowledge base, email support, and engineering support requests for more complex issues. The support team is available 24/5, offering prompt assistance to resolve user queries and issues.
CraftMyPDF also offers thorough documentation and support for its users. The API documentation provides detailed information on all available endpoints, parameters, and example requests, ensuring developers can integrate the API smoothly. The documentation includes guides on creating templates, making API requests, and handling responses. CraftMyPDF provides customer support through email and offers a community forum where users can ask questions and share insights. The documentation is designed to be user-friendly, ensuring that developers of all skill levels can effectively use the API to generate PDFs.
In this article, we have explored the features, licensing, and documentation of two powerful tools for generating PDFs: IronPDF and CraftMyPDF. Both tools offer robust capabilities for creating and managing PDF documents, but IronPDF stands out with several distinct advantages.
IronPDF provides a comprehensive set of features that cater to a wide range of PDF generation needs, including converting HTML strings, URLs, and HTML files into PDFs with ease. Its seamless integration with the .NET environment and the ability to handle complex document structures make it a highly versatile tool. Additionally, IronPDF supports advanced options such as adding headers and footers, digital signatures, and handling PDF forms, ensuring that it can meet the needs of various applications.
One of the significant advantages of IronPDF is its licensing structure. It offers a free trial, allowing users to evaluate the software before making a purchase. The licenses start at $749, making it accessible for individual developers and small teams. Moreover, IronPDF provides an excellent value proposition by offering the Iron Suite, which includes nine products, at the price of two, making it a cost-effective choice for comprehensive PDF and document management needs.
In summary, while both IronPDF and CraftMyPDF are excellent tools for PDF generation, IronPDF offers a more extensive feature set, robust support, and a more advantageous licensing model. Its ability to handle complex document requirements and the cost-effective Iron Suite package give it an edge over CraftMyPDF. Whether you are an individual developer or part of a larger team, IronPDF provides a reliable and powerful solution for all your PDF generation needs.
9 .NET API products for your office documents