using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from a HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external html assets: Images, CSS and JavaScript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
// Before (TallComponents — real namespaces)
using TallComponents.PDF; // Document, Page (PDFKit.NET)
using TallComponents.PDF.Shapes; // TextShape, ImageShape (PDFKit)
using TallComponents.PDF.Security; // PasswordSecurity
using TallComponents.PDF.Layout; // Document, Section (TallPDF.NET)
using TallComponents.PDF.Layout.Paragraphs; // TextParagraph, XhtmlParagraph
// After (IronPDF)
using IronPdf;
// Before (TallComponents — real namespaces)
using TallComponents.PDF; // Document, Page (PDFKit.NET)
using TallComponents.PDF.Shapes; // TextShape, ImageShape (PDFKit)
using TallComponents.PDF.Security; // PasswordSecurity
using TallComponents.PDF.Layout; // Document, Section (TallPDF.NET)
using TallComponents.PDF.Layout.Paragraphs; // TextParagraph, XhtmlParagraph
// After (IronPDF)
using IronPdf;
// NuGet: Install-Package TallComponents.TallPDF5
// (HTML/XHTML conversion lives in TallPDF.NET, not in PDFKit.NET.)
using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;
using System.IO;
class Program
{
static void Main()
{
Document document = new Document();
Section section = document.Sections.Add();
// XhtmlParagraph supports XHTML 1.0/1.1 +CSS 2.1only.
XhtmlParagraph xhtml = new XhtmlParagraph();
xhtml.Text = "<html><body><h1>Hello World</h1><p>This is a PDF from XHTML.</p></body></html>";
section.Paragraphs.Add(xhtml);
using (FileStream fs = new FileStream("output.pdf", FileMode.Create))
{
document.Write(fs);
}
}
}
// NuGet: Install-Package TallComponents.TallPDF5
// (HTML/XHTML conversion lives in TallPDF.NET, not in PDFKit.NET.)
using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;
using System.IO;
class Program
{
static void Main()
{
Document document = new Document();
Section section = document.Sections.Add();
// XhtmlParagraph supports XHTML 1.0/1.1 +CSS 2.1only.
XhtmlParagraph xhtml = new XhtmlParagraph();
xhtml.Text = "<html><body><h1>Hello World</h1><p>This is a PDF from XHTML.</p></body></html>";
section.Paragraphs.Add(xhtml);
using (FileStream fs = new FileStream("output.pdf", FileMode.Create))
{
document.Write(fs);
}
}
}
Imports TallComponents.PDF.Layout
Imports TallComponents.PDF.Layout.Paragraphs
Imports System.IO
Class Program
Shared Sub Main()
Dim document As New Document()
Dim section As Section = document.Sections.Add()
' XhtmlParagraph supports XHTML 1.0/1.1 +CSS 2.1 only.
Dim xhtml As New XhtmlParagraph()
xhtml.Text = "<html><body><h1>Hello World</h1><p>This is a PDF from XHTML.</p></body></html>"
section.Paragraphs.Add(xhtml)
Using fs As New FileStream("output.pdf", FileMode.Create)
document.Write(fs)
End Using
End Sub
End Class
$vbLabelText $csharpLabel
IronPDF 方法:
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
// Create a PDF fromHTMLstring
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML.</p></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
// Create a PDF fromHTMLstring
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML.</p></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
' Create a PDF from HTML string
Dim renderer As New ChromePdfRenderer()
Dim html As String = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML.</p></body></html>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
End Sub
End Class
// NuGet: Install-Package TallComponents.PDFKit5
using TallComponents.PDF;
using System.IO;
class Program
{
static void Main()
{
// Create target document
Document outputDoc = new Document();
// Load first PDF and clone each page into the target
using (FileStream fs1 = new FileStream("document1.pdf", FileMode.Open, FileAccess.Read))
{
Document doc1 = new Document(fs1);
foreach (Page page in doc1.Pages)
{
outputDoc.Pages.Add(page.Clone()); // clone is required across documents
}
}
// Load second PDF and append the whole page collection
using (FileStream fs2 = new FileStream("document2.pdf", FileMode.Open, FileAccess.Read))
{
Document doc2 = new Document(fs2);
outputDoc.Pages.AddRange(doc2.Pages.CloneToArray());
}
// Save merged document
using (FileStream output = new FileStream("merged.pdf", FileMode.Create))
{
outputDoc.Write(output);
}
}
}
// NuGet: Install-Package TallComponents.PDFKit5
using TallComponents.PDF;
using System.IO;
class Program
{
static void Main()
{
// Create target document
Document outputDoc = new Document();
// Load first PDF and clone each page into the target
using (FileStream fs1 = new FileStream("document1.pdf", FileMode.Open, FileAccess.Read))
{
Document doc1 = new Document(fs1);
foreach (Page page in doc1.Pages)
{
outputDoc.Pages.Add(page.Clone()); // clone is required across documents
}
}
// Load second PDF and append the whole page collection
using (FileStream fs2 = new FileStream("document2.pdf", FileMode.Open, FileAccess.Read))
{
Document doc2 = new Document(fs2);
outputDoc.Pages.AddRange(doc2.Pages.CloneToArray());
}
// Save merged document
using (FileStream output = new FileStream("merged.pdf", FileMode.Create))
{
outputDoc.Write(output);
}
}
}
Imports TallComponents.PDF
Imports System.IO
Class Program
Shared Sub Main()
' Create target document
Dim outputDoc As New Document()
' Load first PDF and clone each page into the target
Using fs1 As New FileStream("document1.pdf", FileMode.Open, FileAccess.Read)
Dim doc1 As New Document(fs1)
For Each page As Page In doc1.Pages
outputDoc.Pages.Add(page.Clone()) ' clone is required across documents
Next
End Using
' Load second PDF and append the whole page collection
Using fs2 As New FileStream("document2.pdf", FileMode.Open, FileAccess.Read)
Dim doc2 As New Document(fs2)
outputDoc.Pages.AddRange(doc2.Pages.CloneToArray())
End Using
' Save merged document
Using output As New FileStream("merged.pdf", FileMode.Create)
outputDoc.Write(output)
End Using
End Sub
End Class
$vbLabelText $csharpLabel
IronPDF 方法:
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
// Load PDFs
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
// Merge PDFs
var merged = PdfDocument.Merge(pdf1, pdf2);
// Save merged document
merged.SaveAs("merged.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
// Load PDFs
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
// Merge PDFs
var merged = PdfDocument.Merge(pdf1, pdf2);
// Save merged document
merged.SaveAs("merged.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
' Load PDFs
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
' Merge PDFs
Dim merged = PdfDocument.Merge(pdf1, pdf2)
' Save merged document
merged.SaveAs("merged.pdf")
End Sub
End Class
// NuGet: Install-Package TallComponents.PDFKit5
using TallComponents.PDF;
using TallComponents.PDF.Shapes;
using System.IO;
using System.Drawing;
class Program
{
static void Main()
{
// Load existing PDF
using (FileStream fs = new FileStream("input.pdf", FileMode.Open, FileAccess.Read))
{
Document document = new Document(fs);
foreach (Page page in document.Pages)
{
TextShape watermark = new TextShape();
watermark.Text = "CONFIDENTIAL";
watermark.Font = new Font("Arial", 60);
watermark.Pen = new Pen(Color.FromArgb(128, 255, 0, 0));
watermark.X = 200;
watermark.Y = 400;
// Rotation is applied via a transform on PDFKit.NET
// (TextShape has no Rotate property in the PDFKit API).
watermark.Transform = new RotateTransform(45);
page.Overlay.Add(watermark);
}
using (FileStream output = new FileStream("watermarked.pdf", FileMode.Create))
{
document.Write(output);
}
}
}
}
// NuGet: Install-Package TallComponents.PDFKit5
using TallComponents.PDF;
using TallComponents.PDF.Shapes;
using System.IO;
using System.Drawing;
class Program
{
static void Main()
{
// Load existing PDF
using (FileStream fs = new FileStream("input.pdf", FileMode.Open, FileAccess.Read))
{
Document document = new Document(fs);
foreach (Page page in document.Pages)
{
TextShape watermark = new TextShape();
watermark.Text = "CONFIDENTIAL";
watermark.Font = new Font("Arial", 60);
watermark.Pen = new Pen(Color.FromArgb(128, 255, 0, 0));
watermark.X = 200;
watermark.Y = 400;
// Rotation is applied via a transform on PDFKit.NET
// (TextShape has no Rotate property in the PDFKit API).
watermark.Transform = new RotateTransform(45);
page.Overlay.Add(watermark);
}
using (FileStream output = new FileStream("watermarked.pdf", FileMode.Create))
{
document.Write(output);
}
}
}
}
Imports TallComponents.PDF
Imports TallComponents.PDF.Shapes
Imports System.IO
Imports System.Drawing
Class Program
Shared Sub Main()
' Load existing PDF
Using fs As New FileStream("input.pdf", FileMode.Open, FileAccess.Read)
Dim document As New Document(fs)
For Each page As Page In document.Pages
Dim watermark As New TextShape()
watermark.Text = "CONFIDENTIAL"
watermark.Font = New Font("Arial", 60)
watermark.Pen = New Pen(Color.FromArgb(128, 255, 0, 0))
watermark.X = 200
watermark.Y = 400
' Rotation is applied via a transform on PDFKit.NET
' (TextShape has no Rotate property in the PDFKit API).
watermark.Transform = New RotateTransform(45)
page.Overlay.Add(watermark)
Next
Using output As New FileStream("watermarked.pdf", FileMode.Create)
document.Write(output)
End Using
End Using
End Sub
End Class
$vbLabelText $csharpLabel
IronPDF 方法:
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
class Program
{
static void Main()
{
// Load existing PDF
var pdf = PdfDocument.FromFile("input.pdf");
// Create watermark
var watermark = new TextStamper()
{
Text = "CONFIDENTIAL",
FontSize = 60,
Opacity = 50,
Rotation = 45,
VerticalAlignment = VerticalAlignment.Middle,
HorizontalAlignment = HorizontalAlignment.Center
};
// Apply watermark to all pages
pdf.ApplyStamp(watermark);
// Save watermarked PDF
pdf.SaveAs("watermarked.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
class Program
{
static void Main()
{
// Load existing PDF
var pdf = PdfDocument.FromFile("input.pdf");
// Create watermark
var watermark = new TextStamper()
{
Text = "CONFIDENTIAL",
FontSize = 60,
Opacity = 50,
Rotation = 45,
VerticalAlignment = VerticalAlignment.Middle,
HorizontalAlignment = HorizontalAlignment.Center
};
// Apply watermark to all pages
pdf.ApplyStamp(watermark);
// Save watermarked PDF
pdf.SaveAs("watermarked.pdf");
}
}
Imports IronPdf
Imports IronPdf.Editing
Class Program
Shared Sub Main()
' Load existing PDF
Dim pdf = PdfDocument.FromFile("input.pdf")
' Create watermark
Dim watermark = New TextStamper() With {
.Text = "CONFIDENTIAL",
.FontSize = 60,
.Opacity = 50,
.Rotation = 45,
.VerticalAlignment = VerticalAlignment.Middle,
.HorizontalAlignment = HorizontalAlignment.Center
}
' Apply watermark to all pages
pdf.ApplyStamp(watermark)
' Save watermarked PDF
pdf.SaveAs("watermarked.pdf")
End Sub
End Class
using TallComponents.PDF;
using TallComponents.PDF.Signing;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using (FileStream fs = new FileStream("unsigned.pdf", FileMode.Open, FileAccess.Read))
{
Document document = new Document(fs);
X509Certificate2 cert = new X509Certificate2("certificate.pfx", "password");
SignatureField field = new SignatureField("Signature1");
field.Sign(cert);
document.Fields.Add(field);
using (FileStream output = new FileStream("signed.pdf", FileMode.Create))
{
document.Write(output);
}
}
using TallComponents.PDF;
using TallComponents.PDF.Signing;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using (FileStream fs = new FileStream("unsigned.pdf", FileMode.Open, FileAccess.Read))
{
Document document = new Document(fs);
X509Certificate2 cert = new X509Certificate2("certificate.pfx", "password");
SignatureField field = new SignatureField("Signature1");
field.Sign(cert);
document.Fields.Add(field);
using (FileStream output = new FileStream("signed.pdf", FileMode.Create))
{
document.Write(output);
}
}
Imports TallComponents.PDF
Imports TallComponents.PDF.Signing
Imports System.IO
Imports System.Security.Cryptography.X509Certificates
Using fs As New FileStream("unsigned.pdf", FileMode.Open, FileAccess.Read)
Dim document As New Document(fs)
Dim cert As New X509Certificate2("certificate.pfx", "password")
Dim field As New SignatureField("Signature1")
field.Sign(cert)
document.Fields.Add(field)
Using output As New FileStream("signed.pdf", FileMode.Create)
document.Write(output)
End Using
End Using
$vbLabelText $csharpLabel
IronPDF 方法:
using IronPdf;
using IronPdf.Signing;
var pdf = PdfDocument.FromFile("unsigned.pdf");
// Sign with certificate
var signature = new PdfSignature("certificate.pfx", "password")
{
SigningContact = "support@company.com",
SigningLocation = "New York",
SigningReason = "Document Approval"
};
pdf.Sign(signature);
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
var pdf = PdfDocument.FromFile("unsigned.pdf");
// Sign with certificate
var signature = new PdfSignature("certificate.pfx", "password")
{
SigningContact = "support@company.com",
SigningLocation = "New York",
SigningReason = "Document Approval"
};
pdf.Sign(signature);
pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Dim pdf = PdfDocument.FromFile("unsigned.pdf")
' Sign with certificate
Dim signature = New PdfSignature("certificate.pfx", "password") With {
.SigningContact = "support@company.com",
.SigningLocation = "New York",
.SigningReason = "Document Approval"
}
pdf.Sign(signature)
pdf.SaveAs("signed.pdf")