Skip to content

Commit d0b8a78

Browse files
committed
Updated READMEs and code in XObjects, watermarks and backgrounds group
1 parent 09b21e0 commit d0b8a78

File tree

6 files changed

+23
-13
lines changed

6 files changed

+23
-13
lines changed

Samples/XObjects, watermarks and backgrounds/RemoveXObjectsWatermarks/C#/RemoveXObjectsWatermarks.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static void Main()
2020
{
2121
foreach (PdfPage page in pdf.Pages)
2222
{
23-
// remove first XObject (in this case it's a watermark)
23+
// Remove the first XObject. Here, it's a watermark.
2424
page.XObjects.RemoveAt(0);
2525
}
2626

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# Remove XObjects
2-
This sample shows how to remove XObjects (often used for watermarks and backgrounds) from PDF document pages.
1+
# Remove XObjects from PDF in C# and VB.NET
32

4-
Use PdfPage.XObjects.Remove or PdfPage.XObjects.RemoveAt method to remove specified XObject from a page or PdfPage.XObjects.Clear method to remove all such objects.
3+
This sample shows how to remove XObjects, often used for watermarks and backgrounds, from PDF document pages.
54

6-
Please note that XObjects are not always watermarks or backgrounds. Sometimes such objects are used for logos and other repeatable items.
5+
## Description
6+
7+
[Docotic.Pdf library](https://bitmiracle.com/pdf-library/) provides access to the collection of page XObjects through the [PdfPage.XObjects](https://api.docotic.com/pdfpage-xobjects) property. The value of the property is a [PdfList](https://api.docotic.com/pdflist(t)) object.
8+
9+
You can remove any XObject you no longer need using the [PdfList.Remove](https://api.docotic.com/pdflist(t)-remove) or [PdfList.RemoveAt](https://api.docotic.com/pdflist(t)-removeat) method. The [PdfList.Clear](https://api.docotic.com/pdflist(t)-clear) method removes all such objects.
10+
11+
Please note that XObjects are not always watermarks or backgrounds. A PDF file can use such objects for logos and other repeatable items, too.
12+
13+
## See also
14+
* [Get free time-limited license key](https://bitmiracle.com/pdf-library/download)

Samples/XObjects, watermarks and backgrounds/RemoveXObjectsWatermarks/VB.NET/RemoveXObjectsWatermarks.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Namespace BitMiracle.Docotic.Pdf.Samples
1515

1616
Using pdf As New PdfDocument("..\Sample Data\DocumentWithWatermark.pdf")
1717
For Each page As PdfPage In pdf.Pages
18-
' remove first XObject (in this case it's a watermark)
18+
' Remove the first XObject. Here, it's a watermark.
1919
page.XObjects.RemoveAt(0)
2020
Next
2121

Samples/XObjects, watermarks and backgrounds/Watermarks/C#/Watermarks.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public static void Main()
3333

3434
foreach (PdfPage page in pdf.Pages)
3535
{
36-
// draw watermark at the top left corner over the page contents
37-
// this will also add watermark to the collection of page XObjects
36+
// Draw the watermark at the top left corner over the page contents.
37+
// This will also add the watermark to the collection of page XObjects.
3838
page.Canvas.DrawXObject(watermark, 0, 0);
3939
}
4040

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Add watermarks and backgrounds to PDF using C# or VB.NET
22
This sample shows how to apply PDF watermarks and backgrounds in C# or VB.NET application.
33

4-
Use the `PdfDocument.CreateXObject` method to add a `PdfXObject` object to your document. Use the new object for a watermark. You can set up the PDF watermark appearance using methods and properties of the object’s canvas. To access the canvas, use the `PdfXObject.Canvas` property.
4+
Use the [PdfDocument.CreateXObject](https://api.docotic.com/pdfdocument-createxobject) method to add a [PdfXObject](https://api.docotic.com/pdfxobject) object to your document. Use the new object for a watermark. You can set up the PDF watermark appearance using methods and properties of the object’s canvas. To access the canvas, use the [PdfXObject.Canvas](https://api.docotic.com/pdfxobject-canvas) property.
55

6-
The `PdfCanvas.DrawXObject` methods apply the watermark to a page. It’s ok to apply the same watermark to more than one page.
6+
The [PdfCanvas.DrawXObject](https://api.docotic.com/pdfcanvas-drawxobject) methods apply the watermark to a page. It’s ok to apply the same watermark to more than one page.
77

8-
To convert a watermark to a background, set the `DrawOnBackground` property of the created object to `true`. After that, use apply the background to one or more pages using one of the PdfCanvas.DrawXObject methods.
8+
To convert a watermark to a background, set the [DrawOnBackground](https://api.docotic.com/pdfxobject-drawonbackground) property of the created object to `true`. After that, use apply the background to one or more pages using one of the `PdfCanvas.DrawXObject` methods.
99

1010
## See also
11+
* [Get free time-limited license key](https://bitmiracle.com/pdf-library/download)
12+
* [Watermarks & backgrounds](https://bitmiracle.com/pdf-library/edit/#watermarks)
1113
* [Watermark PDFs using page background and foreground containers](https://bitmiracle.com/pdf-library/layout/compounds#watermarks)

Samples/XObjects, watermarks and backgrounds/Watermarks/VB.NET/Watermarks.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Namespace BitMiracle.Docotic.Pdf.Samples
2828
watermarkCanvas.DrawString(100, 100, "This text is a part of the watermark")
2929

3030
For i As Integer = 0 To pdf.PageCount - 1
31-
' draw watermark at the top left corner over the page contents
32-
' this will also add watermark to the collection of page XObjects
31+
' Draw the watermark at the top left corner over the page contents.
32+
' This will also add the watermark to the collection of page XObjects.
3333
pdf.Pages(i).Canvas.DrawXObject(watermark, 0, 0)
3434
Next
3535

0 commit comments

Comments
 (0)