透かしなしで本番環境でテストしてください。
必要な場所で動作します。
30日間、完全に機能する製品をご利用いただけます。
数分で稼働させることができます。
製品トライアル期間中にサポートエンジニアリングチームへの完全アクセス
PDFを扱う開発者にとって、PDFの生成と操作のための信頼できるライブラリを持つことは不可欠です。 .NETエコシステムでは、2つの人気のPDFライブラリが際立っています - IronPDF以下のコンテンツを日本語に翻訳してください:iTextPdf– それぞれがPDFドキュメントの作成、編集、管理に強力なツールを提供します。 この記事では、機能の性能、ドキュメントの質、および価格方針に基づくこれらのライブラリの詳細な比較を提供します。
IronPDFは、PDF管理のための堅牢な.NETライブラリであり、さまざまな.NET環境に対応しています。(Core 8、7、6、Framework、その他). 包括HTMLからPDFへの変換、PDFの結合、暗号化、デジタル署名などの包括的な機能セットを提供します。 IronPDFのドキュメントは分かりやすく、ユーザーは信頼できる技術サポートを利用できます。 開発者は、Stack Overflowのディスカッションやその他のソースコード共有プラットフォームで一般的な問題の解決策を見つけることがよくあります。
iTextPdfは、Javaおよび.NET用の高機能なPDFライブラリです。(C#)iTextライブラリから、企業レベルのドキュメント処理に焦点を当てています。 これは、さまざまなプロジェクトに柔軟性を提供するAGPLと商用ライセンスの両方で利用可能です。 iTextソフトウェア、例えばiTextPdfは非常にカスタマイズ性が高く、ドキュメントの暗号化、デジタル署名、フォーム作成などの複雑なPDFタスクに最適です。
IronPDFとiTextPdfの両方はクロスプラットフォーム機能をサポートしており、.NET内のさまざまなアプリケーションのニーズに対応するために多用途です。 各ライブラリの互換性の概要をご紹介します。
以下は、各ライブラリが提供する主要機能の詳細な比較です。
PDFスタンピング: PDFファイルに画像やテキストスタンプを追加します。
IronPDFが提供する豊富な機能の詳細については、以下のリンクをご覧ください。IronPDF機能ページ.
両方のライブラリはHTMLからPDFへの変換をサポートしていますが、アプローチと使いやすさに違いがあります。
IronPDF
using IronPdf;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
pdf.SaveAs("output.pdf");
// Advanced example with external assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
using IronPdf;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
pdf.SaveAs("output.pdf");
// Advanced example with external assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
iTextPdf
using iText.Html2pdf;
using System.IO;
public class HtmlToPdf
{
public static void ConvertHtmlToPdf()
{
using (FileStream htmlSource = File.Open("input.html", FileMode.Open))
using (FileStream pdfDest = File.Open("output.pdf", FileMode.Create))
{
ConverterProperties converterProperties = new ConverterProperties();
HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties);
}
}
}
using iText.Html2pdf;
using System.IO;
public class HtmlToPdf
{
public static void ConvertHtmlToPdf()
{
using (FileStream htmlSource = File.Open("input.html", FileMode.Open))
using (FileStream pdfDest = File.Open("output.pdf", FileMode.Create))
{
ConverterProperties converterProperties = new ConverterProperties();
HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties);
}
}
}
IronPDFは、に対してシンプルなアプローチを提供します。HTMLからPDFHTML、CSS、およびJavaScriptのサポートを含む変換。 それにより、ユーザーはHTML文字列から直接変換したり、オプションのベースパスを使用してアセットを含めたりすることができます。 iTextPdfは効果的ですが、ファイルベースの変換に重点を置いているため、追加のセットアップに数秒を要します。
セキュリティが最重要であるシナリオでは、暗号化が不可欠です。 こちらは各ライブラリの処理方法です。
IronPDF
using IronPdf;
// Load an encrypted PDF or create a new one
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Set document security settings
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
using IronPdf;
// Load an encrypted PDF or create a new one
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Set document security settings
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
iTextPdf
using iText.Kernel.Pdf;
using System.Text;
public class EncryptPdf
{
public static readonly String DEST = "encrypt_pdf.pdf";
public static readonly String OWNER_PASSWORD = "World";
public static readonly String USER_PASSWORD = "Hello";
protected void ManipulatePdf(String dest)
{
PdfDocument document = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter(dest,
new WriterProperties().SetStandardEncryption(
Encoding.UTF8.GetBytes(USER_PASSWORD),
Encoding.UTF8.GetBytes(OWNER_PASSWORD),
EncryptionConstants.ALLOW_PRINTING,
EncryptionConstants.ENCRYPTION_AES_128)));
document.Close();
}
}
using iText.Kernel.Pdf;
using System.Text;
public class EncryptPdf
{
public static readonly String DEST = "encrypt_pdf.pdf";
public static readonly String OWNER_PASSWORD = "World";
public static readonly String USER_PASSWORD = "Hello";
protected void ManipulatePdf(String dest)
{
PdfDocument document = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter(dest,
new WriterProperties().SetStandardEncryption(
Encoding.UTF8.GetBytes(USER_PASSWORD),
Encoding.UTF8.GetBytes(OWNER_PASSWORD),
EncryptionConstants.ALLOW_PRINTING,
EncryptionConstants.ENCRYPTION_AES_128)));
document.Close();
}
}
IronPDFのメソッドはよりユーザーフレンドリーであり、わかりやすさを提供しています。暗号化 (あんごうか)およびドキュメントの権限に対する制御。 iTextPdfは効果的ですが、暗号化基準に重点を置いた詳細な設定が必要です。
PDFファイル内の情報を墨消しすることは、プライバシーとセキュリティにとって不可欠です。 各ライブラリがこの機能をどのようにサポートしているかを以下に示します。
IronPDF
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
iTextPdf
using iText.Kernel.Pdf;
using iText.Kernel.Colors;
// Define areas to redact on each page
Rectangle[] rectanglesToRedact = { new Rectangle(100, 100, 200, 50) };
// Draw black rectangles to cover sensitive areas
using (PdfDocument pdfDoc = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter("output_redacted.pdf")))
{
for (int pageNum = 1; pageNum <= pdfDoc.GetNumberOfPages(); pageNum++)
{
PdfPage page = pdfDoc.GetPage(pageNum);
PdfCanvas canvas = new PdfCanvas(page);
foreach (Rectangle rect in rectanglesToRedact)
{
canvas.SetFillColor(ColorConstants.BLACK)
.Rectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight())
.Fill();
}
}
}
using iText.Kernel.Pdf;
using iText.Kernel.Colors;
// Define areas to redact on each page
Rectangle[] rectanglesToRedact = { new Rectangle(100, 100, 200, 50) };
// Draw black rectangles to cover sensitive areas
using (PdfDocument pdfDoc = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter("output_redacted.pdf")))
{
for (int pageNum = 1; pageNum <= pdfDoc.GetNumberOfPages(); pageNum++)
{
PdfPage page = pdfDoc.GetPage(pageNum);
PdfCanvas canvas = new PdfCanvas(page);
foreach (Rectangle rect in rectanglesToRedact)
{
canvas.SetFillColor(ColorConstants.BLACK)
.Rectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight())
.Fill();
}
}
}
IronPDFは便利な編集すべてのページにわたって敏感なテキストを簡単に隠すツール。 対照的に、iTextPdfではユーザーが手動で黒い長方形を定義して敏感な領域を覆う必要があります。
PDF文書の署名を自動化することで、時間を大幅に節約できます。ここでは、IronPDFとiTextPdfによるデジタル署名の処理方法を並べて比較します。
IronPDF
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
PdfDocument pdf = PdfDocument.FromFile("document.pdf");
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
PdfDocument pdf = PdfDocument.FromFile("document.pdf");
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
iTextPdf
using System;
using System.IO;
using iText.Kernel.Pdf;
using iText.Signatures;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.X509;
class Program
{
static void Main(string[] args)
{
string src = "input.pdf";
string dest = "output_signed.pdf";
string pfxFile = "your_certificate.pfx";
string pfxPassword = "your_password";
try
{
// Load your certificate
Pkcs12Store ks = new Pkcs12Store(new FileStream(pfxFile, FileMode.Open), pfxPassword.ToCharArray());
string alias = null;
foreach (string al in ks.Aliases)
{
if (ks.IsKeyEntry(al))
{
alias = al;
break;
}
}
ICipherParameters pk = ks.GetKey(alias).Key;
X509CertificateEntry[] chain = ks.GetCertificateChain(alias);
X509Certificate2 cert = new X509Certificate2(chain[0].Certificate.GetEncoded());
// Create output PDF with signed content
using (PdfReader reader = new PdfReader(src))
{
using (PdfWriter writer = new PdfWriter(dest))
{
using (PdfDocument pdfDoc = new PdfDocument(reader, writer))
{
// Create the signer
PdfSigner signer = new PdfSigner(pdfDoc, writer, new StampingProperties().UseAppendMode());
// Configure signature appearance
PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
appearance.SetReason("Digital Signature");
appearance.SetLocation("Your Location");
appearance.SetContact("Your Contact");
// Create signature
IExternalSignature pks = new PrivateKeySignature(pk, "SHA-256");
signer.SignDetached(pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
}
}
}
Console.WriteLine($"PDF digitally signed successfully: {dest}");
}
catch (Exception ex)
{
Console.WriteLine($"Error signing PDF: {ex.Message}");
}
}
}
using System;
using System.IO;
using iText.Kernel.Pdf;
using iText.Signatures;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.X509;
class Program
{
static void Main(string[] args)
{
string src = "input.pdf";
string dest = "output_signed.pdf";
string pfxFile = "your_certificate.pfx";
string pfxPassword = "your_password";
try
{
// Load your certificate
Pkcs12Store ks = new Pkcs12Store(new FileStream(pfxFile, FileMode.Open), pfxPassword.ToCharArray());
string alias = null;
foreach (string al in ks.Aliases)
{
if (ks.IsKeyEntry(al))
{
alias = al;
break;
}
}
ICipherParameters pk = ks.GetKey(alias).Key;
X509CertificateEntry[] chain = ks.GetCertificateChain(alias);
X509Certificate2 cert = new X509Certificate2(chain[0].Certificate.GetEncoded());
// Create output PDF with signed content
using (PdfReader reader = new PdfReader(src))
{
using (PdfWriter writer = new PdfWriter(dest))
{
using (PdfDocument pdfDoc = new PdfDocument(reader, writer))
{
// Create the signer
PdfSigner signer = new PdfSigner(pdfDoc, writer, new StampingProperties().UseAppendMode());
// Configure signature appearance
PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
appearance.SetReason("Digital Signature");
appearance.SetLocation("Your Location");
appearance.SetContact("Your Contact");
// Create signature
IExternalSignature pks = new PrivateKeySignature(pk, "SHA-256");
signer.SignDetached(pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
}
}
}
Console.WriteLine($"PDF digitally signed successfully: {dest}");
}
catch (Exception ex)
{
Console.WriteLine($"Error signing PDF: {ex.Message}");
}
}
}
適用する際にデジタル署名PDFファイルへの変換には、IronPDFがX509証明書を使用してこれを簡単かつ効率的に実行する方法を提供しています。 そのAPIはプロセスを簡素化し、署名のセキュリティを犠牲にすることなくワークフローに統合しやすくします。 比較すると、iTextPDFの署名プロセスはより複雑な設定ですが、追加のカスタマイズオプションを提供します。 開発者はより細かい制御が可能ですが、iTextPDFの署名設定と証明書処理をナビゲートする際に、より急な学習曲線に直面する可能性があります。
PDFにウォーターマークを追加することは、ブランディング、機密性の維持、および著作権保護にとって不可欠です。 こちらは、IronPDFとiTextPDFがPDFドキュメントにウォーターマークを適用する方法です。
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");
iTextPdf
using iText.IO.Font;
using iText.IO.Font.Constants;
using iText.Kernel.Colors;
using iText.Kernel.Font;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas;
using iText.Kernel.Pdf.Extgstate;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
public class TransparentWatermark
{
public static readonly String DEST = "results/sandbox/stamper/transparent_watermark.pdf";
public static readonly String SRC = "../../../resources/pdfs/hero.pdf";
public static void Main(String[] args)
{
FileInfo file = new FileInfo(DEST);
file.Directory.Create();
new TransparentWatermark().ManipulatePdf(DEST);
}
protected void ManipulatePdf(String dest)
{
PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
PdfCanvas under = new PdfCanvas(pdfDoc.GetFirstPage().NewContentStreamBefore(), new PdfResources(), pdfDoc);
PdfFont font = PdfFontFactory.CreateFont(FontProgramFactory.CreateFont(StandardFonts.HELVETICA));
Paragraph paragraph = new Paragraph("This watermark is added UNDER the existing content")
.SetFont(font)
.SetFontSize(15);
Canvas canvasWatermark1 = new Canvas(under, pdfDoc.GetDefaultPageSize())
.ShowTextAligned(paragraph, 297, 550, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
canvasWatermark1.Close();
PdfCanvas over = new PdfCanvas(pdfDoc.GetFirstPage());
over.SetFillColor(ColorConstants.BLACK);
paragraph = new Paragraph("This watermark is added ON TOP OF the existing content")
.SetFont(font)
.SetFontSize(15);
Canvas canvasWatermark2 = new Canvas(over, pdfDoc.GetDefaultPageSize())
.ShowTextAligned(paragraph, 297, 500, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
canvasWatermark2.Close();
paragraph = new Paragraph("This TRANSPARENT watermark is added ON TOP OF the existing content")
.SetFont(font)
.SetFontSize(15);
over.SaveState();
PdfExtGState gs1 = new PdfExtGState();
gs1.SetFillOpacity(0.5f);
over.SetExtGState(gs1);
Canvas canvasWatermark3 = new Canvas(over, pdfDoc.GetDefaultPageSize())
.ShowTextAligned(paragraph, 297, 450, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
canvasWatermark3.Close();
over.RestoreState();
pdfDoc.Close();
}
}
using iText.IO.Font;
using iText.IO.Font.Constants;
using iText.Kernel.Colors;
using iText.Kernel.Font;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas;
using iText.Kernel.Pdf.Extgstate;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
public class TransparentWatermark
{
public static readonly String DEST = "results/sandbox/stamper/transparent_watermark.pdf";
public static readonly String SRC = "../../../resources/pdfs/hero.pdf";
public static void Main(String[] args)
{
FileInfo file = new FileInfo(DEST);
file.Directory.Create();
new TransparentWatermark().ManipulatePdf(DEST);
}
protected void ManipulatePdf(String dest)
{
PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
PdfCanvas under = new PdfCanvas(pdfDoc.GetFirstPage().NewContentStreamBefore(), new PdfResources(), pdfDoc);
PdfFont font = PdfFontFactory.CreateFont(FontProgramFactory.CreateFont(StandardFonts.HELVETICA));
Paragraph paragraph = new Paragraph("This watermark is added UNDER the existing content")
.SetFont(font)
.SetFontSize(15);
Canvas canvasWatermark1 = new Canvas(under, pdfDoc.GetDefaultPageSize())
.ShowTextAligned(paragraph, 297, 550, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
canvasWatermark1.Close();
PdfCanvas over = new PdfCanvas(pdfDoc.GetFirstPage());
over.SetFillColor(ColorConstants.BLACK);
paragraph = new Paragraph("This watermark is added ON TOP OF the existing content")
.SetFont(font)
.SetFontSize(15);
Canvas canvasWatermark2 = new Canvas(over, pdfDoc.GetDefaultPageSize())
.ShowTextAligned(paragraph, 297, 500, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
canvasWatermark2.Close();
paragraph = new Paragraph("This TRANSPARENT watermark is added ON TOP OF the existing content")
.SetFont(font)
.SetFontSize(15);
over.SaveState();
PdfExtGState gs1 = new PdfExtGState();
gs1.SetFillOpacity(0.5f);
over.SetExtGState(gs1);
Canvas canvasWatermark3 = new Canvas(over, pdfDoc.GetDefaultPageSize())
.ShowTextAligned(paragraph, 297, 450, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
canvasWatermark3.Close();
over.RestoreState();
pdfDoc.Close();
}
}
IronPDFのAPIは、迅速かつ直感的に使えるようにします。透かしHTMLとCSSを使用したカスタマイズの柔軟性を持つアプリケーション。 このアプローチはユーザーフレンドリーで、広範な設定を必要とせずに視覚的に特徴のある透かしを作成しやすくします。一方、iTextPDFは、より詳細な設定オプションによって非常にカスタマイズ可能な透かしの配置を可能にしますが、より多くのコーディング努力を要します。
PDFにコンテンツをスタンプすることは、ウォーターマークを適用することに似ていますが、ラベリングやブランディングの目的で、画像やテキストのような特定の要素を追加することに重点を置いています。 こちらが、IronPDF と iTextPDF がこのタスクを実行する方法です。
IronPDF
using IronPdf;
using IronPdf.Editing;
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;
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");
iTextPdf
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
public void StampPDF(string inputPdfPath, string outputPdfPath, string stampText)
{
PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputPdfPath), new PdfWriter(outputPdfPath));
Document doc = new Document(pdfDoc);
// Add stamp (text) to each page
int numPages = pdfDoc.GetNumberOfPages();
for (int i = 1; i <= numPages; i++)
{
doc.ShowTextAligned(new Paragraph(stampText),
36, 36, i, iText.Layout.Properties.TextAlignment.LEFT,
iText.Layout.Properties.VerticalAlignment.TOP, 0);
}
doc.Close();
}
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
public void StampPDF(string inputPdfPath, string outputPdfPath, string stampText)
{
PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputPdfPath), new PdfWriter(outputPdfPath));
Document doc = new Document(pdfDoc);
// Add stamp (text) to each page
int numPages = pdfDoc.GetNumberOfPages();
for (int i = 1; i <= numPages; i++)
{
doc.ShowTextAligned(new Paragraph(stampText),
36, 36, i, iText.Layout.Properties.TextAlignment.LEFT,
iText.Layout.Properties.VerticalAlignment.TOP, 0);
}
doc.Close();
}
IronPDFの画像およびテキストのスタンピングメソッドは効率的で柔軟性があり、開発者がブランドコンテンツやラベルをPDFページに簡単に追加できるようにします。 APIは、使い慣れたHTML/CSSスタイリング要素を利用しており、カスタマイズが簡単です。 iTextPDFは画像とテキストのスタンピング機能も提供していますが、その設定にはより多くの手動によるセットアップとPDFレイアウト構造の知識が必要です。 PDFページ上でコンテンツを直接操作しスタイルを設定する能力により、開発者に強力なスタンプツールが提供されますが、iTextPDFのセットアップにはもう少し手間がかかるかもしれません。
一部のプロジェクトでは、DOCXファイルをPDF形式に変換する必要があります。 以下は、IronPDFとiTextがこのタスクをどのように処理するかを比較し、その違いを強調したものです。
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");
iTextPDF
IronPDFとは異なり、iTextPDFにはDOCXをPDFに変換するための組み込みサポートがありません。 この変換を行うために、開発者はDocXやAspose.Wordsのようなサードパーティライブラリを利用して、まずDOCXファイルをPDF互換フォーマットに変換し、その後iTextPDFを使用して処理または修正する必要があります。
IronPDFは、簡単で組み込みのソリューションを提供します。DOCXからPDFへの変換追加のライブラリが不要になります。 これは、迅速かつ統合されたアプローチを必要とする開発者に非常に適しています。 対照的に、iTextPDFはDOCXファイルを変換するために外部ライブラリに依存しており、追加のセットアップと依存関係が必要で、プロジェクトの複雑さが増す可能性があります。
詳細な例については、こちらをご覧くださいIronPDFの例.
IronPDFには、ライセンス購入のためのさまざまなレベルと追加機能があります。 開発者は、また、購入することができますIron SuiteすべてのIronSoftwareの製品にアクセスできることを、2つの価格で提供します。 ライセンスを購入する準備ができていない場合、IronPDF は無料試用, .
Iron Suite: $1,498で、IronPDF、IronOCR、IronWord、IronXL、IronBarcode、IronQR、IronZIP、IronPrint、およびIronWebScraperを含むすべてのIron Software製品にアクセスできます。
iTextPDFは、その豊富な機能セットに対して強力なドキュメントとサポートを提供しています。
定期的な更新: iTextPDFは頻繁に更新と改善を提供します。
IronPDF のドキュメントとサポートの詳細については、訪問してくださいIronPDF ドキュメントおよびIronSoftware YouTubeチャネル.
.NET向けのPDF操作ツールの領域では、両方のIronPDFおよびiTextPDFは開発者向けに強力なソリューションを提供します。 IronPDFは、外部依存なしでDOCXをPDFに変換するユーザーフレンドリーな機能や.NETプラットフォーム全体での簡単な統合で際立っています。 対照的に、iTextPDFは、その多様性と豊富な機能セットで知られており、特に他のツールと組み合わせた場合には強力な選択肢として残りますが、DOCX変換には追加の依存関係が必要です。
最終的に、IronPDFとiTextPDFの選択は、プロジェクトの特定のニーズ、ライセンスの好み、および必要なサポートのレベルに依存します。 両方のライブラリは、.NETアプリケーションでPDFワークフローを効率化するための信頼できる方法を提供します。