Test in einer Live-Umgebung
Test in der Produktion ohne Wasserzeichen.
Funktioniert überall, wo Sie es brauchen.
Suchen Sie eine PDF-Bibliothek, um alle Ihre PDF-bezogenen Aufgaben ohne die Installation von Adobe Acrobat auszuführen, wissen aber nicht, welche Sie aus den zahlreichen derzeit verfügbaren PDF-Bibliotheken wählen sollen? Heute werfen wir einen genaueren Blick auf zwei prominente PDF-Bibliotheken, IronPDF und Spire.PDF, innerhalb der .NET-Umgebung.
In diesem Vergleichsleitfaden werden wir die Funktionen betrachten, die diese Bibliotheken bieten, wie sie Ihnen helfen können, die verfügbare Dokumentation für die Bibliotheken und die Lizenzierungspreise für die Nutzung dieser Bibliotheken.
IronPDF ist eine vielseitige .NET PDF-Bibliothek, die für eine breite Palette von Aufgaben im Zusammenhang mit PDFs konzipiert wurde, einschließlich der Konvertierung von PDF-Dateien, PDF-Bearbeitung, PDF-Erstellung, Lesen von PDF-Dateien und mehr. Es ist bekannt für seine einfache Integration in bestehende .NET-Anwendungen, hohe Leistung und Unterstützung für moderne Webstandards wie HTML5, CSS3 und JavaScript. Die API von IronPDF ist intuitiv und stellt eine ausgezeichnete Wahl dar, wenn Sie auf der Suche nach einer robusten PDF-Funktionalität für Ihre Projekte sind.
Spire.PDF for .NET ist eine weitere leistungsstarke .NET PDF-Bibliothek, die eine umfassende Reihe von Funktionen für die PDF-Erstellung und -Bearbeitung bietet. Es unterstützt verschiedene PDF-Funktionen wie Text- und Bildextraktion, das Ausfüllen von PDF-Formularen und digitale Signaturen. Spire.PDF wurde entwickelt, um einfach zu bedienen zu sein und nahtlos mit .NET-Anwendungen zu integrieren, was es zu einem weiteren potenziellen Kandidaten für Ihre PDF-Projekte macht.
Für ausführlichere Informationen über IronPDF, besuchen Sie bitteIronPDF.com.
IronPDF zeichnet sich durch seine umfassende plattformübergreifende Kompatibilität aus. Es unterstützt eine Vielzahl von Umgebungen innerhalb des .NET Frameworks und gewährleistet einen nahtlosen Betrieb auf verschiedenen Plattformen. Nachfolgend finden Sie eine Zusammenfassung der Plattformkompatibilität von IronPDF:
.NET-Versionen:
Vollständig geschrieben in und unterstützt C#, VB.NET und F#.
.NET Core(8, 7, 6, 5 und 3.1+)
OS und Prozessoren: Unterstützt verschiedene Betriebssysteme und Prozessoren wie Windows, Mac, Linux, x64, x86, ARM
Für weitere Details zur Kompatibilität von IronPDF, besuchen Sie dieIronPDF Funktionen Seite.
Spire.PDF hat volle Unterstützung innerhalb der .NET-Umgebung, aber während es im Windows-Betriebssystem funktioniert, fehlt ihm die native Unterstützung für Linux und macOS, die IronPDF bietet.
IronPDF und Spire.PDF bieten beide eine Reihe von Funktionen, die auf verschiedene PDF-Funktionalitäten zugeschnitten sind. Nachfolgend finden Sie einen Vergleich der wichtigsten Funktionen, die von jeder Bibliothek bereitgestellt werden:
PDF-Version-Unterstützung: Kann PDF-Version 1.2-1.7 unterstützen
Für eine umfassende Liste der IronPDF-Funktionen besuchen Sie bitteIronPDF-Funktionen.
Um die Fähigkeiten von IronPDF und Spire.PDF für .NET zu veranschaulichen, werden wir deren Implementierung mehrerer wichtiger PDF-Funktionen anhand von Codebeispielen vergleichen, um Ihnen einen Eindruck zu vermitteln, wie diese Funktionen bei Ihren PDF-Projekten helfen können.
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
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");
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
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");
Imports IronPdf
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from an HTML string using C#
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
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
Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
myAdvancedPdf.SaveAs("html-with-assets.pdf")
Spire.PDF Beispiel:
using Spire.Pdf;
using Spire.Pdf.HtmlConverter;
using System.IO;
using System.Threading;
using System.Drawing;
namespace ConvertHtmlStringToPdfWithoutPlugin
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
//Create a PdfPageSettings object
PdfPageSettings setting = new PdfPageSettings();
//Save page size and margins through the object
setting.Size = new SizeF(1000, 1000);
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);
//Create a PdfHtmlLayoutFormat object
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
//Set IsWaiting property to true
htmlLayoutFormat.IsWaiting = true;
//Read html string from a .html file
string htmlString = File.ReadAllText(@"C:\Users\Administrator\Desktop\Document\Html\Sample.html");
//Load HTML from html string using LoadFromHTML method
Thread thread = new Thread(() =>
{ doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
//Save to a PDF file
doc.SaveToFile("HtmlStringToPdf.pdf");
}
}
}
using Spire.Pdf;
using Spire.Pdf.HtmlConverter;
using System.IO;
using System.Threading;
using System.Drawing;
namespace ConvertHtmlStringToPdfWithoutPlugin
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
//Create a PdfPageSettings object
PdfPageSettings setting = new PdfPageSettings();
//Save page size and margins through the object
setting.Size = new SizeF(1000, 1000);
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);
//Create a PdfHtmlLayoutFormat object
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
//Set IsWaiting property to true
htmlLayoutFormat.IsWaiting = true;
//Read html string from a .html file
string htmlString = File.ReadAllText(@"C:\Users\Administrator\Desktop\Document\Html\Sample.html");
//Load HTML from html string using LoadFromHTML method
Thread thread = new Thread(() =>
{ doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
//Save to a PDF file
doc.SaveToFile("HtmlStringToPdf.pdf");
}
}
}
Imports Spire.Pdf
Imports Spire.Pdf.HtmlConverter
Imports System.IO
Imports System.Threading
Imports System.Drawing
Namespace ConvertHtmlStringToPdfWithoutPlugin
Friend Class Program
Shared Sub Main(ByVal args() As String)
'Create a PdfDocument object
Dim doc As New PdfDocument()
'Create a PdfPageSettings object
Dim setting As New PdfPageSettings()
'Save page size and margins through the object
setting.Size = New SizeF(1000, 1000)
setting.Margins = New Spire.Pdf.Graphics.PdfMargins(20)
'Create a PdfHtmlLayoutFormat object
Dim htmlLayoutFormat As New PdfHtmlLayoutFormat()
'Set IsWaiting property to true
htmlLayoutFormat.IsWaiting = True
'Read html string from a .html file
Dim htmlString As String = File.ReadAllText("C:\Users\Administrator\Desktop\Document\Html\Sample.html")
'Load HTML from html string using LoadFromHTML method
Dim thread As New Thread(Sub()
doc.LoadFromHTML(htmlString, True, setting, htmlLayoutFormat)
End Sub)
thread.SetApartmentState(ApartmentState.STA)
thread.Start()
thread.Join()
'Save to a PDF file
doc.SaveToFile("HtmlStringToPdf.pdf")
End Sub
End Class
End Namespace
IronPDF nutzt die Rendering-Engine von Chrome für eine hochwertige HTML-zu-PDF-Konvertierung, um eine genaue Darstellung von Webinhalten zu gewährleisten, dank der Unterstützung moderner Webstandards. Spire.PDF bietet ebenfalls eine leistungsstarke HTML-zu-PDF-Konvertierung, erreicht jedoch möglicherweise nicht die Rendergenauigkeit von IronPDF und verfolgt einen längeren, manuellen Ansatz.
Wenn Sie also nach einer einfachen Methode suchen, um Ihre HTML-zu-PDF-Aufgaben zu automatisieren und dabei eine hohe Qualität Ihrer PDFs beizubehalten, dann wäre IronPDF das richtige Werkzeug für Sie.
using IronPdf;
using System;
// Open an Encrypted File, alternatively create a new PDF from Html
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;
// Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// Change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
using IronPdf;
using System;
// Open an Encrypted File, alternatively create a new PDF from Html
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;
// Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// Change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
Imports IronPdf
Imports System
' Open an Encrypted File, alternatively create a new PDF from Html
Private pdf = PdfDocument.FromFile("encrypted.pdf", "password")
' Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = DateTime.Now
' Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption()
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserFormData = False
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights
' Change or set the document encryption password
pdf.Password = "my-password"
pdf.SaveAs("secured.pdf")
Spire.PDF:
using Spire.Pdf;
using Spire.Pdf.Security;
//Create a PdfDocument object
PdfDocument pdf = new PdfDocument();
//Load a sample PDF file
pdf.LoadFromFile(@"E:\Files\sample.pdf");
//Encrypt the PDF file with password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print
PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit);
//Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF);
using Spire.Pdf;
using Spire.Pdf.Security;
//Create a PdfDocument object
PdfDocument pdf = new PdfDocument();
//Load a sample PDF file
pdf.LoadFromFile(@"E:\Files\sample.pdf");
//Encrypt the PDF file with password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print
PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit);
//Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF);
Imports Spire.Pdf
Imports Spire.Pdf.Security
'Create a PdfDocument object
Private pdf As New PdfDocument()
'Load a sample PDF file
pdf.LoadFromFile("E:\Files\sample.pdf")
'Encrypt the PDF file with password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit)
'Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF)
Beide Bibliotheken bieten benutzerfreundliche Methoden zum Verschlüsseln von PDFs und zum Festlegen der Lesbarkeit der verschlüsselten PDF-Dokumente. IronPDF bietet einen einfachen Ansatz, während es Ihnen dennoch die vollständige Kontrolle über die Sicherheitseinstellungen Ihres PDFs ermöglicht. Spire.PDF benötigt einen etwas kürzeren Prozess, beinhaltet jedoch immer noch zusätzliche Optionen zum Festlegen von Berechtigungen.
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are")
pdf.SaveAs("redacted.pdf")
Spire.PDF:
Spire.PDF verfügt über kein spezielles Schwärzungswerkzeug. Sie können es jedoch weiterhin verwenden, um Inhalte zu schwärzen, indem Sie ein Rechteck über die Inhalte zeichnen, die Sie schwärzen möchten.(wie unten zu sehen)oder indem Sie den Text extrahieren und entfernen, den Sie schwärzen möchten.
using Spire.Pdf;
using Spire.Pdf.Graphics;
// Specify the input PDF file path
string inputPdfFilePath = "path/to/your/input.pdf";
// Specify the output redacted PDF file path
string outputPdfFilePath = "path/to/your/redacted_output.pdf";
// Create a new PdfDocument object
PdfDocument pdfDocument = new PdfDocument();
// Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath);
// Redact content on each page
foreach (PdfPageBase page in pdfDocument.Pages)
{
// Define the area to redact (e.g., coordinates and size of the rectangle)
RectangleF redactArea = new RectangleF(100, 100, 200, 50); // Example coordinates and size
// Apply redaction
page.Canvas.DrawRectangle(new PdfSolidBrush(Color.Black), redactArea);
}
// Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath);
using Spire.Pdf;
using Spire.Pdf.Graphics;
// Specify the input PDF file path
string inputPdfFilePath = "path/to/your/input.pdf";
// Specify the output redacted PDF file path
string outputPdfFilePath = "path/to/your/redacted_output.pdf";
// Create a new PdfDocument object
PdfDocument pdfDocument = new PdfDocument();
// Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath);
// Redact content on each page
foreach (PdfPageBase page in pdfDocument.Pages)
{
// Define the area to redact (e.g., coordinates and size of the rectangle)
RectangleF redactArea = new RectangleF(100, 100, 200, 50); // Example coordinates and size
// Apply redaction
page.Canvas.DrawRectangle(new PdfSolidBrush(Color.Black), redactArea);
}
// Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath);
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
' Specify the input PDF file path
Private inputPdfFilePath As String = "path/to/your/input.pdf"
' Specify the output redacted PDF file path
Private outputPdfFilePath As String = "path/to/your/redacted_output.pdf"
' Create a new PdfDocument object
Private pdfDocument As New PdfDocument()
' Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath)
' Redact content on each page
For Each page As PdfPageBase In pdfDocument.Pages
' Define the area to redact (e.g., coordinates and size of the rectangle)
Dim redactArea As New RectangleF(100, 100, 200, 50) ' Example coordinates and size
' Apply redaction
page.Canvas.DrawRectangle(New PdfSolidBrush(Color.Black), redactArea)
Next page
' Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath)
IronPDF vereinfacht die Schwärzung mit seinem leistungsstarken, aber unkomplizierten Schwärzungswerkzeug. Spire.PDF erfordert manuelle Handhabung der Schwärzung, da es kein integriertes Schwärzungswerkzeug besitzt, was weniger effizient wäre.
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PDF digital signature with the PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PDF digital signature with the PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>")
' Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create PDF digital signature with the PdfSignature object
Private sig = New PdfSignature(cert)
' Sign PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")
Spire.PDF Beispiel:
using system;
using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Security;
using Spire.Pdf.Graphics;
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
//Load a sample PDF file
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pdf");
//Load the certificate
PdfCertificate cert = new PdfCertificate("C:\\Users\\Administrator\\Desktop\\MyCertificate.pfx", "e-iceblue");
//Create a PdfSignature object and specify its position and size
PdfSignature signature = new PdfSignature(doc, doc.Pages[doc.Pages.Count - 1], cert, "MySignature");
24
RectangleF rectangleF = new RectangleF(doc.Pages[0].ActualSize.Width - 260 - 54 , 200, 260, 110);
signature.Bounds = rectangleF;
signature.Certificated = true;
//Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
//Set the signature content
signature.NameLabel = "Signer:";
signature.Name = "Gary";
signature.ContactInfoLabel = "Phone:";
signature.ContactInfo = "0123456";
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "USA";
signature.ReasonLabel = "Reason:";
signature.Reason = "I am the author";
signature.DistinguishedNameLabel = "DN:";
signature.DistinguishedName = signature.Certificate.IssuerName.Name;
//Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\\Users\\Administrator\\Desktop\\handwrittingSignature.png");
//Set the signature font
signature.SignDetailsFont = new PdfTrueTypeFont(new Font("Arial Unicode MS", 12f, FontStyle.Regular));
//Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges
PdfCertificationFlags.AllowFormFill;
//Save to file
doc.SaveToFile("VisiableSignature.pdf");
doc.Close();
using system;
using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Security;
using Spire.Pdf.Graphics;
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
//Load a sample PDF file
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pdf");
//Load the certificate
PdfCertificate cert = new PdfCertificate("C:\\Users\\Administrator\\Desktop\\MyCertificate.pfx", "e-iceblue");
//Create a PdfSignature object and specify its position and size
PdfSignature signature = new PdfSignature(doc, doc.Pages[doc.Pages.Count - 1], cert, "MySignature");
24
RectangleF rectangleF = new RectangleF(doc.Pages[0].ActualSize.Width - 260 - 54 , 200, 260, 110);
signature.Bounds = rectangleF;
signature.Certificated = true;
//Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
//Set the signature content
signature.NameLabel = "Signer:";
signature.Name = "Gary";
signature.ContactInfoLabel = "Phone:";
signature.ContactInfo = "0123456";
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "USA";
signature.ReasonLabel = "Reason:";
signature.Reason = "I am the author";
signature.DistinguishedNameLabel = "DN:";
signature.DistinguishedName = signature.Certificate.IssuerName.Name;
//Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\\Users\\Administrator\\Desktop\\handwrittingSignature.png");
//Set the signature font
signature.SignDetailsFont = new PdfTrueTypeFont(new Font("Arial Unicode MS", 12f, FontStyle.Regular));
//Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges
PdfCertificationFlags.AllowFormFill;
//Save to file
doc.SaveToFile("VisiableSignature.pdf");
doc.Close();
Imports system
Imports System.Drawing
Imports Spire.Pdf
Imports Spire.Pdf.Security
Imports Spire.Pdf.Graphics
'Create a PdfDocument object
Private doc As New PdfDocument()
'Load a sample PDF file
doc.LoadFromFile("C:\Users\Administrator\Desktop\sample.pdf")
'Load the certificate
Dim cert As New PdfCertificate("C:\Users\Administrator\Desktop\MyCertificate.pfx", "e-iceblue")
'Create a PdfSignature object and specify its position and size
Dim signature As New PdfSignature(doc, doc.Pages(doc.Pages.Count - 1), cert, "MySignature")
24 RectangleF rectangleF = New RectangleF(doc.Pages(0).ActualSize.Width - 260 - 54, 200, 260, 110)
signature.Bounds = rectangleF
signature.Certificated = True
'Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail
'Set the signature content
signature.NameLabel = "Signer:"
signature.Name = "Gary"
signature.ContactInfoLabel = "Phone:"
signature.ContactInfo = "0123456"
signature.DateLabel = "Date:"
signature.Date = DateTime.Now
signature.LocationInfoLabel = "Location:"
signature.LocationInfo = "USA"
signature.ReasonLabel = "Reason:"
signature.Reason = "I am the author"
signature.DistinguishedNameLabel = "DN:"
signature.DistinguishedName = signature.Certificate.IssuerName.Name
'Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\Users\Administrator\Desktop\handwrittingSignature.png")
'Set the signature font
signature.SignDetailsFont = New PdfTrueTypeFont(New Font("Arial Unicode MS", 12F, FontStyle.Regular))
'Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges PdfCertificationFlags.AllowFormFill
'Save to file
doc.SaveToFile("VisiableSignature.pdf")
doc.Close()
Das digitale Signieren von PDFs kann in verschiedenen Bereichen hilfreich sein, sei es zur Authentifizierung von PDF-Dokumenten oder einfach zum Abzeichnen eines neuen Projekts. IronPDF bietet einen einfachen Ansatz zum Hinzufügen digitaler Signaturen, mit IronPDF können Sie den Prozess der digitalen Signatur leicht automatisieren. Spire.PDF unterstützt auch digitale Signaturen für PDFs, jedoch kann der Prozess manueller sein und mehr Arbeit erfordern, um implementiert zu werden.
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
Imports IronPdf
' Stamps a Watermark onto a new or existing PDF
Private renderer = New ChromePdfRenderer()
Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
pdf.SaveAs("C:\Path\To\Watermarked.pdf")
Spire.PDF Beispiel:
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
//Create a PdfDocument object
PdfDocument pdf = new PdfDocument();
//Load a sample PDF document
pdf.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf");
//Create a PdfTrueTypeFont object
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 50f), true);
//Set the watermark text
string text = "CONFIDENTIAL";
//Measure the text size
SizeF textSize = font.MeasureString(text);
//Calculate the values of two offset variables,
//which will be used to calculate the translation amount of the coordinate system
float offset1 = (float)(textSize.Width * System.Math.Sqrt(2) / 4);
float offset2 = (float)(textSize.Height * System.Math.Sqrt(2) / 4);
//Traverse all the pages in the document
foreach (PdfPageBase page in pdf.Pages)
{
//Set the page transparency
page.Canvas.SetTransparency(0.8f);
//Translate the coordinate system by specified coordinates
page.Canvas.TranslateTransform(page.Canvas.Size.Width / 2 - offset1 - offset2, page.Canvas.Size.Height / 2 + offset1 - offset2);
//Rotate the coordinate system 45 degrees counterclockwise
page.Canvas.RotateTransform(-45);
//Draw watermark text on the page
page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0);
}
//Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf");
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
//Create a PdfDocument object
PdfDocument pdf = new PdfDocument();
//Load a sample PDF document
pdf.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf");
//Create a PdfTrueTypeFont object
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 50f), true);
//Set the watermark text
string text = "CONFIDENTIAL";
//Measure the text size
SizeF textSize = font.MeasureString(text);
//Calculate the values of two offset variables,
//which will be used to calculate the translation amount of the coordinate system
float offset1 = (float)(textSize.Width * System.Math.Sqrt(2) / 4);
float offset2 = (float)(textSize.Height * System.Math.Sqrt(2) / 4);
//Traverse all the pages in the document
foreach (PdfPageBase page in pdf.Pages)
{
//Set the page transparency
page.Canvas.SetTransparency(0.8f);
//Translate the coordinate system by specified coordinates
page.Canvas.TranslateTransform(page.Canvas.Size.Width / 2 - offset1 - offset2, page.Canvas.Size.Height / 2 + offset1 - offset2);
//Rotate the coordinate system 45 degrees counterclockwise
page.Canvas.RotateTransform(-45);
//Draw watermark text on the page
page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0);
}
//Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf");
Imports System
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing
'Create a PdfDocument object
Private pdf As New PdfDocument()
'Load a sample PDF document
pdf.LoadFromFile("C:\Users\Administrator\Desktop\sample.pdf")
'Create a PdfTrueTypeFont object
Dim font As New PdfTrueTypeFont(New Font("Arial", 50F), True)
'Set the watermark text
Dim text As String = "CONFIDENTIAL"
'Measure the text size
Dim textSize As SizeF = font.MeasureString(text)
'Calculate the values of two offset variables,
'which will be used to calculate the translation amount of the coordinate system
Dim offset1 As Single = CSng(textSize.Width * Math.Sqrt(2) / 4)
Dim offset2 As Single = CSng(textSize.Height * Math.Sqrt(2) / 4)
'Traverse all the pages in the document
For Each page As PdfPageBase In pdf.Pages
'Set the page transparency
page.Canvas.SetTransparency(0.8F)
'Translate the coordinate system by specified coordinates
page.Canvas.TranslateTransform(page.Canvas.Size.Width \ 2 - offset1 - offset2, page.Canvas.Size.Height \ 2 + offset1 - offset2)
'Rotate the coordinate system 45 degrees counterclockwise
page.Canvas.RotateTransform(-45)
'Draw watermark text on the page
page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0)
Next page
'Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf")
IronPDF bietet eine einfache Methode zum Hinzufügen von Textwasserzeichen und gibt Ihnen dabei volle Kontrolle über die Position und das Design des Wasserzeichens. Die Verwendung von HTML und CSS durch IronPDF bedeutet, dass der Prozess noch einfacher ist, wenn Sie Erfahrung mit diesen Sprachen haben. Der Ansatz von Spire.PDF ist langwieriger und erfordert einen manuellen Prozess, bietet jedoch trotzdem ein starkes Wasserzeichen-Tool mit vollständiger Kontrolle über das Design und die Position.
using IronPdf;
using IronPdf.Editing;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");
using IronPdf;
using IronPdf.Editing;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");
Imports IronPdf
Imports IronPdf.Editing
' Instantiate Renderer
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create text stamper
Private textStamper As New TextStamper() With {
.Text = "Text Stamper!",
.FontFamily = "Bungee Spice",
.UseGoogleFont = True,
.FontSize = 30,
.IsBold = True,
.IsItalic = True,
.VerticalAlignment = VerticalAlignment.Top
}
' Stamp the text stamper
pdf.ApplyStamp(textStamper)
pdf.SaveAs("stampText.pdf")
' Create image stamper
Dim imageStamper As New ImageStamper(New Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg")) With {.VerticalAlignment = VerticalAlignment.Top}
' Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0)
pdf.SaveAs("stampImage.pdf")
Spire.PDF:
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
//save graphics state
PdfGraphicsState state = page.Canvas.Save();
//Draw the text - transform
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);
PdfSolidBrush brush1 = new PdfSolidBrush(Color.DeepSkyBlue);
PdfSolidBrush brush2 = new PdfSolidBrush(Color.CadetBlue);
page.Canvas.TranslateTransform(20, 200);
page.Canvas.ScaleTransform(1f, 0.6f);
page.Canvas.SkewTransform(-10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0);
page.Canvas.SkewTransform(10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0);
page.Canvas.ScaleTransform(1f, -1f);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18);
//restore graphics
page.Canvas.Restore(state);
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
//save graphics state
PdfGraphicsState state = page.Canvas.Save();
//Draw the text - transform
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);
PdfSolidBrush brush1 = new PdfSolidBrush(Color.DeepSkyBlue);
PdfSolidBrush brush2 = new PdfSolidBrush(Color.CadetBlue);
page.Canvas.TranslateTransform(20, 200);
page.Canvas.ScaleTransform(1f, 0.6f);
page.Canvas.SkewTransform(-10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0);
page.Canvas.SkewTransform(10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0);
page.Canvas.ScaleTransform(1f, -1f);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18);
//restore graphics
page.Canvas.Restore(state);
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing
'save graphics state
Private state As PdfGraphicsState = page.Canvas.Save()
'Draw the text - transform
Private font As New PdfFont(PdfFontFamily.Helvetica, 18F)
Private brush1 As New PdfSolidBrush(Color.DeepSkyBlue)
Private brush2 As New PdfSolidBrush(Color.CadetBlue)
page.Canvas.TranslateTransform(20, 200)
page.Canvas.ScaleTransform(1F, 0.6F)
page.Canvas.SkewTransform(-10, 0)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0)
page.Canvas.SkewTransform(10, 0)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0)
page.Canvas.ScaleTransform(1F, -1F)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18)
'restore graphics
page.Canvas.Restore(state)
Das Text- und Bildstempel-Werkzeug von IronPDF ist ein leistungsstarkes, benutzerfreundliches Stempelwerkzeug, das einen Ansatz ähnlich HTML und CSS verwendet, wenn der gestempelte Inhalt angewendet wird. Während Spire.PDF auch ein grundlegendes Textstempel-Werkzeug bietet, erfordert es mehr Aufwand, um den gestempelten Text auf Ihre PDF-Dateien anzuwenden.
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
Imports IronPdf
' Instantiate Renderer
Private renderer As New DocxToPdfRenderer()
' Render from DOCX file
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
' Save the PDF
pdf.SaveAs("pdfFromDocx.pdf")
Spire.PDF:
Spire.PDF selbst kann DOCX nicht in PDF konvertieren, jedoch kann die Spire.Doc-Bibliothek für diese Konvertierung verwendet werden, und anschließend können Sie Spire.PDF nutzen, um mit dem resultierenden PDF weiterzuarbeiten.
using Spire.Doc;
// Create a Document object
Document doc = new Document();
// Load a Word document
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.docx");
// Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF);
// Dispose resources
doc.Dispose();
using Spire.Doc;
// Create a Document object
Document doc = new Document();
// Load a Word document
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.docx");
// Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF);
// Dispose resources
doc.Dispose();
Imports Spire.Doc
' Create a Document object
Private doc As New Document()
' Load a Word document
doc.LoadFromFile("C:\Users\Administrator\Desktop\Sample.docx")
' Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF)
' Dispose resources
doc.Dispose()
IronPDF bietet integrierte Unterstützung für die direkte Konvertierung von DOCX zu PDF, was bedeutet, dass Sie Zeit sparen, da Sie keine zusätzlichen Bibliotheken installieren müssen, um diese Aufgabe zu erledigen. Spire.PDF hingegen kann die direkte Umwandlung von DOCX in PDF nicht durchführen, daher müssten Sie die Spire.Doc-Bibliothek installieren, um Ihre DOCX-Dateien in PDF zu konvertieren.
Nachfolgend finden Sie eine Vergleichstabelle, die die wesentlichen Unterschiede bei der Code-Implementierung zwischen IronPDF und Spire.PDF für .NET zusammenfasst:
IronPDFhat verschiedene Stufen und zusätzliche Funktionen beim Erwerb einer Lizenz. Entwickler können auch kaufenIron Suitewas Ihnen Zugang zu allen Produkten von IronSoftware zum Preis von zwei bietet. Wenn Sie noch nicht bereit sind, eine Lizenz zu kaufen, bietet IronPDF einekostenloser Testdie 30 Tage dauert.
Iron Suite: Für 1.498 USD erhalten Sie Zugang zu allen Iron Software-Produkten, einschließlich IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint und IronWebScraper.
Spire.PDF bietet je nach Bedarf eine Vielzahl von Lizenzen an.
IronPDF zeichnet sich durch die Bereitstellung einer umfassenden Dokumentation und Unterstützung aus:
PDF-API-Referenz: Bietet API-Referenzen, damit Sie das Beste aus unseren Tools herausholen können.
Weitere Informationen finden Sie in der umfangreichen IronPDF-Websitedokumentationund besuchen Sie dieIron Software YouTube-Kanal.
Abschließend lässt sich sagen, dass IronPDF und Spire.PDF für .NET leistungsstarke Werkzeuge zur Bearbeitung von PDF-Dokumenten in .NET-Anwendungen sind. IronPDF überzeugt durch Benutzerfreundlichkeit, plattformübergreifende Kompatibilität und Unterstützung moderner Webstandards, was es zur bevorzugten Wahl macht, wenn Sie Ihre Arbeit mit PDF-Dokumenten auf das nächste Level bringen möchten. Spire.PDF bietet eine umfassende Auswahl an Funktionen, kann jedoch für komplexe Aufgaben mehr Aufwand erfordern und möglicherweise nicht das reiche, umfangreiche Sortiment an Funktionen haben, das IronPDF bietet.
Sie können den 0 Tage kostenloser Test um ihre verfügbaren Funktionen zu überprüfen.
10 .NET API-Produkte für Ihre Bürodokumente