Skip to content

Commit 8123c2e

Browse files
Add 99 example(s) for pages
1 parent 3765296 commit 8123c2e

180 files changed

Lines changed: 5779 additions & 5040 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.IO;
3+
using Aspose.Pdf;
4+
5+
class Program
6+
{
7+
static void Main()
8+
{
9+
const string inputPath = "input.pdf";
10+
const string outputPath = "bates_numbered.pdf";
11+
12+
if (!File.Exists(inputPath))
13+
{
14+
Console.Error.WriteLine($"File not found: {inputPath}");
15+
return;
16+
}
17+
18+
// Load the PDF document
19+
using (Document doc = new Document(inputPath))
20+
{
21+
// Add Bates numbering with an alphanumeric prefix
22+
doc.Pages.AddBatesNumbering(bates =>
23+
{
24+
bates.Prefix = "PRJ-"; // Alphanumeric prefix for project tracking
25+
bates.StartNumber = 1; // Starting number
26+
bates.NumberOfDigits = 5; // Zero‑padded to 5 digits (e.g., 00001)
27+
28+
// Position the artifact at the bottom‑right of each page
29+
bates.ArtifactHorizontalAlignment = HorizontalAlignment.Right;
30+
bates.ArtifactVerticalAlignment = VerticalAlignment.Bottom;
31+
bates.BottomMargin = 20; // 20 points from the bottom edge
32+
bates.RightMargin = 20; // 20 points from the right edge
33+
});
34+
35+
// Save the modified PDF
36+
doc.Save(outputPath);
37+
}
38+
39+
Console.WriteLine($"Bates numbering added. Saved to '{outputPath}'.");
40+
}
41+
}

pages/add-bates-numbering-increment-5.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

pages/add-bates-numbering-stamp.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.IO;
3+
using Aspose.Pdf;
4+
5+
class Program
6+
{
7+
static void Main()
8+
{
9+
const string inputPath = "input.pdf";
10+
const string outputPath = "bates_numbered.pdf";
11+
12+
if (!File.Exists(inputPath))
13+
{
14+
Console.Error.WriteLine($"File not found: {inputPath}");
15+
return;
16+
}
17+
18+
// Load the PDF document (using the standard Document constructor)
19+
using (Document doc = new Document(inputPath))
20+
{
21+
// Add Bates numbering to every page.
22+
// Configure the artifact: prefix "2026-", 4 digits, start at 1.
23+
doc.Pages.AddBatesNumbering(artifact =>
24+
{
25+
artifact.Prefix = "2026-";
26+
artifact.NumberOfDigits = 4; // ####
27+
artifact.StartNumber = 1;
28+
});
29+
30+
// Save the modified PDF.
31+
doc.Save(outputPath);
32+
}
33+
34+
Console.WriteLine($"Bates-numbered PDF saved to '{outputPath}'.");
35+
}
36+
}

pages/add-bates-numbering.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

pages/add-bates-numbering__v2.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

pages/add-bates-numbering__v3.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.IO;
3+
using Aspose.Pdf; // Core Aspose.Pdf namespace
4+
using Aspose.Pdf; // For PageLabel, NumberingStyle, etc.
5+
6+
class Program
7+
{
8+
static void Main()
9+
{
10+
const string inputPath = "input.pdf"; // Existing PDF (can be empty)
11+
const string outputPath = "output_with_label.pdf";
12+
13+
if (!File.Exists(inputPath))
14+
{
15+
Console.Error.WriteLine($"Input file not found: {inputPath}");
16+
return;
17+
}
18+
19+
// Load the PDF, add a blank page, set a custom page label “i”, and save.
20+
using (Document doc = new Document(inputPath))
21+
{
22+
// Insert a new blank page at the beginning (position 1, 1‑based indexing)
23+
// The inserted page will adopt the most common page size in the document.
24+
Page blankPage = doc.Pages.Insert(1);
25+
26+
// Create a PageLabel with the desired prefix "i" and no numbering.
27+
PageLabel label = new PageLabel
28+
{
29+
Prefix = "i",
30+
NumberingStyle = NumberingStyle.None,
31+
StartingValue = 1 // Value is ignored when NumberingStyle is None
32+
};
33+
34+
// PageLabelCollection uses zero‑based page indexes.
35+
// The newly inserted page is at index 0.
36+
doc.PageLabels.UpdateLabel(0, label);
37+
38+
// Save the modified document.
39+
doc.Save(outputPath);
40+
}
41+
42+
Console.WriteLine($"PDF saved with custom front‑matter label to '{outputPath}'.");
43+
}
44+
}

0 commit comments

Comments
 (0)