Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PDF内のArtifactは、実際の文書コンテンツの一部ではないグラフィックオブジェクトやその他の要素です。これらは通常、装飾、レイアウト、または背景目的で使用されます。Artifactの例としては、ページヘッダー、フッター、区切り線、または意味を伝えない画像などが含まれます。
PDFにおけるArtifactの目的は、コンテンツ要素と非コンテンツ要素とを区別できるようにすることです。これにより、スクリーンリーダーなどの支援技術がArtifactを無視して関連するコンテンツに注目できるため、アクセシビリティが向上します。また、印刷、検索、またはコピーの際にArtifactを省略することで、PDF文書のパフォーマンスおよび品質も改善されます。
PDF内で要素をArtifactとして作成するには、Artifact クラスを使用する必要があります。 このクラスには、以下の有用なプロパティが含まれています:
以下のクラスもArtifactの操作に役立つかもしれません:
Adobe Acrobatで作成された透かしは、PDF仕様の14.8.2.2 Real Content and Artifactsで説明されているように、Artifactと呼ばれます。
特定のページ上のすべての透かしを取得するには、Page クラスの Artifacts プロパティを使用します。
以下のコードスニペットは、PDFファイルの最初のページ上のすべての透かしを取得する方法を示しています。
Note: このコードは Aspose.PDF.Drawing ライブラリでも動作します。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExtractWatermarkFromPDF()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "sample-w.pdf"))
{
// Get the watermarks from the first page artifacts
var watermarks = document.Pages[1].Artifacts
.Where(artifact =>
artifact.Type == Aspose.Pdf.Artifact.ArtifactType.Pagination
&& artifact.Subtype == Aspose.Pdf.Artifact.ArtifactSubtype.Watermark);
// Iterate through the found watermark artifacts and print details
foreach (Aspose.Pdf.WatermarkArtifact item in watermarks.Cast<Aspose.Pdf.WatermarkArtifact>())
{
Console.WriteLine($"{item.Text} {item.Rectangle}");
}
}
}
背景画像は、文書に透かしやその他の subtle なデザイン要素を追加するために使用できます。Aspose.PDF for .NETでは、各PDF文書が複数のページで構成され、各ページが複数のArtifactを含んでいます。BackgroundArtifact クラスを使用して、ページオブジェクトに背景画像を追加できます。
以下のコードスニペットは、BackgroundArtifactオブジェクトを使用してPDFページに背景画像を追加する方法を示しています。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddBackgroundImageToPDF()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "sample.pdf"))
{
// Create a new BackgroundArtifact and set the background image
var background = new Aspose.Pdf.BackgroundArtifact()
{
BackgroundImage = File.OpenRead(dataDir + "background.jpg")
};
// Add the background image to the first page's artifacts
document.Pages[1].Artifacts.Add(background);
// Save PDF document with the added background
document.Save(dataDir + "SampleArtifactsBackground_out.pdf");
}
}
何らかの理由で、単色の背景を使用したい場合は、前述のコードを以下のように変更してください:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddBackgroundColorToPDF()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "sample.pdf"))
{
// Create a new BackgroundArtifact and set the background color
var background = new Aspose.Pdf.BackgroundArtifact()
{
BackgroundColor = Aspose.Pdf.Color.DarkKhaki
};
// Add the background color to the first page's artifacts
document.Pages[1].Artifacts.Add(background);
// Save PDF document
document.Save(dataDir + "SampleArtifactsBackground_out.pdf");
}
}
特定のタイプのArtifact (例えば、透かしの総数) の合計を計算するには、以下のコードを使用します:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void CountPDFArtifacts()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "sample.pdf"))
{
// Get pagination artifacts from the first page
var paginationArtifacts = document.Pages[1].Artifacts
.Where(artifact => artifact.Type == Aspose.Pdf.Artifact.ArtifactType.Pagination);
// Count and display the number of each artifact type
Console.WriteLine("Watermarks: {0}",
paginationArtifacts.Count(a => a.Subtype == Aspose.Pdf.Artifact.ArtifactSubtype.Watermark));
Console.WriteLine("Backgrounds: {0}",
paginationArtifacts.Count(a => a.Subtype == Aspose.Pdf.Artifact.ArtifactSubtype.Background));
Console.WriteLine("Headers: {0}",
paginationArtifacts.Count(a => a.Subtype == Aspose.Pdf.Artifact.ArtifactSubtype.Header));
Console.WriteLine("Footers: {0}",
paginationArtifacts.Count(a => a.Subtype == Aspose.Pdf.Artifact.ArtifactSubtype.Footer));
}
}
文書にBates番号付Artifactを追加するには、PageCollection
に対して AddBatesNumbering(BatesNArtifact batesNArtifact)
拡張メソッドを呼び出し、BatesNArtifact
オブジェクトをパラメータとして渡してください:
または、PaginationArtifacts
のコレクションを渡すこともできます:
あるいは、アクションデリゲートを使用してBates番号付Artifactを追加することも可能です:
Bates番号付を削除するには、以下のコードを使用してください:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.