C#에서 PDF를 편집하는 방법
Iron Software는 여러 PDF 편집 기능을 쉽게 이해할 수 있는 방법으로 IronPDF 라이브러리에 통합했습니다. 서명 추가, HTML 푸터 추가, 워터마크 삽입, 주석 추가 등 어떤 작업이든 가능합니다. IronPDF는 코드의 가독성, 프로그래밍을 통한 PDF 생성, 쉬운 디버깅 및 지원되는 모든 환경 또는 플랫폼으로의 원활한 배포를 가능하게 하는 도구입니다.
IronPDF PDF 편집을 위한 다양한 기능을 자랑합니다. 이 튜토리얼 문서에서는 주요 기능 몇 가지를 코드 예제와 설명을 통해 살펴보겠습니다.
이 글을 통해 C#에서 IronPDF 사용하여 PDF를 편집하는 방법을 잘 이해할 수 있을 것입니다.
빠른 시작: 몇 초 만에 PDF 파일 편집하기IronPDF 사용하면 C#에서 PDF 문서를 손쉽게 편집할 수 있습니다. 이 간편 가이드에서는 기존 PDF 파일에 텍스트 스탬프를 추가하는 방법을 보여줍니다. 몇 줄의 코드만으로 PDF를 수정하고 변경 사항을 즉시 저장할 수 있습니다. 빠르고 효율적인 PDF 편집 솔루션이 필요한 개발자에게 적합합니다.
-
1IronPDF를 NuGet Package Manager로 설치하십시오
-
2다음 코드 조각을 복사하여 실행하세요.
var pdf = IronPdf.PdfDocument.FromFile("example.pdf"); pdf.ApplyStamp(new IronPdf.Editing.TextStamper("Confidential")); pdf.SaveAs("edited_example.pdf");Dim pdf = IronPdf.PdfDocument.FromFile("example.pdf") pdf.ApplyStamp(New IronPdf.Editing.TextStamper("Confidential")) pdf.SaveAs("edited_example.pdf")Dim pdf = IronPdf.PdfDocument.FromFile("example.pdf") pdf.ApplyStamp(New IronPdf.Editing.TextStamper("Confidential")) pdf.SaveAs("edited_example.pdf") -
3실제 운영 환경에서 테스트할 수 있도록 배포하세요.
오늘 프로젝트에서 IronPDF 사용을 시작해보세요 무료 체험
- 문서 구조 편집
- 문서 속성 편집
- PDF 디자인 개선
문서 구조 편집
PDF DOM 객체에 접근
PDF 객체를 조작하고 접근하는 것은 빠르고 간단합니다. IronPDF는 개발자가 웹 페이지의 DOM을(를) 조작하는 것처럼 DOM 객체와 상호 작용하는 방식으로 개발자에게 친숙하게 하여 텍스트와 같은 다양한 요소에 프로그래밍적으로 접근하고 조작할 수 있도록 합니다.
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;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;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().ObjectModelImports 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이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
PDF 레이어 작업
레이어가 있는 PDF(예: CAD 도면, 공학 도면 및 지도 내보내기)는 그 내용을 명명된 선택적 콘텐츠 그룹에 보관합니다. IronPDF는 이를 PdfDocument.Layers를 통해 제공하므로, 레이어를 열거하고, 이름으로 찾고, 해당 범위의 텍스트를 추출할 수 있습니다.
using IronPdf;
using IronSoftware;
using System;
// Load a layered PDF, such as a CAD plan, engineering drawing, or map export
using PdfDocument pdf = new PdfDocument("blueprint.pdf");
// Enumerate every Optional Content Group (OCG) layer in the document
Console.WriteLine($"Document has {pdf.Layers.Count} layers");
foreach (PdfLayer layer in pdf.Layers)
{
Console.WriteLine($" {layer.Id}: \"{layer.Name}\" visible={layer.IsVisible} parent={layer.ParentId}");
}
// Look a layer up by name (case-sensitive) and extract just its text
PdfLayer titleBlock = pdf.Layers.FindByName("Title Block");
if (titleBlock != null)
{
string headerText = pdf.ExtractTextFromLayer(titleBlock.Id);
Console.WriteLine(headerText);
}using IronPdf;
using IronSoftware;
using System;
// Load a layered PDF, such as a CAD plan, engineering drawing, or map export
using PdfDocument pdf = new PdfDocument("blueprint.pdf");
// Enumerate every Optional Content Group (OCG) layer in the document
Console.WriteLine($"Document has {pdf.Layers.Count} layers");
foreach (PdfLayer layer in pdf.Layers)
{
Console.WriteLine($" {layer.Id}: \"{layer.Name}\" visible={layer.IsVisible} parent={layer.ParentId}");
}
// Look a layer up by name (case-sensitive) and extract just its text
PdfLayer titleBlock = pdf.Layers.FindByName("Title Block");
if (titleBlock != null)
{
string headerText = pdf.ExtractTextFromLayer(titleBlock.Id);
Console.WriteLine(headerText);
}Imports IronPdf
Imports IronSoftware
Imports System
' Load a layered PDF, such as a CAD plan, engineering drawing, or map export
Using pdf As New PdfDocument("blueprint.pdf")
' Enumerate every Optional Content Group (OCG) layer in the document
Console.WriteLine($"Document has {pdf.Layers.Count} layers")
For Each layer As PdfLayer In pdf.Layers
Console.WriteLine($" {layer.Id}: ""{layer.Name}"" visible={layer.IsVisible} parent={layer.ParentId}")
Next
' Look a layer up by name (case-sensitive) and extract just its text
Dim titleBlock As PdfLayer = pdf.Layers.FindByName("Title Block")
If titleBlock IsNot Nothing Then
Dim headerText As String = pdf.ExtractTextFromLayer(titleBlock.Id)
Console.WriteLine(headerText)
End If
End UsingImports IronPdf
Imports IronSoftware
Imports System
' Load a layered PDF, such as a CAD plan, engineering drawing, or map export
Using pdf As New PdfDocument("blueprint.pdf")
' Enumerate every Optional Content Group (OCG) layer in the document
Console.WriteLine($"Document has {pdf.Layers.Count} layers")
For Each layer As PdfLayer In pdf.Layers
Console.WriteLine($" {layer.Id}: ""{layer.Name}"" visible={layer.IsVisible} parent={layer.ParentId}")
Next
' Look a layer up by name (case-sensitive) and extract just its text
Dim titleBlock As PdfLayer = pdf.Layers.FindByName("Title Block")
If titleBlock IsNot Nothing Then
Dim headerText As String = pdf.ExtractTextFromLayer(titleBlock.Id)
Console.WriteLine(headerText)
End If
End Using이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
문서 저장 및 내보내기
IronPDF를 사용하면 편집된 문서를 빠르게 디스크에 PdfDocument.SaveAs 방법으로 저장할 수 있으며 이진 데이터 및 메모리 스트림과 같은 다른 형식으로 내보낼 수 있습니다.
이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
메모리에서 PDF 불러오기
IronPDF 기존 C# .NET 애플리케이션과 완벽하게 통합됩니다. 우리는 MemoryStream을(를) 통해 MemoryStream 객체를 사용하여 PDF 파일을 로드하고 만들 수 있습니다.
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);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);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)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)이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
PDF 파일을 메모리에 내보내기
마찬가지로, 우리는 C# .NET에서 MemoryStream으로 PDF를 내보낼 때 MemoryStream 객체를 사용할 수 있습니다.
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;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;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.BinaryDataImports 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이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
문서 텍스트 편집
Parse PDFs in C#
IronPDF 사용하면 PDF에서 텍스트를 빠르고 쉽게 추출할 수 있습니다. 모든 페이지에서 텍스트를 가져오기 위해 ExtractAllText 메소드를 사용하여 문서의 내용을 쉽게 접근하고 활용할 수 있습니다. 이 강력한 기능은 생산성을 향상시키고 작업 과정을 간소화합니다!
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);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);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)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)이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
텍스트 및 이미지 추출
IronPDF를 사용하면 텍스트 추출에만 국한되지 않습니다; PDF에서 이미지를 가져오는 것도 놀랍도록 쉽습니다! ExtractAllImages 기능을 사용하면 필요한 모든 시각 자료를 빠르게 캡처할 수 있습니다.
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");
}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");
}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 iImports 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이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
텍스트 및 영역 수정
민감한 정보를 교정하여 보호해야 하는 상황에서 우리는 강력한 도구 RedactTextOnAllPages를 사용할 수 있습니다. 이 기능을 사용하면 PDF 전체에서 특정 키워드가 나타나는 모든 부분을 손쉽게 찾아 숨길 수 있습니다. 이는 기밀 세부사항을 보호하면서도 문서를 안전하게 공유할 수 있는 효율적인 방법입니다.
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'Alaric' phrase from all pages
pdf.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");Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'Alaric' phrase from all pages
pdf.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")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
PDF에서 텍스트 바꾸기
IronPDF를 사용하여 PDF 문서를 향상시키기 위해 파일 전체의 텍스트를 쉽게 교체할 수 있습니다. ReplaceTextOnAllPages 기능을 사용하여 교체되어야 하는 oldText를 함께 제공하고 그 대체물로 사용할 newText를 제공할 수 있습니다. 이 방법은 문서 내 oldText의 모든 인스턴스를 효과적으로 업데이트하여 일관되고 전문적인 외관을 보장합니다.
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");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");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")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")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
PDF 디자인 향상
주석 추가 및 편집
IronPDF PDF 주석에 대한 광범위한 사용자 지정 옵션을 제공하여 사용자가 "스티커 메모" 스타일의 댓글을 PDF 페이지에 직접 추가할 수 있도록 합니다. TextAnnotation 클래스를 통해 크기, 불투명도, 아이콘 선택 및 편집 기능과 같은 고급 옵션을 제공하며, 주석을 프로그래밍적으로 추가할 수 있습니다. LinkAnnotation 클래스는 동일한 주석 컬렉션을 통해 사용자 정의 목차, 맨 위로 버튼과 같은 클릭 가능한 내부 네비게이션 링크를 추가합니다.
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");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");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")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")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
스탬프에 글자와 이미지를 새길 수 있습니다.
IronPDF PDF에 텍스트와 이미지를 삽입하는 방법을 사용자 지정할 수 있는 다양한 옵션을 제공합니다. 이 예제에서는 아래와 같이 ApplyStamp 메소드를 사용하여 PDF에 스탬프를 적용하기 위해 TextStamper 클래스를 사용할 것입니다.
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");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");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")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")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
사용자 지정 워터마크
또한 새로 렌더링된 PDF 및 기존 문서에 워터마크를 통합하기 위해 ApplyWatermark 메소드를 사용할 수 있습니다. 이 기능은 브랜드 인지도를 높여주어 자료가 전문적인 이미지를 전달하도록 보장합니다.
using IronPdf;
string watermarkHtml = @"
<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>
<h1>Iron Software</h1>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Watermark</h1>");
// Apply watermark
pdf.ApplyWatermark(watermarkHtml);
pdf.SaveAs("watermark.pdf");using IronPdf;
string watermarkHtml = @"
<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>
<h1>Iron Software</h1>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Watermark</h1>");
// Apply watermark
pdf.ApplyWatermark(watermarkHtml);
pdf.SaveAs("watermark.pdf");Imports IronPdf
Private watermarkHtml As String = "
<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>
<h1>Iron Software</h1>"
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Watermark</h1>")
' Apply watermark
pdf.ApplyWatermark(watermarkHtml)
pdf.SaveAs("watermark.pdf")Imports IronPdf
Private watermarkHtml As String = "
<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>
<h1>Iron Software</h1>"
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Watermark</h1>")
' Apply watermark
pdf.ApplyWatermark(watermarkHtml)
pdf.SaveAs("watermark.pdf")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
배경 및 전경
워터마크와 스탬프 외에도 PDF를 사용자 정의하기 위해 AddBackgroundPdf를 통해 배경을 추가할 수 있습니다.
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");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");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")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 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;
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");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")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")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
선과 사각형을 그리세요
IronPDF PDF에 선을 그리는 기능도 지원합니다. 우리는 먼저 두 개의 PointF 클래스를 초기화하여 시작점과 끝점을 만들고, 아래와 같이 DrawLine 메소드로 이를 적용합니다.
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");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");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")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")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
텍스트와 페이지 회전
PDF 페이지를 회전하기 위해 SetPageRotation 메소드를 사용하여 특정 페이지를 회전할 수 있습니다. 아래 예시에서는 2페이지부터 4페이지까지만 회전시키고 1페이지는 그대로 두어 기능을 보여줍니다.
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");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");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")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")회전 각도와 관련된 사용 가능한 열거형 목록은 여기를 참조하십시오.
이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
PDF 페이지 변환
회전 외에도 다양한 매개변수를 제공하여 PDF 페이지를 변형할 수 있습니다. 다음 예제에서는 PDF의 첫 페이지를 선택하고 Transform을 사용하여 첫 페이지의 내용을 오른쪽과 아래로 50포인트 이동하고 원래 크기의 80%로 축소합니다.
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("basic.pdf");
pdf.Pages[0].Transform(50, 50, 0.8, 0.8);
pdf.SaveAs("transformPage.pdf");using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("basic.pdf");
pdf.Pages[0].Transform(50, 50, 0.8, 0.8);
pdf.SaveAs("transformPage.pdf");Imports IronPdf
Dim pdf As PdfDocument = PdfDocument.FromFile("basic.pdf")
pdf.Pages(0).Transform(50, 50, 0.8, 0.8)
pdf.SaveAs("transformPage.pdf")Imports IronPdf
Dim pdf As PdfDocument = PdfDocument.FromFile("basic.pdf")
pdf.Pages(0).Transform(50, 50, 0.8, 0.8)
pdf.SaveAs("transformPage.pdf")이 코드 조각에 대한 더 상세한 설명과 추가 기능을 탐색하려면, 우리의 포괄적인 사용 가이드를 참조하시기 바랍니다.
결론
위의 예시 목록은 IronPDF PDF 편집과 관련하여 별도의 설정 없이 바로 사용할 수 있는 핵심 기능을 갖추고 있음을 보여줍니다.
IronPDF 또는 라이선스에 대한 기능 요청을 하거나 일반적인 질문이 있는 경우, 지원 팀에 문의해 주세요. 기꺼이 도와드리겠습니다.
자주 묻는 질문
IronPDF를 사용하여 PDF에 텍스트 스탬프를 추가할 수 있는 방법은 무엇인가요?
IronPDF의 TextStamper 클래스를 사용하여 텍스트 스탬프를 추가할 수 있습니다. PdfDocument 객체를 생성하고, ApplyStamp 메서드를 사용하여 스탬프를 적용하고 변경 사항을 저장합니다. 이를 통해 PDF 파일을 프로그래밍적으로 효율적으로 수정할 수 있습니다.
PDF에서 이미지를 추출하는 데 IronPDF가 제공하는 방법은 무엇인가요?
IronPDF는 ExtractAllImages 메서드를 제공합니다. 이 기능을 통해 PDF에서 모든 이미지를 쉽게 추출하고 저장할 수 있어 시각적 콘텐츠의 추출 및 관리 과정을 간소화할 수 있습니다.
IronPDF는 PDF에서 텍스트 수정 기능을 지원하나요?
예, IronPDF의 RedactTextOnAllPages 기능을 사용하여 PDF의 모든 페이지에 걸쳐 특정 구문이나 키워드를 수정할 수 있어 민감한 정보를 일관되게 숨길 수 있습니다.
IronPDF는 PDF 내 페이지 회전을 지원하나요?
IronPDF는 SetPageRotation 또는 SetAllPageRotations와 같은 메서드를 사용하여 특정 페이지나 전체 문서를 다양한 각도로 프로그래밍적으로 회전할 수 있도록 지원합니다.
IronPDF를 사용하여 PDF를 메모리 스트림에 내보내는 방법은 무엇인가요?
IronPDF에서 MemoryStream 객체를 생성하고 PdfDocument.Stream 메서드를 사용하여 PDF를 내보낼 수 있어 애플리케이션의 다른 부분과의 간편한 통합이 가능합니다.
IronPDF가 PDF에 주석을 추가하는데 제공하는 옵션은 무엇인가요?
IronPDF는 TextAnnotation 및 LinkAnnotation 클래스를 포함하여 끈적이 노트 및 인터랙티브 네비게이션 링크를 추가할 수 있는 광범위한 주석 기능을 지원하여 PDF의 상호작용성과 사용자 참여를 향상시킵니다.
IronPDF를 사용하여 PDF에 사용자 정의 워터마크를 추가하는 방법은 무엇인가요?
IronPDF의 ApplyWatermark 메서드를 사용하여 새로운 PDF와 기존 PDF 모두에 HTML 기반 워터마크를 추가할 수 있어 브랜드 인식과 문서의 전문적인 표현을 용이하게 합니다.
IronPDF를 사용하여 PDF의 텍스트를 교체하는 것이 가능한가요?
예, IronPDF의 ReplaceTextOnAllPages 기능을 사용하여 문서 전체의 텍스트를 대체할 수 있어 반복되는 콘텐츠를 간편하게 업데이트할 수 있습니다.
IronPDF가 기존 C# 애플리케이션에 PDF 생성을 통합할 수 있나요?
IronPDF는 기존의 C# .NET 애플리케이션에 통합할 수 있으며, 스트림에서 직접 PDF를 로드하고 생성할 수 있는 기능을 갖추어 신뢰할 수 있는 애플리케이션 개발을 지원합니다.
IronPDF가 PDF 페이지 컨텐츠 변환에 제공하는 기능은 무엇인가요?
IronPDF는 PDF 페이지 컨텐츠를 번역하고 확대하거나 축소할 수 있는 Transform 메서드를 제공하여 문서 프레젠테이션을 프로그래밍적으로 정밀하게 조작하고 맞춤화할 수 있습니다.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.