Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.PDF for .NET은 아티팩트를 사용하여 PDF 문서에 워터마크를 추가할 수 있습니다. 이 문서를 확인하여 작업을 해결하십시오.
다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와 함께 작동합니다.
Adobe Acrobat으로 생성된 워터마크는 아티팩트라고 하며( PDF 사양의 14.8.2.2 실제 콘텐츠 및 아티팩트에 설명됨), 아티팩트와 함께 작업하기 위해 Aspose.PDF에는 두 개의 클래스가 있습니다: Artifact 및 ArtifactCollection.
특정 페이지의 모든 아티팩트를 가져오기 위해 Page 클래스에는 Artifacts 속성이 있습니다. 이 주제에서는 PDF 파일에서 아티팩트와 함께 작업하는 방법을 설명합니다.
Artifact 클래스에는 다음과 같은 속성이 포함되어 있습니다:
다음 코드 스니펫은 C#을 사용하여 PDF 파일의 첫 페이지에서 각 워터마크를 가져오는 방법을 보여줍니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddWatermarks()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_StampsWatermarks();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "AddWatermarksInput.pdf"))
{
// Create a new watermark artifact
var artifact = new Aspose.Pdf.WatermarkArtifact();
artifact.SetTextAndState(
"WATERMARK",
new Aspose.Pdf.Text.TextState()
{
FontSize = 72,
ForegroundColor = Aspose.Pdf.Color.Blue,
Font = Aspose.Pdf.Text.FontRepository.FindFont("Courier")
});
// Set watermark properties
artifact.ArtifactHorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
artifact.ArtifactVerticalAlignment = Aspose.Pdf.VerticalAlignment.Center;
artifact.Rotation = 45;
artifact.Opacity = 0.5;
artifact.IsBackground = true;
// Add watermark artifact to the first page
document.Pages[1].Artifacts.Add(artifact);
// Save PDF document
document.Save(dataDir + "AddWatermarks_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.