SpirePDF C# HTML do PDF Tutorial & Porównanie bibliotek
Konwersja HTML do PDF jest kluczowym wymogiem dla wielu aplikacji .NET, od generowania faktur i raportów po tworzenie dokumentacji i e-booków. Przy wyborze między IronPDF a Spire.PDF do konwersji plików HTML na PDF niezbędne jest zrozumienie ich mocnych stron, ograniczeń i rzeczywistej wydajności. To kompleksowe porównanie analizuje możliwości obu bibliotek, pomagając w podjęciu świadomej decyzji dotyczącej wymagań związanych z generowaniem plików PDF.
Jakie są kluczowe różnice między IronPDF a Spire.PDF w zakresie konwersji HTML do PDF?
IronPDF to wszechstronna biblioteka .NET do obsługi plików PDF, zaprojektowana do wykonywania szerokiego zakresu zadań związanych z plikami PDF, w tym konwersji plików PDF, edycji plików PDF, tworzenia plików PDF, odczytu plików PDF i wielu innych. Rozwiązanie to znane jest z łatwości integracji z istniejącymi aplikacjami .NET, wysokiej wydajności oraz obsługi nowoczesnych standardów internetowych, takich jak HTML5, CSS3 i JavaScript. Silnik renderujący IronPDF oparty na przeglądarce Chrome zapewnia generowanie plików PDF o idealnej rozdzielczości na podstawie treści HTML.
Spire.PDF for .NET to kolejna potężna biblioteka .NET do obsługi plików PDF, która zapewnia kompleksowy zestaw funkcji do tworzenia i edycji plików PDF. Obsługuje różne funkcje związane z plikami PDF, takie jak wyodrębnianie tekstu i obrazów, wypełnianie formularzy PDF oraz podpisy cyfrowe. Chociaż narzędzie ma wszechstronne funkcje, jego możliwości konwersji HTML do PDF mają konkretne ograniczenia, które programiści powinni wziąć pod uwagę.
| Kategoria | Funkcja/Aspekt | IronPDF | Spire.PDF | Kluczowa zaleta |
|---|---|---|---|---|
| Podstawowa architektura | Design Philosophy | Simplicity-first, intuitive APIs | Podejście wieloklasowe, konfiguracja ręczna | IronPDF: Faster development |
| API Complexity | Simple methods like RenderHtmlAsPdf() |
Wymagane podejście wielowątkowe | IronPDF: 70% less code | |
| Krzywa uczenia się | Zazwyczaj 1–2 dni | Zazwyczaj 1–2 tygodnie | IronPDF: Quicker adoption | |
| Obsługa platform | Wieloplatformowe | Wbudowana obsługa, bez dodatkowych pakietów | Ograniczona obsługa systemów Linux/macOS | IronPDF: Prawdziwa wieloplatformowość |
| Wersje .NET | .NET 8, 7, 6, 5, Core 3.1+, Framework 4.6.2+ | .NET Core 2.0+, Framework 2.0+ | Oba: Szerokie wsparcie dla frameworków | |
| Systemy operacyjne | Windows, Linux, macOS, Docker native | Skupia się głównie na systemie Windows | IronPDF: Broader OS support | |
| HTML do PDF | Silnik renderujący | Pełny silnik Chrome V8 | Niestandardowy parser HTML | IronPDF: zgodność z przeglądarkami na poziomie ponad 98% |
| Obsługa CSS3/HTML5 | Pełne wsparcie | Ograniczone (tylko podstawowy CSS) | IronPDF: Nowoczesne standardy internetowe | |
| Wykonanie JavaScript | Pełna obsługa JavaScript | Zaplanowane, ale niezrealizowane | IronPDF: Dynamic content ready | |
| Czcionki internetowe | Czcionki Google, czcionki systemowe | Ograniczona obsługa czcionek | IronPDF: Elastyczność typograficzna | |
| Szybkość renderowania | Typowo 0,8–1,2 s | 0,5–0,8 s dla prostego kodu HTML | Spire: Szybszy dla podstawowego HTML | |
| Security & Encryption | Poziomy szyfrowania | AES-256, niestandardowe procedury obsługi | Standard AES-256 | Oba: Standard branżowy |
| Prostota API | Pojedyncza klasa SecuritySettings |
Wiele metod zabezpieczeń | IronPDF: Ujednolicone podejście | |
| Manipulacja treścią | Metoda redakcji | Prawdziwe usuwanie treści, jednowierszowe API | Ręczne nakładanie prostokątów | IronPDF: Gotowość do zapewnienia zgodności |
| Znak wodny | Oparty na HTML/CSS, pełna stylizacja | Text-based with rotation | IronPDF: Bogate znaki wodne | |
| Konwersja plików | DOCX do PDF | Wbudowany DocxToPdfRenderer |
Wymagana biblioteka Spire.Doc | IronPDF: Bez dodatkowych kosztów |
| Wskaźniki wydajności | Wykorzystanie pamięci | 150–200 MB (silnik Chrome) | 80–120 MB | Spire: mniejsze zużycie pamięci |
| Obsługa wątków | Zoptymalizowane pod kątem natywnego async/await | Wymagany wątek STA | IronPDF: Nowoczesne wzorce asynchroniczne | |
| Doświadczenie programisty | Przykłady kodu | 100+ ready-to-run samples | Podstawowe przykłady | IronPDF: Extensive resources |
| Komunikaty błędów | Descriptive, actionable | Komunikaty techniczne | IronPDF: Better debugging | |
| Licensing & Pricing | Entry Level | Lite: $799 (1 dev, 1 project) | Developer: $1,199/year (1 dev) | IronPDF: Licencja wieczysta |
| Team License | Plus: $1,199 (3 devs, 3 projects) | Strona: 4599 USD (10 programistów) | IronPDF: Większa wartość dla zespołu | |
| Suite Option | Iron Suite: $1,498 (9 products) | No suite option | IronPDF: Exceptional value | |
| Wsparcie | Wsparcie techniczne w cenie | Yes, 24/5 engineering support | Tylko forum (płatna pomoc techniczna dodatkowo) | IronPDF: Wsparcie w cenie |
| Kanały wsparcia | E-mail, czat, telefon, udostępnianie ekranu | Forum, e-mail (poziomy płatne) | IronPDF: Więcej kanałów | |
| Najlepsze dla | Przykłady zastosowań | Modern web apps, complex HTML/CSS | Simple documents, basic layouts | Context-dependent |
For more detailed information about IronPDF, visit IronPDF.com.
How Does Wieloplatformowe Compatibility Compare Between the Libraries?
IronPDF
IronPDF stands out with its extensive cross-platform compatibility. It supports a wide range of environments within the .NET framework, ensuring seamless operation across different platforms. Below is a summary of IronPDF's platform compatibility:
-
.NET versions:
- Fully written in and supports C#, VB.NET, and F#
- .NET Core (8, 7, 6, 5, and 3.1+)
- .NET Standard (2.0+)
- .NET Framework (4.6.2+)
- App environments: IronPDF works within various app environments such as Windows, Linux, Mac, Docker, Azure, and AWS.
- IDEs: Works with IDEs such as Microsoft Visual Studio and JetBrains Rider & ReSharper
- OS and Processors: Supports several different OS & processors including Windows, Mac, Linux, x64, x86, ARM
For more details on IronPDF's compatibility, visit the IronPDF Features Page.
Spire.PDF
Spire.PDF has full support within the .NET environment, but while it works within the Windows operating system, it lacks the native support for Linux and macOS that IronPDF has. When deploying on macOS or Linux, Spire.PDF requires different plugins for each platform, which can complicate deployment scenarios.
-
.NET Support:
- .NET Framework 2.0+
- .NET Core 2.0+
- Written in C#, with support for VB.NET
- App Environments: Spire.PDF works in various app environments such as Windows and ASP.NET applications. It can also support Windows Forms.
Which Library Offers Better HTML to PDF Conversion Features?
Funkcje IronPDF
- PDF conversion: IronPDF can convert HTML to PDF. With its full support for modern web standards, you can be assured that IronPDF will consistently return pixel-perfect PDFs from your HTML content. IronPDF can also convert PDF files from other formats such as DOCX, images, RTF, and more.
- PDF Generation: With IronPDF, you can generate PDFs from URLs, ASPX files, or HTML strings.
- Security features: With IronPDF, you can always be assured that any sensitive PDF files are secure thanks to its security features. Use IronPDF to encrypt your PDF files, set passwords, and set permissions for your PDF files.
- PDF editing features: With IronPDF you can process existing PDF documents, edit them, and read PDF files with ease. IronPDF offers editing features such as adding headers and footers, stamping text and images onto the PDF pages, adding custom watermarks to the PDF, working with PDF forms, and splitting or merging PDF files.
- Integration: Seamlessly integrates with ASP.NET and MVC applications.
- PDF version support: Can support PDF version 1.2-1.7
For a comprehensive list of IronPDF features, visit IronPDF Features.
Spire.PDF Features
- PDF Creation: Create PDFs from scratch or existing files.
- Text and Image Extraction: Use Spire.PDF to extract PDF pages and content.
- PDF Form Handling: Fill and manage PDF forms.
- PDF Conversion: Convert PDFs to other formats like HTML, RTF, and images.
- Page Manipulation: Insert, delete, and reorder pages in a PDF.
- Limited HTML Support: The HTML to PDF engine has limited support for modern CSS and JavaScript. The default Qt-based plugin doesn't support CSS page-break properties or external CSS file recognition, and JavaScript execution is a planned feature that is not fully implemented. An optional ChromeHtmlConverter is available for better rendering.
Bootstrap and Modern CSS Framework Rendering
Modern web development relies heavily on CSS frameworks like Bootstrap for rapid UI development and responsive design. PDF generation libraries must accurately convert these frameworks to maintain professional document quality and design consistency.
IronPDF: Full Bootstrap and Tailwind Support
IronPDF's Chromium engine delivers complete support for all modern CSS frameworks:
- Bootstrap 5: Full flexbox and CSS Grid support with all responsive components
- Bootstrap 4: Complete card layouts, navigation systems, and utility classes
- Tailwind CSS: All utility-first classes and responsive modifiers
- Foundation: Complete grid and component systems
- Modern CSS3: Flexbox, Grid, custom properties, animations, and transforms
Proven with real examples: Bootstrap homepage and Bootstrap templates convert with pixel-perfect accuracy.
Code Example: Team Member Cards with Bootstrap
using IronPdf;
var renderer = new ChromePdfRenderer();
string bootstrapTeam = @"
<!DOCTYPE html>
<html>
<head>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
<div class='container my-5'>
<h1 class='text-center mb-5'>Our Team</h1>
<div class='row row-cols-1 row-cols-md-3 g-4'>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Jennifer Martinez</h5>
<p class='text-muted mb-3'>Chief Technology Officer</p>
<p class='card-text flex-grow-1'>Leading our technical vision and innovation strategy with over 15 years of experience in software architecture.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>David Chen</h5>
<p class='text-muted mb-3'>Head of Engineering</p>
<p class='card-text flex-grow-1'>Managing our engineering teams and ensuring product quality through rigorous testing and code review processes.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Sarah Johnson</h5>
<p class='text-muted mb-3'>Product Manager</p>
<p class='card-text flex-grow-1'>Driving product strategy and customer satisfaction through data-driven decisions and user research.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<h3>Join Our Team</h3>
<p class='text-muted mb-3'>We're always looking for talented individuals to join our growing team.</p>
<a href='#' class='btn btn-primary btn-lg'>View Open Positions</a>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(bootstrapTeam);
pdf.SaveAs("team-members.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
string bootstrapTeam = @"
<!DOCTYPE html>
<html>
<head>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
<div class='container my-5'>
<h1 class='text-center mb-5'>Our Team</h1>
<div class='row row-cols-1 row-cols-md-3 g-4'>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Jennifer Martinez</h5>
<p class='text-muted mb-3'>Chief Technology Officer</p>
<p class='card-text flex-grow-1'>Leading our technical vision and innovation strategy with over 15 years of experience in software architecture.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>David Chen</h5>
<p class='text-muted mb-3'>Head of Engineering</p>
<p class='card-text flex-grow-1'>Managing our engineering teams and ensuring product quality through rigorous testing and code review processes.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Sarah Johnson</h5>
<p class='text-muted mb-3'>Product Manager</p>
<p class='card-text flex-grow-1'>Driving product strategy and customer satisfaction through data-driven decisions and user research.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<h3>Join Our Team</h3>
<p class='text-muted mb-3'>We're always looking for talented individuals to join our growing team.</p>
<a href='#' class='btn btn-primary btn-lg'>View Open Positions</a>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(bootstrapTeam);
pdf.SaveAs("team-members.pdf");
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim bootstrapTeam As String = "
<!DOCTYPE html>
<html>
<head>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
<div class='container my-5'>
<h1 class='text-center mb-5'>Our Team</h1>
<div class='row row-cols-1 row-cols-md-3 g-4'>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Jennifer Martinez</h5>
<p class='text-muted mb-3'>Chief Technology Officer</p>
<p class='card-text flex-grow-1'>Leading our technical vision and innovation strategy with over 15 years of experience in software architecture.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>David Chen</h5>
<p class='text-muted mb-3'>Head of Engineering</p>
<p class='card-text flex-grow-1'>Managing our engineering teams and ensuring product quality through rigorous testing and code review processes.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Sarah Johnson</h5>
<p class='text-muted mb-3'>Product Manager</p>
<p class='card-text flex-grow-1'>Driving product strategy and customer satisfaction through data-driven decisions and user research.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<h3>Join Our Team</h3>
<p class='text-muted mb-3'>We're always looking for talented individuals to join our growing team.</p>
<a href='#' class='btn btn-primary btn-lg'>View Open Positions</a>
</div>
</div>
</body>
</html>"
Dim pdf = renderer.RenderHtmlAsPdf(bootstrapTeam)
pdf.SaveAs("team-members.pdf")
Output: A professional team page with Bootstrap's card grid, flexbox alignment, responsive images, and button components—all accurately rendered in the PDF.
Spire.PDF: Limited HTML and Modern Framework Support
Spire.PDF's HTML-to-PDF engine has significant limitations for modern CSS frameworks, as noted in their own documentation:
- Limited CSS Support: Basic CSS only, no comprehensive CSS3 features
- No Flexbox: Bootstrap 4/5 rely heavily on flexbox which is not supported
- No CSS Grid: Modern layout systems using CSS Grid will not render correctly
- JavaScript Limitations: Minimal JavaScript execution compared to modern browsers
- Bootstrap 3 Maximum: Only older table-based Bootstrap versions work reliably
- Complex Layouts Fail: Modern responsive designs require extensive workarounds
Developer-reported issues with Spire.PDF HTML conversion:
- Bootstrap navigation bars render with layout problems
- Card components with flexbox don't align correctly
- Responsive grid breakpoints are ignored in PDF output
- Modern CSS features require manual CSS rewrites or fallbacks
Development impact: Applications using Bootstrap 4+ or modern CSS frameworks face significant challenges with Spire.PDF. Development teams must:
- Maintain separate simplified CSS specifically for PDF generation (double maintenance)
- Downgrade to Bootstrap 3 or abandon frameworks entirely (limits modern features)
- Extensively test and manually fix each component (time-consuming and brittle)
For projects requiring modern CSS framework support, Spire.PDF's HTML rendering limitations make it unsuitable without major additional development effort and ongoing maintenance burden.
For detailed Bootstrap compatibility information, see the Bootstrap & Flexbox CSS Guide.
How Do Przykłady kodu Compare for Common PDF Tasks?
To illustrate the capabilities of IronPDF and Spire.PDF for .NET, we will compare their implementation of several key PDF functionalities through code examples, giving you an idea of how these features could help with your PDF projects.
Convert HTML to PDF
Przykład IronPDF:
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")
The ChromePdfRenderer class in IronPDF leverages a full Chrome browser engine to render HTML content. This means CSS3 animations, JavaScript execution, and modern web fonts all render exactly as they would in Chrome. The RenderHtmlAsPdf() method accepts HTML strings and optional base paths for loading external assets, making it straightforward to convert both simple and complex HTML documents. The renderer supports advanced rendering options including custom paper sizes, margins, and JavaScript delay settings.
Spire.PDF Example:
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();
// Set 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();
// Set 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()
' Set 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
Spire.PDF's HTML to PDF conversion requires creating multiple objects including PdfDocument, PdfPageSettings, and PdfHtmlLayoutFormat. The conversion must be executed in a Single Thread Apartment (STA) thread, adding complexity to the implementation. Users have reported that "Spire generates a PDF file that is just an image. Some of the css is not even correct, such as ignoring bold fonts", indicating limitations in CSS rendering fidelity.
IronPDF uses Chrome's rendering engine for high-fidelity HTML to PDF conversion, ensuring an accurate representation of web content thanks to its support for modern web standards. Spire.PDF also provides robust HTML to PDF conversion but may not match the rendering precision of IronPDF, and takes a longer, more manual approach.
How Can You Encrypt PDF Documents?
Przykład IronPDF:
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 = 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 = 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 = PdfPrintSecurity.FullPrintRights
' Change or set the document encryption password
pdf.Password = "my-password"
pdf.SaveAs("secured.pdf")
IronPDF's SecuritySettings class provides a comprehensive API for managing PDF security. You can control individual permissions with boolean properties, set different levels of printing rights, and manage passwords separately from other security settings. The API design follows .NET conventions with strongly-typed enumerations like PdfPrintSecurity. Learn more about PDF permissions and passwords in the documentation.
Spire.PDF Example:
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 a 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 a 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 a password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print Or PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit)
' Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF)
Spire.PDF's encryption approach uses the Security.Encrypt() method with bitwise flags for permissions. While more compact, this approach requires understanding of bitwise operations and offers less granular control compared to IronPDF's individual permission properties.
Both libraries provide easy-to-use methods for encrypting PDFs and setting the encrypted PDF documents' readability. IronPDF offers a straightforward approach while still giving you full control over the security settings of your PDF. Spire.PDF takes a slightly shorter process but still includes additional options for setting permissions.
What Are the Options for Redacting PDF Content?
Przykład IronPDF:
using IronPdf;
// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
// Save the redacted document
pdf.SaveAs("redacted.pdf");
using IronPdf;
// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
// Save the redacted document
pdf.SaveAs("redacted.pdf");
Imports IronPdf
' Load the PDF document
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are")
' Save the redacted document
pdf.SaveAs("redacted.pdf")
IronPDF provides a dedicated redaction API that performs true content removal, not just visual masking. The RedactTextOnAllPages() method searches for and permanently removes specified text, ensuring compliance with data protection regulations. Additional methods allow redaction on specific pages or regions.
Spire.PDF Example for Redaction via Rectangle Overlay:
While Spire.PDF does not have a dedicated redaction tool, content can still be redacted using a manual process, as demonstrated below:
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
// 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;
using System.Drawing;
// 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
Imports System.Drawing
' 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)
This manual approach requires calculating exact coordinates for each redaction area and only provides visual masking rather than true content removal. The underlying text may still be extractable through PDF editing tools.
IronPDF simplifies redaction with its robust, yet straightforward, redaction tool. Spire.PDF requires more manual handling for redaction due to the absence of a built-in redaction tool, resulting in potentially less efficient workflows.
How Do You Sign PDF Documents?
Przykład IronPDF:
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Instantiate the renderer
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 PdfSignature with certificate
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;
// Instantiate the renderer
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 PdfSignature with certificate
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
' Instantiate the renderer
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 PdfSignature with certificate
Private sig = New PdfSignature(cert)
' Sign PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")
IronPDF's digital signature implementation follows .NET certificate handling patterns. The PdfSignature class accepts standard X509Certificate2 objects and handles the complexities of PDF signing internally. You can also add visual signature appearances and configure signature fields.
Spire.PDF Example:
using Spire.Pdf;
using Spire.Pdf.Security;
using System.Drawing;
// 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");
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 various details about the signature
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");
using Spire.Pdf;
using Spire.Pdf.Security;
using System.Drawing;
// 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");
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 various details about the signature
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");
Imports Spire.Pdf
Imports Spire.Pdf.Security
Imports System.Drawing
' 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")
Dim rectangleF As 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 various details about the signature
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 Or PdfCertificationFlags.AllowFormFill
' Save to file
doc.SaveToFile("VisiableSignature.pdf")
Spire.PDF zapewnia szerokie możliwości kontroli nad wyglądem podpisu, ale wymaga znacznie większej ilości kodu. Każdą etykietę należy ustawić ręcznie, precyzyjnie pozycjonować podpis i osobno konfigurować elementy wizualne.
Cyfrowe podpisywanie plików PDF może być pomocne w różnych sytuacjach, od uwierzytelniania dokumentów PDF po zwykłe zatwierdzanie nowego projektu. IronPDF oferuje proste podejście do dodawania podpisów cyfrowych, umożliwiając łatwą automatyzację procesu podpisywania. Spire.PDF obsługuje również podpisy cyfrowe w plikach PDF; jednak proces ten może być bardziej ręczny i wymagać większego wysiłku przy wdrażaniu.
Jakie metody znakowania wodnego plików PDF są dostępne?
Przykład IronPDF:
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")
Funkcja znakowania wodnego IronPDF akceptuje treści HTML, co pozwala na użycie CSS do stylizacji. The ApplyWatermark() method provides parameters for rotation angle and alignment, making it easy to position watermarks precisely. Dowiedz się więcej o niestandardowych znakach wodnych i zaawansowanych opcjach stylizacji.
Spire.PDF Example:
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")
Znak wodny w Spire.PDF wymaga ręcznego obliczenia położenia i obrotu przy użyciu transformacji układu współrzędnych. Chociaż zapewnia to precyzyjną kontrolę, wymaga zrozumienia koncepcji programowania graficznego.
IronPDF zapewnia łatwy sposób dodawania tekstowych znaków wodnych, dając jednocześnie pełną kontrolę nad położeniem i wyglądem znaku wodnego. Wykorzystanie HTML i CSS przez IronPDF ułatwia ten proces, jeśli masz doświadczenie w pracy z tymi językami. Podejście Spire.PDF jest bardziej czasochłonne i wymaga większego nakładu pracy ręcznej, ale nadal zapewnia solidne narzędzie do tworzenia znaków wodnych z pełną kontrolą nad projektem i położeniem.
Jak można umieszczać obrazy i tekst na plikach PDF?
Przykład IronPDF:
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")
IronPDF's stamping API uses dedicated classes for different stamp types. The TextStamper supports Google Fonts directly through the UseGoogleFont property, while ImageStamper can load images from URLs or local files. Oba stemple mają wspólne właściwości wyrównania, co zapewnia spójne pozycjonowanie. Poznaj więcej opcji stemplowania, w tym stemple HTML i integrację BarCode.
Spire.PDF (przykład stemplowania tekstu):
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
// Assumes a PdfDocument is already loaded as `doc` object
PdfPageBase page = doc.Pages[0];
PdfGraphicsState state = page.Canvas.Save();
// Define font and brushes for different effects
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);
PdfSolidBrush brush1 = new PdfSolidBrush(Color.DeepSkyBlue);
PdfSolidBrush brush2 = new PdfSolidBrush(Color.CadetBlue);
// Apply transformations and draw strings with shadow and effect
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 to previous state
page.Canvas.Restore(state);
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
// Assumes a PdfDocument is already loaded as `doc` object
PdfPageBase page = doc.Pages[0];
PdfGraphicsState state = page.Canvas.Save();
// Define font and brushes for different effects
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);
PdfSolidBrush brush1 = new PdfSolidBrush(Color.DeepSkyBlue);
PdfSolidBrush brush2 = new PdfSolidBrush(Color.CadetBlue);
// Apply transformations and draw strings with shadow and effect
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 to previous state
page.Canvas.Restore(state);
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing
' Assumes a PdfDocument is already loaded as `doc` object
Private page As PdfPageBase = doc.Pages(0)
Private state As PdfGraphicsState = page.Canvas.Save()
' Define font and brushes for different effects
Private font As New PdfFont(PdfFontFamily.Helvetica, 18F)
Private brush1 As New PdfSolidBrush(Color.DeepSkyBlue)
Private brush2 As New PdfSolidBrush(Color.CadetBlue)
' Apply transformations and draw strings with shadow and effect
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 to previous state
page.Canvas.Restore(state)
Spire.PDF wymaga bezpośredniej manipulacji obszarem roboczym z ręcznymi transformacjami dla każdego efektu. Tworzenie złożonych stempli wymaga zrozumienia zarządzania stanem grafiki i transformacji współrzędnych.
Narzędzie do stemplowania tekstu i obrazów IronPDF to potężne, łatwe w użyciu narzędzie do stemplowania, które działa na zasadzie podobnej do HTML i CSS podczas stosowania stemplowanej treści. Chociaż Spire.PDF oferuje również podstawowe narzędzie do stemplowania tekstu, zastosowanie stemplowanego tekstu w plikach PDF wymaga większego wysiłku.
Która biblioteka lepiej radzi sobie z konwersją plików DOCX do PDF?
Przykład IronPDF:
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")
IronPDF includes a dedicated DocxToPdfRenderer class that handles DOCX conversion natively. API jest spójne z innymi klasami renderowania w IronPDF, wymagając zaledwie dwóch wierszy kodu do podstawowej konwersji. Zaawansowane opcje konfiguracji strony i formatowania są dostępne w oknie właściwości renderera. Dowiedz się więcej o funkcjach konwersji plików DOCX do formatu PDF.
Spire.PDF Korzystanie z Spire.Doc do konwersji plików DOCX na PDF:
Sam program Spire.PDF nie może konwertować plików DOCX do formatu PDF; można jednak użyć biblioteki Spire.Doc do przeprowadzenia tej konwersji, a następnie skorzystać z biblioteki Spire.PDF do pracy z uzyskanym plikiem PDF.
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 of 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 of 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 of resources
doc.Dispose()
Takie podejście wymaga zakupu i zarządzania dodatkową biblioteką (Spire.Doc), co zwiększa zarówno koszty, jak i złożoność.
IronPDF oferuje wbudowaną obsługę bezpośredniej konwersji plików DOCX do formatu PDF, co oznacza, że oszczędzasz czas, nie potrzebując dodatkowych bibliotek do wykonania tego zadania. Z drugiej strony Spire.PDF nie obsługuje bezpośrednio konwersji plików DOCX do formatu PDF, co wymaga użycia biblioteki Spire.Doc do konwersji plików DOCX do formatu PDF.
Co pokazują wskaźniki wydajności?
Na podstawie testów i opinii użytkowników oto jak biblioteki wypadają w praktyce:
Wydajność renderowania
W przypadku podstawowych układów Spire.PDF jest zoptymalizowany pod kątem prostych treści, takich jak statyczne tabele lub tekst o podstawowym stylowaniu, dzięki czemu działa szybko i wydajnie w tych zastosowaniach. Jednak w przypadku złożonego kodu HTML zawierającego nowoczesne funkcje CSS3, JavaScript lub responsywne układy, silnik IronPDF oparty na przeglądarce Chrome zapewnia dokładniejsze wyniki kosztem nieco dłuższego czasu renderowania.
Wykorzystanie pamięci
Spire.PDF zazwyczaj zużywa mniej pamięci (80–120 MB) w porównaniu z IronPDF (150–200 MB) ze względu na prostszy silnik renderowania. Odbywa się to jednak kosztem wierności renderowania i obsługi funkcji. W przypadku aplikacji, w których pamięć ma kluczowe znaczenie, a złożoność kodu HTML jest minimalna, korzystnym rozwiązaniem może być Spire.PDF.
Obsługa wątków i asynchroniczności
IronPDF provides native async/await support with methods like RenderHtmlAsPdfAsync(), making it suitable for modern .NET applications. Spire.PDF wymaga ręcznego zarządzania wątkami za pomocą wątków STA, co zwiększa złożoność aplikacji wielowątkowych.
Jak wypadają modele cenowe i licencyjne w porównaniu?
Ceny i licencje IronPDF
IronPDF oferuje różne poziomy i dodatkowe funkcje w ramach zakupu licencji. Programiści mogą również kupić pakiet Iron Suite, który zapewnia dostęp do wszystkich produktów Iron Software w cenie dwóch. If you're not ready to buy a license, IronPDF provides a free trial that lasts 30 days.
Pricing (as of 2025):
- Perpetual licenses: Offers a range of perpetual licenses depending on the size of your team, your project needs, and the number of locations. Each license type comes with email support.
- Lite License: This license costs $799 and supports one developer, one location, and one project.
- Plus License: Supporting three developers, three locations, and three projects, this is the next step up from the lite license and costs $1,199. The Plus license offers chat support and phone support in addition to basic email support.
- Professional License: This license is suitable for larger teams, supporting ten developers, ten locations, and ten projects for $2,399. It offers the same contact support channels as the previous tiers but also offers screen-sharing support.
- Royalty-free redistribution: IronPDF's licensing also offers royalty-free redistribution coverage for an extra $2,399
- Uninterrupted product support: IronPDF offers access to ongoing product updates, security feature upgrades, and support from their engineering team for either $999/year or a one-time purchase of $1,999 for a 5-year coverage.
- Iron Suite: For $1,498, you get access to all Iron Software products including IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint, and IronWebScraper.
IronPDF oferuje elastyczne opcje licencyjne z licencjami wieczystymi i kompleksowym wsparciem technicznym w cenie
Ceny i licencje Spire.PDF
Spire.PDF oferuje szeroki wybór licencji w zależności od potrzeb.
- Wersja bezpłatna: Spire.PDF oferuje bezpłatną wersję ograniczoną do 10 stron PDF; poza tym konieczne będzie zakupienie płatnej licencji.
- Subskrypcja dla programistów: W cenie 999 lub 1199 USD rocznie, w zależności od rodzaju potrzebnego wsparcia, ta opcja jest przeznaczona dla programistów, którzy muszą tworzyć funkcje związane z plikami PDF, ale nie potrzebują praw do dystrybucji OEM.
- Subskrypcja OEM dla programistów: Kosztuje około 2549–4248 USD rocznie w zależności od zakresu potrzebnego wsparcia i obejmuje bezpłatne aktualizacje, wsparcie premium oraz możliwość dystrybucji aplikacji wśród użytkowników końcowych.
- Site Small Business: W cenie 4599 USD lub 7598 USD, w zależności od wybranego poziomu wsparcia, ten poziom licencji obejmuje obsługę maksymalnie 10 programistów w maksymalnie 10 lokalizacjach, aktualizacje przez 1 rok oraz bezpłatne zasoby techniczne online.
- Subskrypcja OEM: Kosztuje od 13 088 do 16 687 USD rocznie w zależności od rodzaju potrzebnego wsparcia i jest skierowana do większych Enterprise, które muszą wdrażać aplikacje w wielu lokalizacjach.
Która biblioteka zapewnia lepszą dokumentację i wsparcie?
IronPDF
IronPDF excels in providing extensive documentation and support:
- Kompleksowa dokumentacja: Obszerna i przyjazna dla użytkownika dokumentacja obejmująca wszystkie funkcje.
- 24/5 Support: Active engineer support is available.
- Video Tutorials: Step-by-step video guides are available on YouTube.
- Community Forum: Engaged community for additional support.
- Regular Updates: Monthly product updates to ensure the latest features and security patches.
- Dokumentacja API PDF: Zawiera informacje o API, dzięki czemu możesz w pełni wykorzystać możliwości naszych narzędzi.
Aby uzyskać więcej informacji, zapoznaj się z obszerną dokumentacją IronPDF i odwiedź kanał Iron Software na YouTube.
Dokumentacja i wsparcie techniczne Spire.PDF dla .NET
- Fora: Spire.PDF posiada forum, na którym użytkownicy mogą nawiązywać kontakty, dzieląc się wskazówkami, sposobami wykorzystania oraz problemami napotkanymi podczas korzystania z Spire.PDF.
- Przykłady kodu: Spire.PDF udostępnia na swojej stronie internetowej przykłady kodu, aby pokazać, jak korzystać z produktu w różnych sytuacjach.
- Biuletyny: Spire.PDF oferuje biuletyn dla programistów zawierający ogłoszenia o aktualizacjach i inne ważne informacje.
- Wsparcie: Wsparcie techniczne jest udzielane głównie za pośrednictwem forów, a płatna pomoc przez e-mail lub telefon jest dostępna za dodatkową opłatą w zależności od wersji licencji.
Jakie są typowe doświadczenia i opinie programistów?
Na podstawie opinii społeczności i rzeczywistego zastosowania:
Opinie over IronPDF
Programiści nieustannie chwalą IronPDF za zapewnienie "bardziej kompleksowego i precyzyjnego odwzorowania oryginalnej strony HTML". Zdolność biblioteki do obsługi złożonych układów CSS3, stron z dużą ilością kodu JavaScript oraz nowoczesnych frameworków internetowych sprawia, że jest ona preferowanym wyborem dla aplikacji wymagających generowania plików PDF o wysokiej jakości.
Typowe pozytywne aspekty to:
- Intuicyjna konstrukcja API, która skraca czas programowania
- Doskonała jakość renderowania zgodna z wyświetlaniem w przeglądarce
- Kompleksowa dokumentacja z praktycznymi przykładami
- Responsywne wsparcie techniczne
Spire.PDF Opinie
Z opinii społeczności wynika, że "Spire generuje plik PDF, który jest po prostu obrazem". Niektóre elementy css są nieprawidłowe, np. ignorowanie pogrubionych czcionek. Ponadto obsługa JavaScript pozostaje funkcją planowaną, która "byłaby tak trudna, że nie da się jej zrealizować w krótkim czasie", zgodnie z oficjalnymi odpowiedziami działu wsparcia.
Typowe kwestie wymagające uwagi to:
- Ograniczona obsługa CSS3 i nowoczesnych standardów internetowych
- Brak możliwości wykonywania kodu JavaScript
- Złożone wymagania dotyczące wątków przy konwersji HTML
- Dodatkowe wymagania biblioteki dotyczące niektórych funkcji
Kiedy należy wybrać daną bibliotekę?
Kiedy wybrać IronPDF:
- Twój kod HTML zawiera nowoczesne elementy CSS3, JavaScript lub responsywne projekty
- Potrzebne jest renderowanie z dokładnością co do piksela, zgodne z wyświetlaniem w przeglądarce
- Wymagane jest wdrożenie na wielu platformach (Linux, macOS, Docker)
- Chcesz, aby Twoja licencja obejmowała kompleksowe wsparcie
- Potrzebujesz wbudowanych funkcji, takich jak konwersja plików DOCX bez konieczności korzystania z dodatkowych bibliotek
- Twój zespół ceni sobie szybki rozwój przy minimalnej ilości kodu
Kiedy wybrać Spire.PDF:
- Twoje pliki PDF zawierają wyłącznie podstawowy kod HTML z prostym formatowaniem
- Zużycie pamięci jest kluczowym ograniczeniem
- You primarily work in Windows environments
- Your HTML doesn't require JavaScript execution
- You already use other Spire products in your stack
Wnioski
In conclusion, IronPDF and Spire.PDF for .NET are both capable tools for handling PDF documents in .NET applications. IronPDF excels in ease of use, cross-platform compatibility, and support for modern web standards, making it a preferred choice if you are looking to step up your game when working with PDF documents. Spire.PDF offers a comprehensive set of features but may require more effort for complex tasks and lacks the rendering precision that modern web applications demand.
For developers working with contemporary web technologies, requiring accurate HTML to PDF conversion, or needing reliable cross-platform support, IronPDF presents a more complete solution. Its Chrome-based rendering engine, intuitive API, and comprehensive support make it particularly suitable for enterprise applications and complex document generation scenarios.
You can try the 30-day free trial to check out their available features.
Często Zadawane Pytania
Jak mogę przekonwertować HTML na PDF w języku C#?
Możesz użyć metody RenderHtmlAsPdf biblioteki IronPDF do konwersji ciągów HTML na pliki PDF. Możesz również konwertować pliki HTML na pliki PDF za pomocą metody RenderHtmlFileAsPdf.
Czy IronPDF obsługuje wykonywanie kodu JavaScript podczas konwersji HTML do PDF?
Tak, IronPDF obsługuje pełne wykonywanie kodu JavaScript, dzięki czemu idealnie nadaje się do konwersji treści dynamicznych lub układów zależnych od JavaScriptu do formatu PDF.
Jakie platformy obsługuje IronPDF do konwersji plików PDF?
IronPDF oferuje natywną obsługę wielu platform, w tym Windows, Linux, macOS, Docker, a także usług chmurowych, takich jak Azure i AWS.
Jak wygląda zużycie pamięci przez IronPDF w porównaniu z Spire.PDF?
IronPDF zużywa nieco więcej pamięci, zazwyczaj między 150 a 200 MB, w porównaniu z 80–120 MB w przypadku Spire.PDF, ale zapewnia lepszą jakość renderowania i obsługuje nowoczesne wzorce async/await.
Czy IronPDF może bezpośrednio konwertować pliki DOCX do formatu PDF?
Tak, IronPDF zawiera wbudowane funkcje konwersji plików DOCX do formatu PDF za pośrednictwem klasy DocxToPdfRenderer, bez konieczności korzystania z dodatkowych bibliotek.
Jakie są opcje licencyjne dla IronPDF?
IronPDF oferuje licencje wieczyste już od 749 USD dla pojedynczych programistów, obejmujące wszystkie funkcje i wsparcie techniczne. Oferuje również pakiet Iron Suite zawierający 9 produktów za 1498 USD.
Jakiego rodzaju wsparcie oferuje IronPDF?
IronPDF zapewnia wsparcie techniczne 24/5 za pośrednictwem poczty elektronicznej, czatu, telefonu oraz udostępniania ekranu dla wszystkich licencji, gwarantując kompleksową pomoc.
Jak mogę zapewnić bezpieczeństwo i szyfrowanie plików PDF za pomocą IronPDF?
IronPDF obsługuje szyfrowanie AES-256 i ochronę hasłem za pośrednictwem klasy SecuritySettings, umożliwiając szczegółową kontrolę nad uprawnieniami do plików PDF.
Czy IronPDF nadaje się do renderowania złożonych stron internetowych z nowoczesnym CSS?
Tak, IronPDF wykorzystuje pełny silnik renderujący Chrome, który obsługuje CSS3, flexbox, układy siatki, czcionki internetowe i JavaScript, dzięki czemu doskonale nadaje się do złożonych stron internetowych.
Jakie są ograniczenia darmowej wersji IronPDF?
IronPDF oferuje w pełni funkcjonalną 30-dniową bezpłatną wersję próbną bez ograniczeń liczby stron, co daje wystarczająco dużo czasu na przetestowanie wszystkich funkcji przed podjęciem decyzji o zakupie.
W jaki sposób IronPDF zapewnia wysoką jakość renderowania HTML?
IronPDF zapewnia renderowanie z dokładnością do piksela, które odpowiada wynikowi przeglądarki Chrome, gwarantując wysoką wierność i dokładne odwzorowanie oryginalnej treści HTML.



