How to Create a New PDF from Scratch in C#
IronPDF builds a new PDF directly in C#, with no HTML and no Chrome renderer: the PdfDocument constructor returns a blank page of any size, and the DrawText, DrawBitmap, DrawLine and DrawRectangle methods put content on it. This route suits fixed layouts where you control every coordinate, such as labels, certificates, tickets and overlays, and simple generated documents that need no HTML templating. It is one of several routes to PDF generation in .NET; starting from HTML? See HTML String to PDF.
PdfDocument constructor API is consistent across supported runtimes (.NET Framework 4.6.2+, .NET Core 3.1+, .NET 5 and later), though performance on older runtimes will differ from the benchmarks below.// 1. Install IronPDF from NuGet
// 2. Create a blank PDF page, 270 by 270 millimetres
var pdf = new IronPdf.PdfDocument(270, 270);
// 3. Draw text on the first page, X and Y in points from the bottom-left corner
pdf.DrawText("Hello PDF!", IronSoftware.Drawing.FontTypes.TimesNewRoman.Name, FontSize: 18, PageIndex: 0, X: 40, Y: 120, IronSoftware.Drawing.Color.Black, Rotation: 0);
// 4. Save your PDF
pdf.SaveAs("myNewPdf.pdf");' 1. Install IronPDF from NuGet
' 2. Create a blank PDF page, 270 by 270 millimetres
Dim pdf = New IronPdf.PdfDocument(270, 270)
' 3. Draw text on the first page, X and Y in points from the bottom-left corner
pdf.DrawText("Hello PDF!", IronSoftware.Drawing.FontTypes.TimesNewRoman.Name, FontSize:=18, PageIndex:=0, X:=40, Y:=120, IronSoftware.Drawing.Color.Black, Rotation:=0)
' 4. Save your PDF
pdf.SaveAs("myNewPdf.pdf")' 1. Install IronPDF from NuGet
' 2. Create a blank PDF page, 270 by 270 millimetres
Dim pdf = New IronPdf.PdfDocument(270, 270)
' 3. Draw text on the first page, X and Y in points from the bottom-left corner
pdf.DrawText("Hello PDF!", IronSoftware.Drawing.FontTypes.TimesNewRoman.Name, FontSize:=18, PageIndex:=0, X:=40, Y:=120, IronSoftware.Drawing.Color.Black, Rotation:=0)
' 4. Save your PDF
pdf.SaveAs("myNewPdf.pdf")Minimal Workflow (5 steps)
- Download IronPDF from NuGet for creating new PDFs
- Use the PdfDocument constructor to create a blank page with a width and height in millimetres
- Draw text, images and shapes onto the page
- Add headers, page numbers and metadata
- Save or export the PDF document
This video walks through generating PDF files in .NET 6:

This video shows the same steps in VB.NET:

