Iron Softwareは、IronPDFライブラリにおいて、さまざまなPDF編集機能をわかりやすいメソッドに簡素化しました。 署名を追加したり、HTMLのフッターを追加したり、透かしを押印したり、注釈を追加したりする際に役立ちます。 IronPDFは、読みやすいコード、プログラムによるPDF生成、簡単なデバッグ、そしてサポートされている任意の環境またはプラットフォームへのシームレスなデプロイを可能にするツールです。
var pdf = IronPdf.PdfDocument.FromFile("example.pdf");pdf.ApplyStamp(new IronPdf.Editing.TextStamper("Confidential"));pdf.SaveAs("edited_example.pdf");
var pdf = IronPdf.PdfDocument.FromFile("example.pdf");
pdf.ApplyStamp(new IronPdf.Editing.TextStamper("Confidential"));
pdf.SaveAs("edited_example.pdf");
using IronPdf;using System.Linq;// Instantiate RendererChromePdfRenderer renderer = new ChromePdfRenderer();// Create a PDF from a URLPdfDocument pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");// Access DOM Objectsvar objects = pdf.Pages.First().ObjectModel;
using IronPdf;
using System.Linq;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Create a PDF from a URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");
// Access DOM Objects
var objects = pdf.Pages.First().ObjectModel;
ImportsIronPdfImportsSystem.Linq' Instantiate RendererPrivate renderer As New ChromePdfRenderer()' Create a PDF from a URLPrivate pdf AsPdfDocument = renderer.RenderUrlAsPdf("https://ironpdf.com/")' Access DOM ObjectsPrivate objects = pdf.Pages.First().ObjectModel
Imports IronPdf
Imports System.Linq
' Instantiate Renderer
Private renderer As New ChromePdfRenderer()
' Create a PDF from a URL
Private pdf As PdfDocument = renderer.RenderUrlAsPdf("https://ironpdf.com/")
' Access DOM Objects
Private objects = pdf.Pages.First().ObjectModel
using IronPdf;using System.IO;// Read PDF file as streamvar fileByte = File.ReadAllBytes("sample.pdf");// Instantiate PDF object from streamPdfDocument pdf = new PdfDocument(fileByte);
using IronPdf;
using System.IO;
// Read PDF file as stream
var fileByte = File.ReadAllBytes("sample.pdf");
// Instantiate PDF object from stream
PdfDocument pdf = new PdfDocument(fileByte);
ImportsIronPdfImportsSystem.IO' Read PDF file as streamPrivate fileByte = File.ReadAllBytes("sample.pdf")' Instantiate PDF object from streamPrivate pdf As New PdfDocument(fileByte)
Imports IronPdf
Imports System.IO
' Read PDF file as stream
Private fileByte = File.ReadAllBytes("sample.pdf")
' Instantiate PDF object from stream
Private pdf As New PdfDocument(fileByte)
同様に、C# .NET では MemoryStream オブジェクトを通じて PDF を MemoryStream にエクスポートすることも可能です。
using IronPdf;using System.IO;var renderer = new ChromePdfRenderer();// Convert the URL into PDFPdfDocument pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");// Export PDF as StreamMemoryStream pdfAsStream = pdf.Stream;// Export PDF as Byte Arraybyte[] pdfAsByte = pdf.BinaryData;
using IronPdf;
using System.IO;
var renderer = new ChromePdfRenderer();
// Convert the URL into PDF
PdfDocument pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");
// Export PDF as Stream
MemoryStream pdfAsStream = pdf.Stream;
// Export PDF as Byte Array
byte[] pdfAsByte = pdf.BinaryData;
ImportsIronPdfImportsSystem.IOPrivate renderer = New ChromePdfRenderer()' Convert the URL into PDFPrivate pdf AsPdfDocument = renderer.RenderUrlAsPdf("https://ironpdf.com/")' Export PDF as StreamPrivate pdfAsStream AsMemoryStream = pdf.Stream' Export PDF as Byte ArrayPrivate pdfAsByte() AsByte = pdf.BinaryData
Imports IronPdf
Imports System.IO
Private renderer = New ChromePdfRenderer()
' Convert the URL into PDF
Private pdf As PdfDocument = renderer.RenderUrlAsPdf("https://ironpdf.com/")
' Export PDF as Stream
Private pdfAsStream As MemoryStream = pdf.Stream
' Export PDF as Byte Array
Private pdfAsByte() As Byte = pdf.BinaryData
using IronPdf;// Select the desired PDF FilePdfDocument pdf = PdfDocument.FromFile("sample.pdf");// Extract all text from an pdfstring allText = pdf.ExtractAllText();// Extract all text from page 1string page1Text = pdf.ExtractTextFromPage(0);
using IronPdf;
// Select the desired PDF File
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Extract all text from an pdf
string allText = pdf.ExtractAllText();
// Extract all text from page 1
string page1Text = pdf.ExtractTextFromPage(0);
ImportsIronPdf' Select the desired PDF FilePrivate pdf AsPdfDocument = PdfDocument.FromFile("sample.pdf")' Extract all text from an pdfPrivate allText AsString = pdf.ExtractAllText()' Extract all text from page 1Private page1Text AsString = pdf.ExtractTextFromPage(0)
Imports IronPdf
' Select the desired PDF File
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")
' Extract all text from an pdf
Private allText As String = pdf.ExtractAllText()
' Extract all text from page 1
Private page1Text As String = pdf.ExtractTextFromPage(0)
using IronPdf;PdfDocument pdf = PdfDocument.FromFile("sample.pdf");// Extract imagesvar images = pdf.ExtractAllImages();for(int i = 0; i < images.Count; i++){ // Export the extracted images images[i].SaveAs($"images/image{i}.png");}
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Extract images
var images = pdf.ExtractAllImages();
for(int i = 0; i < images.Count; i++)
{
// Export the extracted images
images[i].SaveAs($"images/image{i}.png");
}
ImportsIronPdfPrivate pdf AsPdfDocument = PdfDocument.FromFile("sample.pdf")' Extract imagesPrivate images = pdf.ExtractAllImages()For i AsInteger = 0 To images.Count - 1 ' Export the extracted images images(i).SaveAs($"images/image{i}.png")Next i
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")
' Extract images
Private images = pdf.ExtractAllImages()
For i As Integer = 0 To images.Count - 1
' Export the extracted images
images(i).SaveAs($"images/image{i}.png")
Next i
using IronPdf;PdfDocument pdf = PdfDocument.FromFile("novel.pdf");// Redact 'Alaric' phrase from all pagespdf.RedactTextOnAllPages("Alaric");pdf.SaveAs("redacted.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'Alaric' phrase from all pages
pdf.RedactTextOnAllPages("Alaric");
pdf.SaveAs("redacted.pdf");
ImportsIronPdfPrivate pdf AsPdfDocument = PdfDocument.FromFile("novel.pdf")' Redact 'Alaric' phrase from all pagespdf.RedactTextOnAllPages("Alaric")pdf.SaveAs("redacted.pdf")
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'Alaric' phrase from all pages
pdf.RedactTextOnAllPages("Alaric")
pdf.SaveAs("redacted.pdf")
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>");string oldText = ".NET6";string newText = ".NET7";// Replace text on all pagespdf.ReplaceTextOnAllPages(oldText, newText);pdf.SaveAs("replaceText.pdf");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>");
string oldText = ".NET6";
string newText = ".NET7";
// Replace text on all pages
pdf.ReplaceTextOnAllPages(oldText, newText);
pdf.SaveAs("replaceText.pdf");
ImportsIronPdfPrivate renderer As New ChromePdfRenderer()Private pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>")Private oldText AsString = ".NET6"Private newText AsString = ".NET7"' Replace text on all pagespdf.ReplaceTextOnAllPages(oldText, newText)pdf.SaveAs("replaceText.pdf")
Imports IronPdf
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>")
Private oldText As String = ".NET6"
Private newText As String = ".NET7"
' Replace text on all pages
pdf.ReplaceTextOnAllPages(oldText, newText)
pdf.SaveAs("replaceText.pdf")
using IronPdf;using IronPdf.Annotations;ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>");// Create a PDF annotation object on a specified page indexTextAnnotation annotation = new TextAnnotation(0){Title = "This is the title",Contents = "This is the long 'sticky note' comment content...",X = 50,Y = 700,};// Add the annotationpdf.Annotations.Add(annotation);pdf.SaveAs("annotation.pdf");
using IronPdf;
using IronPdf.Annotations;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>");
// Create a PDF annotation object on a specified page index
TextAnnotation annotation = new TextAnnotation(0)
{
Title = "This is the title",
Contents = "This is the long 'sticky note' comment content...",
X = 50,
Y = 700,
};
// Add the annotation
pdf.Annotations.Add(annotation);
pdf.SaveAs("annotation.pdf");
ImportsIronPdfImportsIronPdf.AnnotationsDim renderer As New ChromePdfRenderer()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>")' Create a PDF annotation object on a specified page indexDim annotation As New TextAnnotation(0) With { .Title = "This is the title", .Contents = "This is the long 'sticky note' comment content...", .X = 50, .Y = 700}' Add the annotationpdf.Annotations.Add(annotation)pdf.SaveAs("annotation.pdf")
Imports IronPdf
Imports IronPdf.Annotations
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>")
' Create a PDF annotation object on a specified page index
Dim annotation As New TextAnnotation(0) With {
.Title = "This is the title",
.Contents = "This is the long 'sticky note' comment content...",
.X = 50,
.Y = 700
}
' Add the annotation
pdf.Annotations.Add(annotation)
pdf.SaveAs("annotation.pdf")
using IronPdf;using IronPdf.Editing;ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");// Create text stamperTextStamper textStamper = new TextStamper(){Text = "Text Stamper!",FontFamily = "Bungee Spice",UseGoogleFont = true,FontSize = 30,IsBold = true,IsItalic = true,VerticalAlignment = VerticalAlignment.Top,};// Stamp the text stamperpdf.ApplyStamp(textStamper);pdf.SaveAs("stampText.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");
ImportsIronPdfImportsIronPdf.EditingPrivate renderer As New ChromePdfRenderer()Private pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")' Create text stamperPrivate 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 stamperpdf.ApplyStamp(textStamper)pdf.SaveAs("stampText.pdf")
Imports IronPdf
Imports IronPdf.Editing
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")
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Main HTML content</h1>");// Render backgroundPdfDocument background = renderer.RenderHtmlAsPdf("<body style='background-color: cyan;'></body>");// Add backgroundpdf.AddBackgroundPdf(background);pdf.SaveAs("addBackground.pdf");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Main HTML content</h1>");
// Render background
PdfDocument background = renderer.RenderHtmlAsPdf("<body style='background-color: cyan;'></body>");
// Add background
pdf.AddBackgroundPdf(background);
pdf.SaveAs("addBackground.pdf");
ImportsIronPdfPrivate renderer As New ChromePdfRenderer()Private pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>Main HTML content</h1>")' Render backgroundPrivate background AsPdfDocument = renderer.RenderHtmlAsPdf("<body style='background-color: cyan;'></body>")' Add backgroundpdf.AddBackgroundPdf(background)pdf.SaveAs("addBackground.pdf")
Imports IronPdf
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Main HTML content</h1>")
' Render background
Private background As PdfDocument = renderer.RenderHtmlAsPdf("<body style='background-color: cyan;'></body>")
' Add background
pdf.AddBackgroundPdf(background)
pdf.SaveAs("addBackground.pdf")
PDFにテキストを描画することは直感的で簡単です; DrawText を使用し、必要なパラメータを指定します。 この例では、Times New Romanフォントを使用して、新しいフレーズ Some text を追加しています。
using IronPdf;using IronSoftware.Drawing;ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");// Draw text on PDFpdf.DrawText("Some text", FontTypes.TimesNewRoman.Name, FontSize: 12, PageIndex: 0, X: 100, Y: 100, Color.Black, Rotation: 0);pdf.SaveAs("drawText.pdf");
using IronPdf;
using IronSoftware.Drawing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
// Draw text on PDF
pdf.DrawText("Some text", FontTypes.TimesNewRoman.Name, FontSize: 12, PageIndex: 0, X: 100, Y: 100, Color.Black, Rotation: 0);
pdf.SaveAs("drawText.pdf");
ImportsIronPdfImportsIronSoftware.DrawingDim renderer As New ChromePdfRenderer()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")' Draw text on PDFpdf.DrawText("Some text", FontTypes.TimesNewRoman.Name, FontSize:=12, PageIndex:=0, X:=100, Y:=100, Color.Black, Rotation:=0)pdf.SaveAs("drawText.pdf")
Imports IronPdf
Imports IronSoftware.Drawing
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
' Draw text on PDF
pdf.DrawText("Some text", FontTypes.TimesNewRoman.Name, FontSize:=12, PageIndex:=0, X:=100, Y:=100, Color.Black, Rotation:=0)
pdf.SaveAs("drawText.pdf")
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");// Configure the required parametersint pageIndex = 0;var start = new IronSoftware.Drawing.PointF(200,150);var end = new IronSoftware.Drawing.PointF(1000,150);int width = 10;var color = new IronSoftware.Drawing.Color("#000000");// Draw line on PDFpdf.DrawLine(pageIndex, start, end, width, color);pdf.SaveAs("drawLine.pdf");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
// Configure the required parameters
int pageIndex = 0;
var start = new IronSoftware.Drawing.PointF(200,150);
var end = new IronSoftware.Drawing.PointF(1000,150);
int width = 10;
var color = new IronSoftware.Drawing.Color("#000000");
// Draw line on PDF
pdf.DrawLine(pageIndex, start, end, width, color);
pdf.SaveAs("drawLine.pdf");
ImportsIronPdfPrivate renderer As New ChromePdfRenderer()Private pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")' Configure the required parametersPrivate pageIndex AsInteger = 0Private start = New IronSoftware.Drawing.PointF(200,150)Private [end] = New IronSoftware.Drawing.PointF(1000,150)Private width AsInteger = 10Private color = New IronSoftware.Drawing.Color("#000000")' Draw line on PDFpdf.DrawLine(pageIndex, start, [end], width, color)pdf.SaveAs("drawLine.pdf")
Imports IronPdf
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
' Configure the required parameters
Private pageIndex As Integer = 0
Private start = New IronSoftware.Drawing.PointF(200,150)
Private [end] = New IronSoftware.Drawing.PointF(1000,150)
Private width As Integer = 10
Private color = New IronSoftware.Drawing.Color("#000000")
' Draw line on PDF
pdf.DrawLine(pageIndex, start, [end], width, color)
pdf.SaveAs("drawLine.pdf")
using IronPdf;using IronPdf.Rendering;using System.Linq;// Import PDFPdfDocument pdf = PdfDocument.FromFile("multi-page.pdf");// Set rotation for a single pagepdf.SetPageRotation(0, PdfPageRotation.Clockwise90);// Set rotation for multiple pagespdf.SetPageRotations(Enumerable.Range(1,3), PdfPageRotation.Clockwise270);// Set rotation for the entire documentpdf.SetAllPageRotations(PdfPageRotation.Clockwise180);pdf.SaveAs("rotated.pdf");
using IronPdf;
using IronPdf.Rendering;
using System.Linq;
// Import PDF
PdfDocument pdf = PdfDocument.FromFile("multi-page.pdf");
// Set rotation for a single page
pdf.SetPageRotation(0, PdfPageRotation.Clockwise90);
// Set rotation for multiple pages
pdf.SetPageRotations(Enumerable.Range(1,3), PdfPageRotation.Clockwise270);
// Set rotation for the entire document
pdf.SetAllPageRotations(PdfPageRotation.Clockwise180);
pdf.SaveAs("rotated.pdf");
ImportsIronPdfImportsIronPdf.RenderingImportsSystem.Linq' Import PDFPrivate pdf AsPdfDocument = PdfDocument.FromFile("multi-page.pdf")' Set rotation for a single pagepdf.SetPageRotation(0, PdfPageRotation.Clockwise90)' Set rotation for multiple pagespdf.SetPageRotations(Enumerable.Range(1,3), PdfPageRotation.Clockwise270)' Set rotation for the entire documentpdf.SetAllPageRotations(PdfPageRotation.Clockwise180)pdf.SaveAs("rotated.pdf")
Imports IronPdf
Imports IronPdf.Rendering
Imports System.Linq
' Import PDF
Private pdf As PdfDocument = PdfDocument.FromFile("multi-page.pdf")
' Set rotation for a single page
pdf.SetPageRotation(0, PdfPageRotation.Clockwise90)
' Set rotation for multiple pages
pdf.SetPageRotations(Enumerable.Range(1,3), PdfPageRotation.Clockwise270)
' Set rotation for the entire document
pdf.SetAllPageRotations(PdfPageRotation.Clockwise180)
pdf.SaveAs("rotated.pdf")