Porównanie IronPDF i Apitron PDF Kit
Praca z plikami PDF w C# moze byc wyzwaniem dla programistow. Przy tworzeniu zawartosci do tych plikow nalezy wziac pod uwage wiele czynnikow, a jeszcze wiecej przy konwertowaniu zawartosci z innych formatow do PDF. Automatyzacja jest teraz kluczowa w procesach tworzenia oprogramowania. Te wyzwania zostaly rozwiazane dzieki opracowaniu bibliotek, które pomagają czytać, pisać, tworzyc i modyfikowac dokumenty PDF, a takze edytowac ich atrybuty i konwertowac je z innych formatow.
Ten post na blogu porównuje dwie biblioteki PDF dla .NET i .NET Core:
- Biblioteka IronPDF
- Apitron PDF Kit
IronPDF i Apitron PDF Kit to biblioteki, które udostępniają funkcje manipulacji PDF dla .NET i .NET Core. Obydwie mogą być używane do konwersji i manipulacji polami dokumentów. Pozwalają również na tworzenie zakładek. Kolejnym krokiem jest decyzja, która biblioteka PDF dla .NET w C# jest najlepsza dla naszych projektów .NET. Ten artykuł porównawczy pomoże ci zdecydować pomiędzy tymi dwiema bibliotekami PDF.
Najpierw przyjrzyjmy się, co oferują obie biblioteki, a następnie przejdźmy do samego porównania.
Biblioteka Apitron PDF Kit i jej funkcje
Apitron PDF Kit jest komponentem .NET, który pozwala na manipulację lub konwersję plików PDF na różne sposoby. Możesz dodawać obrazy, rysunki i teksty, podpisywać dokumenty i wiele więcej. Możesz również edytować istniejącą zawartość. Komponent Apitron PDF Kit .NET można użyć do tworzenia aplikacji mobilnych, desktopowych, webowych, Windows i Cloud na wielu platformach.
Używając tego SDK PDF, będziesz w stanie:
- Wydobywać, modyfikować i dodawać grafikę (tekst, obrazy, rysunki)
- Dzielić lub łączyć dokumenty PDF
- Wypełniać lub tworzyć formularze PDF chronione hasłem, wsparcie dla FDF
- Tworzyć dokumenty PDF wielowarstwowe z opcjonalnymi grupami zawartości (OCG)
- Dodawać lub usuwać pola z dokumentów
- Używać tekstu od prawej do lewej lub dwukierunkowego do tworzenia zawartości strony
- Sprawdzać zasoby w dokumencie - zdefiniowane czcionki, osadzone pliki
- Podpisywać cyfrowo i sprawdzać istniejące podpisy w dokumentach PDF
Główne funkcje IronPDF
Programiści, zwłaszcza programiści C#, docenią bibliotekę IronPDF .NET. Z tym narzędziem możesz z łatwością stworzyć aplikację do przetwarzania PDF w .NET Core.
IronPDF używa silnika Chromium .NET do konwersji stron HTML (w kodzie lub w formie URL) do plików PDF. Nie ma potrzeby używania skomplikowanych API do umieszczenia obiektów nawigacyjnych lub projektowania PDF z HTML. IronPDF obsługuje standardowe dokumenty webowe, w tym HTML, ASPX, JS, CSS i obrazki.
IronPDF można stworzyć używając HTML5, CSS, JS i obrazów. PDF można łatwo edytować, pieczętować oraz dodawać do niego nagłówki i stopki. Umożliwia również łatwe czytanie tekstu PDF i wydobywanie grafiki.
Wyróżniające się funkcje IronPDF obejmują:
- Tworzenie dokumentów PDF przy użyciu HTML4/5, CSS i JavaScript
- Ładowanie URLi z niestandardowymi danymi logowania, agentami użytkownika, proxy, ciasteczkami, nagłówkami HTTP i zmiennymi formularzy (umożliwia logowanie za HTML login forms)
- Odczytanie i wypełnienie pól formularzy PDF
- Wydobycie tekstu i grafiki z PDF
- Aktualizowanie stron PDF z nową zawartością HTML
- Tworzenie nagłówków i stopek tekstowych lub opartych na HTML
- Scalanie i oddzielanie zawartości dokumentu PDF
- Konwersja formularzy webowych ASP.NET do nadających się do druku PDF
- Drukowanie plików PDF bez oprogramowania Adobe Acrobat
IronPDF jest dostępny na prawie wszystkich systemach operacyjnych i ramach kompatybilnych z C#, w tym:
- .NET Core 2.1, 3.0, 3.1, .NET 6 & 5
- .NET Standard 2.0 zgodność dla uniwersalnej kompatybilności
- Azure, AWS, Docker, Linux, Windows
Dalsza część artykułu wygląda następująco:
- Instalacja IronPDF
- Instalacja Apitron PDF Kit
- Utwórz dokument PDF
- Tworzenie nagłówka i stopki w PDF
- Podpisywanie plików PDF cyfrowo
- Ceny i licencje
1. Instalacja IronPDF
Istnieją cztery metody pobierania i instalacji biblioteki IronPDF. Są to:
- Korzystanie z menedżera pakietów NuGet
- Wiersz poleceń programisty
- Pobierz pakiet NuGet bezpośrednio
- Pobierz bibliotekę IronPDF .DLL
1.1. Korzystanie z menedżera pakietów NuGet
Aby zainstalować IronPDF, wystarczy kliknąć prawym przyciskiem myszy na swój projekt w Solution Explorer. Spowoduje to otwarcie menedżera pakietów NuGet.
Dostęp do menedżera pakietów NuGet za pomocą Eksploratora rozwiązań
Po wybraniu tej opcji należy wyszukać pakiet IronPDF i zainstalować go, jak pokazano na poniższym zrzucie ekranu.
Instalacja biblioteki IronPDF za pomocą menedżera pakietów NuGet
1.2. Korzystanie z wiersza poleceń programisty
Można również zainstalować IronPDF za pomocą wiersza poleceń programisty.
- Otwórz wiersz poleceń programisty — zazwyczaj znajduje się on w folderze Visual Studio
- Wpisz następujące polecenie:
Install-Package IronPdf
- Naciśnij Enter
- Spowoduje to pobranie i zainstalowanie pakietu
- Odśwież projekt i zacznij z niego korzystać
1.3. Pobierz pakiet NuGet bezpośrednio
IronPDF można również zainstalować, odwiedzając bezpośrednio stronę pakietu IronPDF NuGet i pobierając pakiet. Kroki są następujące:
- Przejdź do pakietu IronPDF NuGet
- Wybierz pakiet do pobrania
- Kliknij dwukrotnie pobrany pakiet
- Pakiet zostanie zainstalowany
- Odśwież projekt Visual Studio i zacznij z niego korzystać
IronPDF jest już pobrany i gotowy do użycia. Zanim to jednak zrobimy, powinniśmy zainstalować bibliotekę Apitron PDF.
2. Instalacja Apitron PDF Kit
W przypadku aplikacji .NET Core możemy zainstalować Apitron za pomocą menedżera pakietów NuGet lub pobrać i zainstalować Apitron bezpośrednio ze strony internetowej Apitron PDF Kit NuGet.
- Otwórz pakiety NuGet w Visual Studio, tak jak zrobiliśmy to w przypadku IronPDF.
- Wyszukaj Apitron.PDF.Kit.
- Kliknij "Zainstaluj" w bieżącym projekcie.
Wyszukiwanie w Apitron PDF Kit
Możesz również użyć konsoli NuGet Package Manager Console, aby zainstalować Apitron. Postępuj zgodnie z instrukcją "Użyj wiersza poleceń programisty" opisaną w IronPDF i wpisz następujące polecenie:
Install-Package Apitron.PDF.Kit
Naciśnij klawisz ENTER. Spowoduje to pobranie i zainstalowanie Apitron.PDF.Kit.
Dodaj następujące przestrzenie nazw:
using Apitron.PDF.Kit;
using Apitron.PDF.Kit.FixedLayout.Resources;
using Apitron.PDF.Kit.FixedLayout.Resources.Fonts;
using Apitron.PDF.Kit.FlowLayout.Content;
using Apitron.PDF.Kit.Styles;
using Apitron.PDF.Kit.Styles.Appearance;
using Font = Apitron.PDF.Kit.Styles.Text.Font;
using Apitron.PDF.Kit;
using Apitron.PDF.Kit.FixedLayout.Resources;
using Apitron.PDF.Kit.FixedLayout.Resources.Fonts;
using Apitron.PDF.Kit.FlowLayout.Content;
using Apitron.PDF.Kit.Styles;
using Apitron.PDF.Kit.Styles.Appearance;
using Font = Apitron.PDF.Kit.Styles.Text.Font;
Imports Apitron.PDF.Kit
Imports Apitron.PDF.Kit.FixedLayout.Resources
Imports Apitron.PDF.Kit.FixedLayout.Resources.Fonts
Imports Apitron.PDF.Kit.FlowLayout.Content
Imports Apitron.PDF.Kit.Styles
Imports Apitron.PDF.Kit.Styles.Appearance
Imports Font = Apitron.PDF.Kit.Styles.Text.Font
Przejdźmy teraz do porównania IronPDF i Apitron PDF.
3. Tworzenie dokumentu PDF
3.1. Korzystanie z IronPDF
IronPDF oferuje wiele metod tworzenia plików PDF. Przyjrzyjmy się dwóm najważniejszym z nich.
Istniejący adres URL do pliku PDF
IronPDF ułatwia konwersję dowolnego adresu URL do formatu PDF. Poniższy kod pomaga przekonwertować adres URL na plik PDF.
var Renderer = new IronPdf.ChromePdfRenderer();
// Render a PDF from an existing URL
using var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
// Save the PDF to a file
Pdf.SaveAs("url.pdf");
var Renderer = new IronPdf.ChromePdfRenderer();
// Render a PDF from an existing URL
using var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
// Save the PDF to a file
Pdf.SaveAs("url.pdf");
Dim Renderer = New IronPdf.ChromePdfRenderer()
' Render a PDF from an existing URL
Dim Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")
' Save the PDF to a file
Pdf.SaveAs("url.pdf")
Ciąg znaków z pola HTML do pliku PDF
Poniższy kod wyjaśnia, jak wyrenderować dokument PDF na podstawie ciągu znaków HTML. Możesz używać samego HTML lub połączyć go z CSS, obrazami i JavaScript.
var Renderer = new IronPdf.ChromePdfRenderer();
// Render a PDF from a simple HTML string
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
PDF.SaveAs("pixel-perfect.pdf");
// Load external HTML assets like images, CSS, and JavaScript
// Set the optional BasePath as the file location to load assets from
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='logo.png'><h1>Sample Text</h1>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
var Renderer = new IronPdf.ChromePdfRenderer();
// Render a PDF from a simple HTML string
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
PDF.SaveAs("pixel-perfect.pdf");
// Load external HTML assets like images, CSS, and JavaScript
// Set the optional BasePath as the file location to load assets from
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='logo.png'><h1>Sample Text</h1>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
Dim Renderer = New IronPdf.ChromePdfRenderer()
' Render a PDF from a simple HTML string
Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
PDF.SaveAs("pixel-perfect.pdf")
' Load external HTML assets like images, CSS, and JavaScript
' Set the optional BasePath as the file location to load assets from
Dim AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='logo.png'><h1>Sample Text</h1>", "C:\site\assets\")
AdvancedPDF.SaveAs("html-with-assets.pdf")
Oto wynik:
IronPDF Generuj pliki PDF z adresów URL oraz ciągów znaków HTML i CSS
3.2. Korzystanie z Apitron PDF Kit
Apitron PDF nie oferuje możliwości konwersji adresu URL lub kodu HTML do formatu PDF. Umożliwia konwersję plików PDF do formatu HTML. Jednakże konwertuje on również pliki XML do formatu PDF. Używany plik XML to:
<?xml version="1.0" encoding="utf-8"?>
<FlowDocument xmlns="Apitron.PDF.Kit.FlowLayout.v1">
<Resources>
<Image resourceId="logo" fileName="../../images/logo.png" />
</Resources>
<Styles>
<Style selector="flowdocument">
<Color value="Black" />
</Style>
<Style selector="grid">
<InnerBorder thickness="1" />
<InnerBorderColor value="Black" />
</Style>
</Styles>
<Elements>
<Image>
<Properties>
<Class value="logo" />
<ResourceId value="logo" />
</Properties>
</Image>
<TextBlock>
<Properties>
<Class value="header" />
<Text value="Sample Interview Questions for Candidates" />
</Properties>
</TextBlock>
<Br />
<TextBlock>
<Properties>
<Class value="headerNote" />
<Text value="To help facilitate the interview process, the Human Resources Department has compiled a list of questions that might be used during the phone and/or on-campus interviews. Some of the questions deal with the same content, but are phrased differently while other questions may not pertain to a specific discipline; however all of the questions are unbiased and appropriate to ask. We hope you'll find this helpful." />
</Properties>
</TextBlock>
</Elements>
<Properties>
<Margin value="30,20,30,20" />
</Properties>
</FlowDocument>
<?xml version="1.0" encoding="utf-8"?>
<FlowDocument xmlns="Apitron.PDF.Kit.FlowLayout.v1">
<Resources>
<Image resourceId="logo" fileName="../../images/logo.png" />
</Resources>
<Styles>
<Style selector="flowdocument">
<Color value="Black" />
</Style>
<Style selector="grid">
<InnerBorder thickness="1" />
<InnerBorderColor value="Black" />
</Style>
</Styles>
<Elements>
<Image>
<Properties>
<Class value="logo" />
<ResourceId value="logo" />
</Properties>
</Image>
<TextBlock>
<Properties>
<Class value="header" />
<Text value="Sample Interview Questions for Candidates" />
</Properties>
</TextBlock>
<Br />
<TextBlock>
<Properties>
<Class value="headerNote" />
<Text value="To help facilitate the interview process, the Human Resources Department has compiled a list of questions that might be used during the phone and/or on-campus interviews. Some of the questions deal with the same content, but are phrased differently while other questions may not pertain to a specific discipline; however all of the questions are unbiased and appropriate to ask. We hope you'll find this helpful." />
</Properties>
</TextBlock>
</Elements>
<Properties>
<Margin value="30,20,30,20" />
</Properties>
</FlowDocument>
Kod służący do konwersji tego szablonu XML do formatu PDF wygląda następująco:
// Use Apitron's FlowDocument to convert XML to PDF
using (Stream stream = File.OpenRead("C:\PLACE YOUR EXACT PATH HERE\template.xml"),
outputStream = File.Create("fromTemplate.pdf"))
{
ResourceManager resourceManager = new ResourceManager();
FlowDocument doc = FlowDocument.LoadFromXml(stream, resourceManager);
doc.Write(outputStream, resourceManager);
}
// Use Apitron's FlowDocument to convert XML to PDF
using (Stream stream = File.OpenRead("C:\PLACE YOUR EXACT PATH HERE\template.xml"),
outputStream = File.Create("fromTemplate.pdf"))
{
ResourceManager resourceManager = new ResourceManager();
FlowDocument doc = FlowDocument.LoadFromXml(stream, resourceManager);
doc.Write(outputStream, resourceManager);
}
' Use Apitron's FlowDocument to convert XML to PDF
Using stream As Stream = File.OpenRead("C:\PLACE YOUR EXACT PATH HERE\template.xml"),
outputStream As Stream = File.Create("fromTemplate.pdf")
Dim resourceManager As New ResourceManager()
Dim doc As FlowDocument = FlowDocument.LoadFromXml(stream, resourceManager)
doc.Write(outputStream, resourceManager)
End Using
Oto wynik:
Dokument PDF firmy Apitron
Jeśli porównamy wyniki działania IronPDF i Apitron, wyraźnie widać, że IronPDF tworzy imponujące dokumenty przy użyciu renderowania HTML, nawet bez skalowania rozmiaru obrazu. Z drugiej strony, Apitron daje podobny wynik jak IronPDF, ale tylko wtedy, gdy plik XML zawiera zarejestrowane style.
4. Dodawanie nagłówków i stopek do dokumentów PDF
4.1. Korzystanie z IronPDF
Dodawanie nagłówków i stopek jest proste dzięki IronPDF. IronPDF pozwala dodawać numery stron i podziały stron, dołączać stronę tytułową, marginesy itp.
Poniżej znajduje się kod służący do dodawania nagłówków i stopek:
var Renderer = new ChromePdfRenderer();
// Add a header
Renderer.RenderingOptions.FirstPageNumber = 1; // Use 2 if a cover page will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
Renderer.RenderingOptions.TextHeader.CenterText = "This is the header text";
Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica;
Renderer.RenderingOptions.TextHeader.FontSize = 12;
Renderer.RenderingOptions.MarginTop = 25; // Create 25mm space for header
// Add a footer too
Renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
Renderer.RenderingOptions.TextFooter.Font = IronPdf.Font.FontTypes.Arial;
Renderer.RenderingOptions.TextFooter.FontSize = 12;
Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";
Renderer.RenderingOptions.MarginTop = 25; // Create 25mm space for footer
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='logo.png'><h1>This is header and footer generated pdf file</h1>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
var Renderer = new ChromePdfRenderer();
// Add a header
Renderer.RenderingOptions.FirstPageNumber = 1; // Use 2 if a cover page will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
Renderer.RenderingOptions.TextHeader.CenterText = "This is the header text";
Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica;
Renderer.RenderingOptions.TextHeader.FontSize = 12;
Renderer.RenderingOptions.MarginTop = 25; // Create 25mm space for header
// Add a footer too
Renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
Renderer.RenderingOptions.TextFooter.Font = IronPdf.Font.FontTypes.Arial;
Renderer.RenderingOptions.TextFooter.FontSize = 12;
Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";
Renderer.RenderingOptions.MarginTop = 25; // Create 25mm space for footer
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='logo.png'><h1>This is header and footer generated pdf file</h1>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
Dim Renderer = New ChromePdfRenderer()
' Add a header
Renderer.RenderingOptions.FirstPageNumber = 1 ' Use 2 if a cover page will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = True
Renderer.RenderingOptions.TextHeader.CenterText = "This is the header text"
Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica
Renderer.RenderingOptions.TextHeader.FontSize = 12
Renderer.RenderingOptions.MarginTop = 25 ' Create 25mm space for header
' Add a footer too
Renderer.RenderingOptions.TextFooter.DrawDividerLine = True
Renderer.RenderingOptions.TextFooter.Font = IronPdf.Font.FontTypes.Arial
Renderer.RenderingOptions.TextFooter.FontSize = 12
Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"
Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"
Renderer.RenderingOptions.MarginTop = 25 ' Create 25mm space for footer
Dim AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='logo.png'><h1>This is header and footer generated pdf file</h1>", "C:\site\assets\")
AdvancedPDF.SaveAs("html-with-assets.pdf")
Oto wynik:
Nagłówek i stopka IronPDF
4.2. Korzystanie z Apitron PDF Kit
Apitron PDF Kit tworzy pliki PDF poprzez konwersję treści w formacie struktury XML do formatu PDF. W Apitron PDF Kit, nagłówki i stopki można dodawać używając właściwości PageHeader i PageFooter. Kod do wykonania tego zadania wygląda następująco:
// Register document resources first
ResourceManager resourceManager = new ResourceManager();
resourceManager.RegisterResource(new Apitron.PDF.Kit.FixedLayout.Resources.XObjects.Image("logo", "../../data/logo.png"));
// Create the document
FlowDocument doc = new FlowDocument() { Margin = new Thickness(10) };
// Register styles
doc.StyleManager.RegisterStyle(".pageHeader", new Style() { Font = new Font(StandardFonts.TimesBold, 20) });
doc.StyleManager.RegisterStyle(".pageFooter", new Style() { Align = Align.Right });
doc.StyleManager.RegisterStyle("hr", new Style() { Height = 2, Margin = new Thickness(0, 5, 0, 5) });
doc.StyleManager.RegisterStyle(".content", new Style() { Align = Align.Left, Display = Display.InlineBlock });
// Fill the header section
doc.PageHeader.Class = "pageHeader";
doc.PageHeader.Add(new Image("logo") { Width = 100, Height = 50 });
doc.PageHeader.Add(new TextBlock("This document is intended for internal use only") { TextIndent = 20 });
doc.PageHeader.Add(new Hr());
// Fill the footer section
doc.PageFooter.Class = "pageFooter";
doc.PageFooter.Add(new Hr());
doc.PageFooter.Add(new TextBlock((ctx) => string.Format("Page {0} from ", ctx.CurrentPage + 1)));
doc.PageFooter.Add(new PageCount(3) { Display = Display.Inline });
// Add pages
for (int i = 0; i < 2; ++i)
{
doc.Add(new TextBlock("This is header and footer generation pdf file.") { Class = "content" });
doc.Add(new PageBreak());
}
// Generate PDF
using (Stream stream = File.Create("out.pdf"))
{
doc.Write(stream, resourceManager);
}
Process.Start("out.pdf");
// Register document resources first
ResourceManager resourceManager = new ResourceManager();
resourceManager.RegisterResource(new Apitron.PDF.Kit.FixedLayout.Resources.XObjects.Image("logo", "../../data/logo.png"));
// Create the document
FlowDocument doc = new FlowDocument() { Margin = new Thickness(10) };
// Register styles
doc.StyleManager.RegisterStyle(".pageHeader", new Style() { Font = new Font(StandardFonts.TimesBold, 20) });
doc.StyleManager.RegisterStyle(".pageFooter", new Style() { Align = Align.Right });
doc.StyleManager.RegisterStyle("hr", new Style() { Height = 2, Margin = new Thickness(0, 5, 0, 5) });
doc.StyleManager.RegisterStyle(".content", new Style() { Align = Align.Left, Display = Display.InlineBlock });
// Fill the header section
doc.PageHeader.Class = "pageHeader";
doc.PageHeader.Add(new Image("logo") { Width = 100, Height = 50 });
doc.PageHeader.Add(new TextBlock("This document is intended for internal use only") { TextIndent = 20 });
doc.PageHeader.Add(new Hr());
// Fill the footer section
doc.PageFooter.Class = "pageFooter";
doc.PageFooter.Add(new Hr());
doc.PageFooter.Add(new TextBlock((ctx) => string.Format("Page {0} from ", ctx.CurrentPage + 1)));
doc.PageFooter.Add(new PageCount(3) { Display = Display.Inline });
// Add pages
for (int i = 0; i < 2; ++i)
{
doc.Add(new TextBlock("This is header and footer generation pdf file.") { Class = "content" });
doc.Add(new PageBreak());
}
// Generate PDF
using (Stream stream = File.Create("out.pdf"))
{
doc.Write(stream, resourceManager);
}
Process.Start("out.pdf");
' Register document resources first
Dim resourceManager As New ResourceManager()
resourceManager.RegisterResource(New Apitron.PDF.Kit.FixedLayout.Resources.XObjects.Image("logo", "../../data/logo.png"))
' Create the document
Dim doc As New FlowDocument() With {.Margin = New Thickness(10)}
' Register styles
doc.StyleManager.RegisterStyle(".pageHeader", New Style() With {.Font = New Font(StandardFonts.TimesBold, 20)})
doc.StyleManager.RegisterStyle(".pageFooter", New Style() With {.Align = Align.Right})
doc.StyleManager.RegisterStyle("hr", New Style() With {
.Height = 2,
.Margin = New Thickness(0, 5, 0, 5)
})
doc.StyleManager.RegisterStyle(".content", New Style() With {
.Align = Align.Left,
.Display = Display.InlineBlock
})
' Fill the header section
doc.PageHeader.Class = "pageHeader"
doc.PageHeader.Add(New Image("logo") With {
.Width = 100,
.Height = 50
})
doc.PageHeader.Add(New TextBlock("This document is intended for internal use only") With {.TextIndent = 20})
doc.PageHeader.Add(New Hr())
' Fill the footer section
doc.PageFooter.Class = "pageFooter"
doc.PageFooter.Add(New Hr())
doc.PageFooter.Add(New TextBlock(Function(ctx) String.Format("Page {0} from ", ctx.CurrentPage + 1)))
doc.PageFooter.Add(New PageCount(3) With {.Display = Display.Inline})
' Add pages
For i As Integer = 0 To 1
doc.Add(New TextBlock("This is header and footer generation pdf file.") With {.Class = "content"})
doc.Add(New PageBreak())
Next i
' Generate PDF
Using stream As Stream = File.Create("out.pdf")
doc.Write(stream, resourceManager)
End Using
Process.Start("out.pdf")
Oto wynik:
Nagłówek i stopka Apitron
5. Podpisywanie plików PDF cyfrowo
5.1. Korzystanie z IronPDF
Jedną z najważniejszych funkcji przetwarzania plików PDF jest możliwość cyfrowego podpisywania dokumentów PDF. IronPDF zapewnia wszystkie narzędzia niezbędne do tego celu.
using IronPdf;
// Cryptographically sign an existing PDF in 1 line of code!
new IronPdf.Signing.PdfSignature("Iron.p12", "123456").SignPdfFile("any.pdf");
/***** Advanced example for more control *****/
// 1. Create a PDF
var Renderer = new IronPdf.ChromePdfRenderer();
var doc = Renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>");
// 2. Create a Signature.
// You may create a .pfx or .p12 PDF signing certificate using Adobe Acrobat Reader.
var signature = new IronPdf.Signing.PdfSignature("Iron.pfx", "123456");
// 3. Handwritten signature graphic
signature.LoadSignatureImageFromFile("handwriting.png");
// 4. Sign the PDF with the PdfSignature. Multiple signing certificates may be used
doc.SignPdfWithDigitalSignature(signature);
// 5. The PDF is not signed until saved to file, stream or byte array.
doc.SaveAs("signed.pdf");
using IronPdf;
// Cryptographically sign an existing PDF in 1 line of code!
new IronPdf.Signing.PdfSignature("Iron.p12", "123456").SignPdfFile("any.pdf");
/***** Advanced example for more control *****/
// 1. Create a PDF
var Renderer = new IronPdf.ChromePdfRenderer();
var doc = Renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>");
// 2. Create a Signature.
// You may create a .pfx or .p12 PDF signing certificate using Adobe Acrobat Reader.
var signature = new IronPdf.Signing.PdfSignature("Iron.pfx", "123456");
// 3. Handwritten signature graphic
signature.LoadSignatureImageFromFile("handwriting.png");
// 4. Sign the PDF with the PdfSignature. Multiple signing certificates may be used
doc.SignPdfWithDigitalSignature(signature);
// 5. The PDF is not signed until saved to file, stream or byte array.
doc.SaveAs("signed.pdf");
Imports IronPdf
' Cryptographically sign an existing PDF in 1 line of code!
Call (New IronPdf.Signing.PdfSignature("Iron.p12", "123456")).SignPdfFile("any.pdf")
'''*** Advanced example for more control ****
' 1. Create a PDF
Dim Renderer = New IronPdf.ChromePdfRenderer()
Dim doc = Renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>")
' 2. Create a Signature.
' You may create a .pfx or .p12 PDF signing certificate using Adobe Acrobat Reader.
Dim signature = New IronPdf.Signing.PdfSignature("Iron.pfx", "123456")
' 3. Handwritten signature graphic
signature.LoadSignatureImageFromFile("handwriting.png")
' 4. Sign the PDF with the PdfSignature. Multiple signing certificates may be used
doc.SignPdfWithDigitalSignature(signature)
' 5. The PDF is not signed until saved to file, stream or byte array.
doc.SaveAs("signed.pdf")
5.2 Korzystanie z Apitron PDF Kit
Umieszczanie podpisu na pliku PDF za pomocą Apitron PDF Kit jest procesem zarówno czasochłonnym, jak i technicznym.
static void Main(string[] args)
{
string fileName = "signedTwice.pdf";
using (Stream stream = File.Create(fileName))
{
FlowDocument doc = new FlowDocument() { Margin = new Thickness(10) };
doc.Add(new TextBlock("Signed using Apitron PDF Kit for .NET"));
doc.Write(stream, new ResourceManager());
}
// Save
Sign(fileName, "../../data/certs/JohnDoe.pfx", "password", "../../data/images/signatureImage.png", new Boundary(10, 750, 110, 800));
}
// Implementation of Sign Method
private static void Sign(string pathToDocument, string pathToCertificate, string password, string pathToSignatureImage, Boundary signatureViewLocation)
{
// Open existing document and sign once
using (Stream inputStream = new FileStream(pathToDocument, FileMode.Open, FileAccess.ReadWrite))
{
using (FixedDocument doc = new FixedDocument(inputStream))
{
string imageResourceId = Guid.NewGuid().ToString("N");
string signatureFieldId = Guid.NewGuid().ToString("N");
// Register signature image resource
doc.ResourceManager.RegisterResource(new Image(imageResourceId, pathToSignatureImage));
// Create first signature field and initialize it using a stored certificate
SignatureField signatureField = new SignatureField(signatureFieldId);
using (Stream signatureDataStream = File.OpenRead(pathToCertificate))
{
signatureField.Signature = Signature.Create(new Pkcs12Store(signatureDataStream, password));
}
// Add signature fields to the document
doc.AcroForm.Fields.Add(signatureField);
// Create first signature view using the image resource
SignatureFieldView signatureView = new SignatureFieldView(signatureField, signatureViewLocation);
signatureView.ViewSettings.Graphic = Graphic.Image;
signatureView.ViewSettings.GraphicResourceID = imageResourceId;
signatureView.ViewSettings.Description = Description.None;
// Add views to page annotations collection
doc.Pages[0].Annotations.Add(signatureView);
// Save as incremental update
doc.Save();
}
}
}
static void Main(string[] args)
{
string fileName = "signedTwice.pdf";
using (Stream stream = File.Create(fileName))
{
FlowDocument doc = new FlowDocument() { Margin = new Thickness(10) };
doc.Add(new TextBlock("Signed using Apitron PDF Kit for .NET"));
doc.Write(stream, new ResourceManager());
}
// Save
Sign(fileName, "../../data/certs/JohnDoe.pfx", "password", "../../data/images/signatureImage.png", new Boundary(10, 750, 110, 800));
}
// Implementation of Sign Method
private static void Sign(string pathToDocument, string pathToCertificate, string password, string pathToSignatureImage, Boundary signatureViewLocation)
{
// Open existing document and sign once
using (Stream inputStream = new FileStream(pathToDocument, FileMode.Open, FileAccess.ReadWrite))
{
using (FixedDocument doc = new FixedDocument(inputStream))
{
string imageResourceId = Guid.NewGuid().ToString("N");
string signatureFieldId = Guid.NewGuid().ToString("N");
// Register signature image resource
doc.ResourceManager.RegisterResource(new Image(imageResourceId, pathToSignatureImage));
// Create first signature field and initialize it using a stored certificate
SignatureField signatureField = new SignatureField(signatureFieldId);
using (Stream signatureDataStream = File.OpenRead(pathToCertificate))
{
signatureField.Signature = Signature.Create(new Pkcs12Store(signatureDataStream, password));
}
// Add signature fields to the document
doc.AcroForm.Fields.Add(signatureField);
// Create first signature view using the image resource
SignatureFieldView signatureView = new SignatureFieldView(signatureField, signatureViewLocation);
signatureView.ViewSettings.Graphic = Graphic.Image;
signatureView.ViewSettings.GraphicResourceID = imageResourceId;
signatureView.ViewSettings.Description = Description.None;
// Add views to page annotations collection
doc.Pages[0].Annotations.Add(signatureView);
// Save as incremental update
doc.Save();
}
}
}
Imports System
Imports System.IO
Imports Apitron.PDF.Rasterizer
Imports Apitron.PDF.Kit.FixedLayout
Imports Apitron.PDF.Kit
Imports Apitron.PDF.Kit.Styles
Imports Apitron.PDF.Kit.Signatures
Imports Apitron.PDF.Kit.Interactive.Annotations
Module Module1
Sub Main(args As String())
Dim fileName As String = "signedTwice.pdf"
Using stream As Stream = File.Create(fileName)
Dim doc As New FlowDocument() With {.Margin = New Thickness(10)}
doc.Add(New TextBlock("Signed using Apitron PDF Kit for .NET"))
doc.Write(stream, New ResourceManager())
End Using
' Save
Sign(fileName, "../../data/certs/JohnDoe.pfx", "password", "../../data/images/signatureImage.png", New Boundary(10, 750, 110, 800))
End Sub
' Implementation of Sign Method
Private Sub Sign(pathToDocument As String, pathToCertificate As String, password As String, pathToSignatureImage As String, signatureViewLocation As Boundary)
' Open existing document and sign once
Using inputStream As Stream = New FileStream(pathToDocument, FileMode.Open, FileAccess.ReadWrite)
Using doc As New FixedDocument(inputStream)
Dim imageResourceId As String = Guid.NewGuid().ToString("N")
Dim signatureFieldId As String = Guid.NewGuid().ToString("N")
' Register signature image resource
doc.ResourceManager.RegisterResource(New Image(imageResourceId, pathToSignatureImage))
' Create first signature field and initialize it using a stored certificate
Dim signatureField As New SignatureField(signatureFieldId)
Using signatureDataStream As Stream = File.OpenRead(pathToCertificate)
signatureField.Signature = Signature.Create(New Pkcs12Store(signatureDataStream, password))
End Using
' Add signature fields to the document
doc.AcroForm.Fields.Add(signatureField)
' Create first signature view using the image resource
Dim signatureView As New SignatureFieldView(signatureField, signatureViewLocation)
signatureView.ViewSettings.Graphic = Graphic.Image
signatureView.ViewSettings.GraphicResourceID = imageResourceId
signatureView.ViewSettings.Description = Description.None
' Add views to page annotations collection
doc.Pages(0).Annotations.Add(signatureView)
' Save as incremental update
doc.Save()
End Using
End Using
End Sub
End Module
Wynik jest w zasadzie taki sam dla wszystkich bibliotek. Wyraźnie widać, że IronPDF jest łatwiejszy i wygodniejszy w obsłudze treści PDF. Wynikowy plik PDF jest podpisany certyfikatem i podpisem wydrukowanym na nim.
Wykorzystanie Bootstrap 5 z IronPDF do tworzenia galerii portfolio
Silnik renderujący IronPDF Chrome V8 w pełni obsługuje nowoczesne komponenty Bootstrap 5, umożliwiając generowanie atrakcyjnych wizualnie dokumentów PDF z profesjonalnymi galeriami portfolio. Ten przykład pokazuje układy siatki, efekty najechania kursorem, nakładki gradientowe i plakietki kategorii — funkcje, których wdrożenie byłoby trudne przy użyciu tradycyjnych bibliotek PDF, takich jak Apitron PDF SDK.
using IronPdf;
var renderer = new ChromePdfRenderer();
string portfolioGallery = @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
<style>
.gallery-item {
position: relative;
overflow: hidden;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.gallery-item img {
width: 100%;
height: 250px;
object-fit: cover;
transition: transform 0.3s;
}
.gallery-item:hover img {
transform: scale(1.1);
}
.gallery-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
padding: 20px;
color: white;
}
.category-badge {
position: absolute;
top: 10px;
right: 10px;
}
@media print {
.gallery-item { page-break-inside: avoid; }
}
</style>
</head>
<body>
<div class='container py-5'>
<div class='text-center mb-5'>
<h1 class='display-4'>Design Portfolio</h1>
<p class='lead text-muted'>Showcase of PDF Document Designs</p>
</div>
<div class='row mb-4'>
<div class='col-12'>
<div class='btn-group' role='group'>
<button class='btn btn-primary'>All Projects</button>
<button class='btn btn-outline-primary'>Invoices</button>
<button class='btn btn-outline-primary'>Reports</button>
<button class='btn btn-outline-primary'>Forms</button>
<button class='btn btn-outline-primary'>Certificates</button>
</div>
</div>
</div>
<div class='row g-4'>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-primary category-badge'>Invoice</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📄</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Professional Invoice Template</h5>
<small>Corporate billing with itemized details</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-success category-badge'>Report</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📊</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Analytics Dashboard Report</h5>
<small>Data visualization and metrics</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-warning category-badge'>Certificate</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>🏆</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Award Certificate</h5>
<small>Professional achievement recognition</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-info category-badge'>Form</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #fa709a 0%, #fee140 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📝</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Application Form</h5>
<small>Multi-page data collection</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-danger category-badge'>Invoice</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #30cfd0 0%, #330867 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>💰</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Payment Receipt</h5>
<small>Transaction confirmation document</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-secondary category-badge'>Report</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📈</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Financial Statement</h5>
<small>Quarterly performance overview</small>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<p class='text-muted'>All templates rendered with IronPDF's Chromium engine</p>
<div class='d-flex justify-content-center gap-2'>
<span class='badge bg-primary'>Bootstrap 5</span>
<span class='badge bg-success'>Responsive</span>
<span class='badge bg-info'>Print-Ready</span>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(portfolioGallery);
pdf.SaveAs("portfolio-gallery.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
string portfolioGallery = @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
<style>
.gallery-item {
position: relative;
overflow: hidden;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.gallery-item img {
width: 100%;
height: 250px;
object-fit: cover;
transition: transform 0.3s;
}
.gallery-item:hover img {
transform: scale(1.1);
}
.gallery-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
padding: 20px;
color: white;
}
.category-badge {
position: absolute;
top: 10px;
right: 10px;
}
@media print {
.gallery-item { page-break-inside: avoid; }
}
</style>
</head>
<body>
<div class='container py-5'>
<div class='text-center mb-5'>
<h1 class='display-4'>Design Portfolio</h1>
<p class='lead text-muted'>Showcase of PDF Document Designs</p>
</div>
<div class='row mb-4'>
<div class='col-12'>
<div class='btn-group' role='group'>
<button class='btn btn-primary'>All Projects</button>
<button class='btn btn-outline-primary'>Invoices</button>
<button class='btn btn-outline-primary'>Reports</button>
<button class='btn btn-outline-primary'>Forms</button>
<button class='btn btn-outline-primary'>Certificates</button>
</div>
</div>
</div>
<div class='row g-4'>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-primary category-badge'>Invoice</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📄</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Professional Invoice Template</h5>
<small>Corporate billing with itemized details</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-success category-badge'>Report</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📊</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Analytics Dashboard Report</h5>
<small>Data visualization and metrics</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-warning category-badge'>Certificate</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>🏆</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Award Certificate</h5>
<small>Professional achievement recognition</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-info category-badge'>Form</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #fa709a 0%, #fee140 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📝</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Application Form</h5>
<small>Multi-page data collection</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-danger category-badge'>Invoice</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #30cfd0 0%, #330867 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>💰</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Payment Receipt</h5>
<small>Transaction confirmation document</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-secondary category-badge'>Report</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📈</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Financial Statement</h5>
<small>Quarterly performance overview</small>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<p class='text-muted'>All templates rendered with IronPDF's Chromium engine</p>
<div class='d-flex justify-content-center gap-2'>
<span class='badge bg-primary'>Bootstrap 5</span>
<span class='badge bg-success'>Responsive</span>
<span class='badge bg-info'>Print-Ready</span>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(portfolioGallery);
pdf.SaveAs("portfolio-gallery.pdf");
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim portfolioGallery As String = "
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
<style>
.gallery-item {
position: relative;
overflow: hidden;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.gallery-item img {
width: 100%;
height: 250px;
object-fit: cover;
transition: transform 0.3s;
}
.gallery-item:hover img {
transform: scale(1.1);
}
.gallery-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
padding: 20px;
color: white;
}
.category-badge {
position: absolute;
top: 10px;
right: 10px;
}
@media print {
.gallery-item { page-break-inside: avoid; }
}
</style>
</head>
<body>
<div class='container py-5'>
<div class='text-center mb-5'>
<h1 class='display-4'>Design Portfolio</h1>
<p class='lead text-muted'>Showcase of PDF Document Designs</p>
</div>
<div class='row mb-4'>
<div class='col-12'>
<div class='btn-group' role='group'>
<button class='btn btn-primary'>All Projects</button>
<button class='btn btn-outline-primary'>Invoices</button>
<button class='btn btn-outline-primary'>Reports</button>
<button class='btn btn-outline-primary'>Forms</button>
<button class='btn btn-outline-primary'>Certificates</button>
</div>
</div>
</div>
<div class='row g-4'>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-primary category-badge'>Invoice</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📄</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Professional Invoice Template</h5>
<small>Corporate billing with itemized details</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-success category-badge'>Report</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📊</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Analytics Dashboard Report</h5>
<small>Data visualization and metrics</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-warning category-badge'>Certificate</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>🏆</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Award Certificate</h5>
<small>Professional achievement recognition</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-info category-badge'>Form</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #fa709a 0%, #fee140 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📝</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Application Form</h5>
<small>Multi-page data collection</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-danger category-badge'>Invoice</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #30cfd0 0%, #330867 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>💰</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Payment Receipt</h5>
<small>Transaction confirmation document</small>
</div>
</div>
</div>
<div class='col-md-4'>
<div class='gallery-item'>
<span class='badge bg-secondary category-badge'>Report</span>
<svg width='100%' height='250' style='background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)'>
<text x='50%' y='50%' text-anchor='middle' fill='white' font-size='48' opacity='0.3'>📈</text>
</svg>
<div class='gallery-overlay'>
<h5 class='mb-1'>Financial Statement</h5>
<small>Quarterly performance overview</small>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<p class='text-muted'>All templates rendered with IronPDF's Chromium engine</p>
<div class='d-flex justify-content-center gap-2'>
<span class='badge bg-primary'>Bootstrap 5</span>
<span class='badge bg-success'>Responsive</span>
<span class='badge bg-info'>Print-Ready</span>
</div>
</div>
</div>
</body>
</html>"
Dim pdf = renderer.RenderHtmlAsPdf(portfolioGallery)
pdf.SaveAs("portfolio-gallery.pdf")
Ten kod generuje profesjonalne portfolio w formacie PDF z responsywnym układem siatki, wizualnymi znacznikami kategorii, nakładkami z gradientem i efektami po najechaniu kursorem. Silnik renderujący Chrome zachowuje wszystkie style Bootstrap, układy CSS Grid oraz niestandardowe właściwości CSS — możliwości, które tradycyjne biblioteki PDF mają trudności z odtworzeniem.
Kluczowe zalety w porównaniu z Apitron PDF SDK:
- Natywna obsługa Bootstrap 5 bez konwersji
- Układy CSS Grid i Flexbox renderują się idealnie
- Tła z gradientem i nowoczesne efekty CSS
- Prostszy kod i lepsza jakość wyników
Pełny przewodnik dotyczący generowania plików PDF w Bootstrap można znaleźć w przewodniku HTML to PDF Bootstrap Guide.
6. Ceny i licencje
Ceny i licencje IronPDF
IronPDF to biblioteka C#, z której można korzystać bezpłatnie do celów programistycznych, a licencję na użytek komercyjny można uzyskać w dowolnym momencie. Dostępne są licencje projektowe dla pojedynczych programistów, agencji i organizacji międzynarodowych, a także na dystrybucję SaaS i OEM. Wszystkie licencje obejmują 30-dniową gwarancję zwrotu pieniędzy, roczną pomoc techniczną i aktualizacje, ważność w środowisku programistycznym, testowym i produkcyjnym oraz Licencję wieczystą (jednorazowy zakup).
Pakiet Lite jest dostępny dla $799 bez stałych kosztów. Więcej szczegółów i pomoc w wyborze najlepszej licencji można znaleźć na stronie licencji produktów IronPDF.
Licencjonowanie IronPDF
Ceny i licencje Apitron PDF Kit
Obecnie stosowane są dwa systemy licencyjne — Modern i Legacy. Jeśli posiadasz już licencję, dotychczasowy system licencyjny pozostaje aktywny do momentu wygaśnięcia Twojej licencji. Następnie należy skontaktować się z obsługą klienta w sprawie przejścia. Nowy system licencyjny ma zastosowanie wyłącznie w przypadku nowych klientów.
W ramach nowoczesnego systemu istnieją trzy poziomy licencji:
- Ocena – trzymiesięczny okres próbny na korzystanie z w pełni funkcjonalnego produktu. Wystarczy pobrać pakiet z NuGet i rozpocząć programowanie.
- Społeczność — korzystaj z w pełni funkcjonalnych produktów bez żadnych opłat w swoich projektach niekomercyjnych. Wymagana jest akceptacja.
- Komercyjne – wszelkie zastosowania nieopisane powyżej. Ceny zależą od sposobu użytkowania.
Wnioski
Biblioteka IronPDF tworzy pliki PDF o idealnej rozdzielczości z dokumentów w formatach takich jak HTML, JS, CSS, JPG, PNG, GIF i SVG. Silnik Chromium pomaga renderować pliki HTML lub adresy URL, aby uzyskać doskonałe pliki PDF jako wynik.
Apitron pozwala tworzyć pliki PDF przy użyciu API stałego układu, zaimplementowanego tak, aby było w 100% zgodne ze specyfikacją PDF. Jako metoda generowania treści oparta na stylach, podobna do HTML i CSS, ten interfejs API o stałym układzie umożliwia tworzenie w ciągu kilku minut atrakcyjnych raportów, rachunków, katalogów i innych dokumentów. Obsługuje również tworzenie szablonów XML.
Ceny licencji na Apitron PDF nie są dostępne na stronie internetowej. Należy skontaktować się z działem pomocy technicznej i uzyskać wycenę na podstawie własnego wykorzystania. Z drugiej strony, IronPDF ma bardzo przejrzysty pakiet licencyjny wyświetlany na swojej stronie internetowej. To wyróżnia IronPDF na tle konkurencji i pozwala użytkownikom dokonywać mądrych wyborów zgodnie z ich potrzebami.
Dzięki IronPDF praca z plikami PDF jest łatwiejsza niż w przypadku Apitron PDF. IronPDF pozwala użytkownikom pisać mniej kodu przy realizacji trudnych zadań związanych z plikami PDF. IronPDF oferuje wiele metod tworzenia plików PDF z różnych typów plików, podczas gdy Apitron może konwertować tylko dokumenty XML na dokumenty PDF. Idealny wynik uzyskuje się bez dodawania żadnych opcji technicznych w IronPDF w porównaniu z Apitron.
Wszyscy klienci Iron Software mają możliwość zakupu wszystkich pięciu produktów firmy w cenie dwóch z nich. Wypróbuj bezpłatną, 30-dniową wersję próbną IronPDF, aby przetestować wszystkie jego funkcje. Pełny zestaw produktów Iron Software można nabyć na stronie IronSoftware.com.
Często Zadawane Pytania
Jak 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.
Jakie funkcje oferuje IronPDF do tworzenia plików PDF?
IronPDF obsługuje tworzenie plików PDF z HTML, CSS i JavaScript, ładowanie adresów URL, wyodrębnianie tekstu i grafiki, scalanie plików PDF i wiele więcej. Jest kompatybilny z .NET Core, Azure, AWS, Docker, Linux i Windows.
Jak podpisać cyfrowo plik PDF w języku C#?
Dzięki IronPDF możesz podpisywać cyfrowo pliki PDF za pomocą certyfikatu podpisu PDF, który można zintegrować za pomocą kilku linii kodu.
Jakie są opcje instalacji IronPDF?
IronPDF można zainstalować za pomocą menedżera pakietów NuGet, wiersza poleceń programisty lub poprzez bezpośrednie pobranie pakietu NuGet lub biblioteki IronPDF .DLL.
Czy dostępna jest bezpłatna wersja IronPDF?
Tak, IronPDF oferuje bezpłatną wersję deweloperską oraz licencje komercyjne. Szczegółowe informacje dotyczące cen, w tym 30-dniowa gwarancja zwrotu, są dostępne na stronie internetowej firmy.
W jaki sposób Apitron PDF Kit obsługuje konwersję HTML do PDF?
Apitron PDF Kit nie obsługuje bezpośredniej konwersji HTML do PDF, ale może konwertować pliki XML do formatu PDF.
Jakie są najważniejsze cechy Apitron PDF Kit?
Apitron PDF Kit umożliwia kompleksową obróbkę plików PDF, w tym dodawanie obrazów, rysunków, tekstów, podpisywanie dokumentów oraz łączenie lub dzielenie plików PDF. Brakuje mu jednak funkcji bezpośredniej konwersji HTML do PDF.
Jak dodać nagłówki i stopki do pliku PDF w języku C#?
IronPDF pozwala w łatwy sposób dodawać nagłówki i stopki do plików PDF za pomocą metod takich jak AddTextHeader i AddTextFooter.
Jakie opcje licencyjne są dostępne dla Apitron PDF Kit?
Apitron PDF Kit oferuje trzymiesięczny okres próbny oraz licencję społecznościową dla projektów niekomercyjnych. W przypadku zastosowań komercyjnych należy skontaktować się bezpośrednio z dostawcą w celu uzyskania wyceny.
Która biblioteka PDF jest łatwiejsza w użyciu do programowania w .NET?
IronPDF jest ogólnie łatwiejszy w użyciu przy tworzeniu oprogramowania w środowisku .NET, zapewniając prostsze API i wymagając mniej linii kodu do wykonania złożonych zadań w porównaniu z Apitron PDF Kit.