How Do I Create a Blank PDF?
There are multiple ways to create a PDF object. Start with the simplest method, which requires only the width and height of the PDF. This PdfDocument constructor creates a new blank PDF, ready for customization and use. The dimensions are specified in millimetres, enabling precise sizing for various applications like labels, business cards, or custom document formats.
For developers who need more control over page dimensions, IronPDF supports custom paper sizes and various predefined formats including Letter, A4, and Legal sizes, with page orientation control alongside them.
How Are Page Dimensions Measured?
using IronPdf;
// Create a blank page, width and height in millimetres
PdfDocument pdf = new PdfDocument(270, 270);
pdf.SaveAs("blankPage.pdf");using IronPdf;
// Create a blank page, width and height in millimetres
PdfDocument pdf = new PdfDocument(270, 270);
pdf.SaveAs("blankPage.pdf");Imports IronPdf
' Create a blank page, width and height in millimetres
Dim pdf As New PdfDocument(270, 270)
pdf.SaveAs("blankPage.pdf")Imports IronPdf
' Create a blank page, width and height in millimetres
Dim pdf As New PdfDocument(270, 270)
pdf.SaveAs("blankPage.pdf")The constructor takes a width and a height in millimetres, so the common paper sizes are:
| Paper size | Portrait (width × height, mm) | Landscape |
|---|---|---|
| A4 | 210 × 297 | 297 × 210 |
| Letter | 215.9 × 279.4 | 279.4 × 215.9 |
| Legal | 215.9 × 355.6 | 355.6 × 215.9 |
Swap the two values for landscape. The 270 × 270 page above is 270 mm square.
Draw methods below work in points (1/72 of an inch), measured from the bottom-left corner of the page. An A4 page is 595 × 842 points to draw on, and a larger Y is higher on the page.How Fast Is Blank PDF Creation?
| Metric | Blank A4 | A4 + Metadata | A4 (10 pages) | Letter | Custom (270×270) |
|---|---|---|---|---|---|
| Average create time | 266.6 ms | 279.4 ms | 287.2 ms | 262.4 ms | 280.6 ms |
| Output file size | 0.60 KB | 3.82 KB | 1.79 KB | 0.60 KB | 0.60 KB |
| Memory per call | 1.62 MB | 1.61 MB | 1.64 MB | 1.61 MB | 1.62 MB |
| Pages produced | 1 | 1 | 10 | 1 | 1 |
Creation time stays flat at roughly 260-290 ms across every variation, and file size, not speed, is what moves when you add metadata or pages. Once you've created a blank PDF, you can enhance it with headers and footers, watermarks, or inserted images.
How Do I Add More Pages?
The constructor returns one page. To build a longer document, create further blank pages and join them: AppendPdf adds another PdfDocument after the last page, and InsertPdf places one at a given index, so a landscape page can sit in front of portrait ones.
using IronPdf;
// Create a blank A4 page, 210 by 297 millimetres
PdfDocument pdf = new PdfDocument(210, 297);
// Append another blank page at the end
pdf.AppendPdf(new PdfDocument(210, 297));
// Insert a landscape A4 page at index 0, so it becomes the first page
pdf.InsertPdf(new PdfDocument(297, 210), 0);
pdf.SaveAs("threePages.pdf");using IronPdf;
// Create a blank A4 page, 210 by 297 millimetres
PdfDocument pdf = new PdfDocument(210, 297);
// Append another blank page at the end
pdf.AppendPdf(new PdfDocument(210, 297));
// Insert a landscape A4 page at index 0, so it becomes the first page
pdf.InsertPdf(new PdfDocument(297, 210), 0);
pdf.SaveAs("threePages.pdf");Imports IronPdf
' Create a blank A4 page, 210 by 297 millimetres
Dim pdf As New PdfDocument(210, 297)
' Append another blank page at the end
pdf.AppendPdf(New PdfDocument(210, 297))
' Insert a landscape A4 page at index 0, so it becomes the first page
pdf.InsertPdf(New PdfDocument(297, 210), 0)
pdf.SaveAs("threePages.pdf")Imports IronPdf
' Create a blank A4 page, 210 by 297 millimetres
Dim pdf As New PdfDocument(210, 297)
' Append another blank page at the end
pdf.AppendPdf(New PdfDocument(210, 297))
' Insert a landscape A4 page at index 0, so it becomes the first page
pdf.InsertPdf(New PdfDocument(297, 210), 0)
pdf.SaveAs("threePages.pdf")Pages are indexed from 0 when you draw on them. To copy, reorder or delete pages later, see add, copy and delete PDF pages.
How Do I Draw Text on a Page?
DrawText places a string at a point on one page. It takes the text, a font name, the font size, the page index, the X and Y position in points from the bottom-left corner, a colour and a rotation. FontTypes in IronSoftware.Drawing lists the built-in fonts by name, and Color accepts a named colour or a hex string.
using IronPdf;
using IronSoftware.Drawing;
// Create a blank A4 page
PdfDocument pdf = new PdfDocument(210, 297);
// Draw a heading near the top, X and Y in points from the bottom-left corner
pdf.DrawText("Certificate of Completion", FontTypes.TimesNewRoman.Name, FontSize: 24, PageIndex: 0, X: 60, Y: 760, Color.Black, Rotation: 0);
// Draw a smaller line of text 30 points below the heading
pdf.DrawText("Awarded to Morgan Ellis", FontTypes.TimesNewRoman.Name, FontSize: 14, PageIndex: 0, X: 60, Y: 730, Color.Black, Rotation: 0);
pdf.SaveAs("drawText.pdf");using IronPdf;
using IronSoftware.Drawing;
// Create a blank A4 page
PdfDocument pdf = new PdfDocument(210, 297);
// Draw a heading near the top, X and Y in points from the bottom-left corner
pdf.DrawText("Certificate of Completion", FontTypes.TimesNewRoman.Name, FontSize: 24, PageIndex: 0, X: 60, Y: 760, Color.Black, Rotation: 0);
// Draw a smaller line of text 30 points below the heading
pdf.DrawText("Awarded to Morgan Ellis", FontTypes.TimesNewRoman.Name, FontSize: 14, PageIndex: 0, X: 60, Y: 730, Color.Black, Rotation: 0);
pdf.SaveAs("drawText.pdf");Imports IronPdf
Imports IronSoftware.Drawing
' Create a blank A4 page
Dim pdf As New PdfDocument(210, 297)
' Draw a heading near the top, X and Y in points from the bottom-left corner
pdf.DrawText("Certificate of Completion", FontTypes.TimesNewRoman.Name, FontSize:=24, PageIndex:=0, X:=60, Y:=760, Color.Black, Rotation:=0)
' Draw a smaller line of text 30 points below the heading
pdf.DrawText("Awarded to Morgan Ellis", FontTypes.TimesNewRoman.Name, FontSize:=14, PageIndex:=0, X:=60, Y:=730, Color.Black, Rotation:=0)
pdf.SaveAs("drawText.pdf")Imports IronPdf
Imports IronSoftware.Drawing
' Create a blank A4 page
Dim pdf As New PdfDocument(210, 297)
' Draw a heading near the top, X and Y in points from the bottom-left corner
pdf.DrawText("Certificate of Completion", FontTypes.TimesNewRoman.Name, FontSize:=24, PageIndex:=0, X:=60, Y:=760, Color.Black, Rotation:=0)
' Draw a smaller line of text 30 points below the heading
pdf.DrawText("Awarded to Morgan Ellis", FontTypes.TimesNewRoman.Name, FontSize:=14, PageIndex:=0, X:=60, Y:=730, Color.Black, Rotation:=0)
pdf.SaveAs("drawText.pdf")For custom font files and the full parameter reference, see draw text and bitmaps.
This video shows how to convert text to a PDF in C#:

