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には2つのクラスがあります: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.