How Do I Draw Images?
DrawBitmap places an AnyBitmap on a page at a position and size in points, with the position marking the image's bottom-left corner, scaling the image to the width and height you give. Load the image with AnyBitmap.FromFile, then draw it on the page index you choose.
using IronPdf;
using IronSoftware.Drawing;
// Create a blank A4 page
PdfDocument pdf = new PdfDocument(210, 297);
// Load the image from file
AnyBitmap logo = AnyBitmap.FromFile("logo.png");
// Draw the image 200 by 80 points, its bottom-left corner at 60, 60
pdf.DrawBitmap(logo, 0, 60, 60, 200, 80);
pdf.SaveAs("drawImage.pdf");using IronPdf;
using IronSoftware.Drawing;
// Create a blank A4 page
PdfDocument pdf = new PdfDocument(210, 297);
// Load the image from file
AnyBitmap logo = AnyBitmap.FromFile("logo.png");
// Draw the image 200 by 80 points, its bottom-left corner at 60, 60
pdf.DrawBitmap(logo, 0, 60, 60, 200, 80);
pdf.SaveAs("drawImage.pdf");Imports IronPdf
Imports IronSoftware.Drawing
' Create a blank A4 page
Dim pdf As New PdfDocument(210, 297)
' Load the image from file
Dim logo As AnyBitmap = AnyBitmap.FromFile("logo.png")
' Draw the image 200 by 80 points, its bottom-left corner at 60, 60
pdf.DrawBitmap(logo, 0, 60, 60, 200, 80)
pdf.SaveAs("drawImage.pdf")Imports IronPdf
Imports IronSoftware.Drawing
' Create a blank A4 page
Dim pdf As New PdfDocument(210, 297)
' Load the image from file
Dim logo As AnyBitmap = AnyBitmap.FromFile("logo.png")
' Draw the image 200 by 80 points, its bottom-left corner at 60, 60
pdf.DrawBitmap(logo, 0, 60, 60, 200, 80)
pdf.SaveAs("drawImage.pdf")The same call works for logos, signatures and photographs. Transparency is controlled by the optional PixelFormat argument, covered in draw text and bitmaps.
How Do I Draw Lines and Rectangles?
DrawLine joins two PointF positions with a stroke of the width and colour you give. DrawRectangle takes a RectangleF (the X and Y of its bottom-left corner, then width and height), a border colour, a fill colour and a border width. Both types come from IronSoftware.Drawing, and both methods draw on one page index.
using IronPdf;
using IronSoftware.Drawing;
// Create a blank A4 page
PdfDocument pdf = new PdfDocument(210, 297);
// Draw a 1-point black line, 110 points up from the bottom of the page
pdf.DrawLine(0, new PointF(60, 110), new PointF(535, 110), 1, Color.Black);
// Draw a 475 by 80 point box above the line, with a black border and a pale blue fill
pdf.DrawRectangle(0, new RectangleF(60, 140, 475, 80), Color.Black, new Color("#F1F9FB"), 1);
pdf.SaveAs("drawShapes.pdf");using IronPdf;
using IronSoftware.Drawing;
// Create a blank A4 page
PdfDocument pdf = new PdfDocument(210, 297);
// Draw a 1-point black line, 110 points up from the bottom of the page
pdf.DrawLine(0, new PointF(60, 110), new PointF(535, 110), 1, Color.Black);
// Draw a 475 by 80 point box above the line, with a black border and a pale blue fill
pdf.DrawRectangle(0, new RectangleF(60, 140, 475, 80), Color.Black, new Color("#F1F9FB"), 1);
pdf.SaveAs("drawShapes.pdf");Imports IronPdf
Imports IronSoftware.Drawing
' Create a blank A4 page
Dim pdf As New PdfDocument(210, 297)
' Draw a 1-point black line, 110 points up from the bottom of the page
pdf.DrawLine(0, New PointF(60, 110), New PointF(535, 110), 1, Color.Black)
' Draw a 475 by 80 point box above the line, with a black border and a pale blue fill
pdf.DrawRectangle(0, New RectangleF(60, 140, 475, 80), Color.Black, New Color("#F1F9FB"), 1)
pdf.SaveAs("drawShapes.pdf")Imports IronPdf
Imports IronSoftware.Drawing
' Create a blank A4 page
Dim pdf As New PdfDocument(210, 297)
' Draw a 1-point black line, 110 points up from the bottom of the page
pdf.DrawLine(0, New PointF(60, 110), New PointF(535, 110), 1, Color.Black)
' Draw a 475 by 80 point box above the line, with a black border and a pale blue fill
pdf.DrawRectangle(0, New RectangleF(60, 140, 475, 80), Color.Black, New Color("#F1F9FB"), 1)
pdf.SaveAs("drawShapes.pdf")Rules, boxes and table grids are the usual uses. For further examples, see draw lines and rectangles.
Output
Both shapes sit exactly at their coordinates, measured up from the bottom of the page.
How Do I Add Headers, Page Numbers and Metadata?
Headers and footers are added to the finished document rather than drawn: AddTextHeaders and AddTextFooters take a TextHeaderFooter and stamp it on every page, and the {page} and {total-pages} placeholders expand per page. Document properties live on MetaData, which exposes Title, Author, Subject, Keywords and the creation and modification dates.
using IronPdf;
using System;
// Create a two-page A4 document
PdfDocument pdf = new PdfDocument(210, 297);
pdf.AppendPdf(new PdfDocument(210, 297));
// Create a text header, and a footer whose placeholders print as 1 of 2, 2 of 2
TextHeaderFooter header = new TextHeaderFooter
{
CenterText = "Monthly Report",
};
TextHeaderFooter footer = new TextHeaderFooter
{
CenterText = "{page} of {total-pages}",
};
// Add them to every page
pdf.AddTextHeaders(header);
pdf.AddTextFooters(footer);
// Set the title, author and creation date shown in the document properties
pdf.MetaData.Title = "Monthly Report";
pdf.MetaData.Author = "Iron Software";
pdf.MetaData.CreationDate = DateTime.Today;
pdf.SaveAs("reportWithHeaders.pdf");using IronPdf;
using System;
// Create a two-page A4 document
PdfDocument pdf = new PdfDocument(210, 297);
pdf.AppendPdf(new PdfDocument(210, 297));
// Create a text header, and a footer whose placeholders print as 1 of 2, 2 of 2
TextHeaderFooter header = new TextHeaderFooter
{
CenterText = "Monthly Report",
};
TextHeaderFooter footer = new TextHeaderFooter
{
CenterText = "{page} of {total-pages}",
};
// Add them to every page
pdf.AddTextHeaders(header);
pdf.AddTextFooters(footer);
// Set the title, author and creation date shown in the document properties
pdf.MetaData.Title = "Monthly Report";
pdf.MetaData.Author = "Iron Software";
pdf.MetaData.CreationDate = DateTime.Today;
pdf.SaveAs("reportWithHeaders.pdf");Imports IronPdf
Imports System
' Create a two-page A4 document
Dim pdf As New PdfDocument(210, 297)
pdf.AppendPdf(New PdfDocument(210, 297))
' Create a text header, and a footer whose placeholders print as 1 of 2, 2 of 2
Dim header As New TextHeaderFooter With {
.CenterText = "Monthly Report"
}
Dim footer As New TextHeaderFooter With {
.CenterText = "{page} of {total-pages}"
}
' Add them to every page
pdf.AddTextHeaders(header)
pdf.AddTextFooters(footer)
' Set the title, author and creation date shown in the document properties
pdf.MetaData.Title = "Monthly Report"
pdf.MetaData.Author = "Iron Software"
pdf.MetaData.CreationDate = DateTime.Today
pdf.SaveAs("reportWithHeaders.pdf")Imports IronPdf
Imports System
' Create a two-page A4 document
Dim pdf As New PdfDocument(210, 297)
pdf.AppendPdf(New PdfDocument(210, 297))
' Create a text header, and a footer whose placeholders print as 1 of 2, 2 of 2
Dim header As New TextHeaderFooter With {
.CenterText = "Monthly Report"
}
Dim footer As New TextHeaderFooter With {
.CenterText = "{page} of {total-pages}"
}
' Add them to every page
pdf.AddTextHeaders(header)
pdf.AddTextFooters(footer)
' Set the title, author and creation date shown in the document properties
pdf.MetaData.Title = "Monthly Report"
pdf.MetaData.Author = "Iron Software"
pdf.MetaData.CreationDate = DateTime.Today
pdf.SaveAs("reportWithHeaders.pdf")Both methods accept a list of page indexes to limit which pages receive the header or footer. HTML headers and footers and their margins are covered in headers and footers and page numbers; custom properties in metadata.
Output
Each page is numbered automatically, and the metadata appears under the PDF's document properties.
When Should I Use HTML to PDF Instead?
Drawing gives exact control and no layout engine, which is what a fixed template wants. The moment the content needs to flow, wrap, paginate or restyle, write it as HTML and render it with ChromePdfRenderer instead: text reflows around images, tables break across pages, and CSS does the styling. HTML String to PDF is the starting point, and the PDF generation overview lists the other sources IronPDF renders.
How Do I Fill an HTML Template?
Documents such as reports, invoices and tickets share one layout and change only their values. Write the layout once as an HTML template, fill in the values for each document, and pass the result to RenderHtmlAsPdf.
using IronPdf;
// Fill the template with the values for one invoice
string template = "<h1>Invoice {0}</h1><p>Customer: {1}</p><p>Total: {2}</p>";
string html = string.Format(template, "INV-1001", "Contoso Ltd", "$1,250.00");
// Render the filled template to a PDF
var renderer = new ChromePdfRenderer();
using PdfDocument pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("invoice.pdf");using IronPdf;
// Fill the template with the values for one invoice
string template = "<h1>Invoice {0}</h1><p>Customer: {1}</p><p>Total: {2}</p>";
string html = string.Format(template, "INV-1001", "Contoso Ltd", "$1,250.00");
// Render the filled template to a PDF
var renderer = new ChromePdfRenderer();
using PdfDocument pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("invoice.pdf");Imports IronPdf
' Fill the template with the values for one invoice
Dim template As String = "<h1>Invoice {0}</h1><p>Customer: {1}</p><p>Total: {2}</p>"
Dim html As String = String.Format(template, "INV-1001", "Contoso Ltd", "$1,250.00")
' Render the filled template to a PDF
Dim renderer = New ChromePdfRenderer()
Using pdf As PdfDocument = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("invoice.pdf")
End UsingImports IronPdf
' Fill the template with the values for one invoice
Dim template As String = "<h1>Invoice {0}</h1><p>Customer: {1}</p><p>Total: {2}</p>"
Dim html As String = String.Format(template, "INV-1001", "Contoso Ltd", "$1,250.00")
' Render the filled template to a PDF
Dim renderer = New ChromePdfRenderer()
Using pdf As PdfDocument = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("invoice.pdf")
End UsingHow Do I Render Without Blocking the Application?
RenderUrlAsPdfAsync is the asynchronous form of RenderUrlAsPdf. Awaiting it leaves the calling thread free while the page loads and renders, which keeps a desktop form responsive during the conversion.
using IronPdf;
// Render the web page without blocking the calling thread
var renderer = new ChromePdfRenderer();
using PdfDocument pdf = await renderer.RenderUrlAsPdfAsync("https://ironpdf.com/");
pdf.SaveAs("url.pdf");using IronPdf;
// Render the web page without blocking the calling thread
var renderer = new ChromePdfRenderer();
using PdfDocument pdf = await renderer.RenderUrlAsPdfAsync("https://ironpdf.com/");
pdf.SaveAs("url.pdf");Imports IronPdf
' Render the web page without blocking the calling thread
Dim renderer = New ChromePdfRenderer()
Using pdf As PdfDocument = Await renderer.RenderUrlAsPdfAsync("https://ironpdf.com/")
pdf.SaveAs("url.pdf")
End UsingImports IronPdf
' Render the web page without blocking the calling thread
Dim renderer = New ChromePdfRenderer()
Using pdf As PdfDocument = Await renderer.RenderUrlAsPdfAsync("https://ironpdf.com/")
pdf.SaveAs("url.pdf")
End UsingFrequently Asked Questions
Can IronPDF Create PDFs in Xamarin?
IronPDF does not run natively inside a Xamarin.Forms app, so a server-side API approach covers the gap. The mobile app sends HTML content to an API that runs IronPDF and receives the finished PDF in return, which gives the app access to forms, headers, footers, images, and custom layouts. The HTML is rendered as described in HTML String to PDF. The Xamarin.Forms client calls the API, receives a byte array, writes it to local storage, and optionally opens a PDF viewer. The server handles everything else.
Why Does a Server-Side Approach Work for Xamarin PDF Generation?
Running IronPDF on a dedicated server, rather than inside a mobile application, sidesteps the platform constraints that prevent direct on-device PDF rendering on iOS and Android. The server-side pattern offers several concrete advantages:
- Consistent output: Fonts, images, and CSS are resolved server-side, eliminating rendering differences between Android and iOS hardware.
- Feature access: IronPDF features such as PDF form creation, digital signatures, watermarks, and multi-page layouts are all available on the server without restriction.
- Lighter mobile app: The device only sends an HTTP request and stores the returned PDF bytes. No heavy PDF engine runs on the phone.
- Centralized licensing: A single IronPDF license covers the server deployment rather than licensing each device separately.
Does the Server-Side Approach Work with .NET MAUI?
Microsoft ended support for Xamarin in May 2024. For new projects, .NET MAUI is the recommended successor and supports IronPDF more directly. The server-side approach works identically for .NET MAUI apps, because the client HTTP code is essentially the same.
Does IronPDF Work as a .NET Core PDF Generator on Linux and Docker?
Yes. IronPDF runs on .NET Core 3.1, .NET 5 through .NET 10, .NET Framework 4.6.2 and later, and .NET Standard 2.0 and later. It runs on Windows, Linux, Azure, AWS, and Docker without changing a line of application code. Each environment may need specific configuration for fonts and rendering, but the core API stays the same. The Linux setup guide covers the Linux requirements, and Docker deployments should start from the official IronPDF base image described in the Docker guide.
Conclusion
This guide covered creating a blank PDF with a set page size, adding pages, drawing text, images and shapes, and adding headers, page numbers and metadata. To save the finished document to disk, memory or an HTTP response, see Save and Export PDF Documents. If your content is easier to lay out in HTML, use HTML String to PDF instead.
This video generates downloadable PDF files from HTML in an ASP.NET Core MVC app:

This video gives an overview of PDF generation and conversion in .NET:

Frequently Asked Questions
How do I create a new PDF in C# using IronPDF?
Install IronPDF from NuGet, create a PdfDocument with the constructor, passing the page width and height in millimetres, draw content onto it with the Draw methods, then call SaveAs to write the file.
How do I create an A4 or Letter page from scratch?
Pass the width and height in millimetres to the PdfDocument constructor: new PdfDocument(210, 297) for A4 and new PdfDocument(215.9, 279.4) for US Letter. Swap the two values for landscape.
How do I add more pages to a PDF created from scratch?
Create another blank PdfDocument and join it to the first: AppendPdf adds it after the last page and InsertPdf places it at the index you specify.
How do I draw text on a blank PDF with IronPDF?
Call DrawText with the text, a font name from FontTypes, the font size, the page index, the X and Y position in points from the bottom-left corner, a Color and a rotation. Each call draws one string on one page.
How do I draw text in a custom font?
Read the font file's bytes and add them with pdf.Fonts.Add, then pass the returned font's Name to DrawText. The font is embedded in the PDF as soon as it is added, so there is no need to call Embed() as well.
How do I add an image to a PDF created from scratch?
Load the image as an AnyBitmap, for example with AnyBitmap.FromFile, then call DrawBitmap with the page index, the X and Y position, and the width and height in points.
Can I draw lines and rectangles on a PDF with IronPDF?
Yes. DrawLine takes a page index, two PointF positions, a width and a Color. DrawRectangle takes a page index, a RectangleF, a border colour, a fill colour and a border width.
Can I put page numbers in the footer instead of the header?
Yes. Put {page} and {total-pages} in a TextHeaderFooter and pass it to AddTextFooters instead of AddTextHeaders. The placeholders are replaced on every page, in a footer as in a header.
How do I set the title and author of a PDF in IronPDF?
Set the properties on MetaData, such as Title, Author, Subject, Keywords, CreationDate and ModifiedDate, before saving.
How fast is creating a blank PDF with IronPDF?
Creating a blank PDF with IronPDF is efficient, taking approximately 260-290 ms depending on the page dimensions and whether metadata or multiple pages are included.
Should I build from scratch or use an HTML template for tickets, labels or invoices?
Draw from scratch when every element sits at a fixed position, as on tickets and labels. Use an HTML template rendered with ChromePdfRenderer when the content changes length, as invoice line items do, because HTML wraps text and breaks tables across pages.
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.