> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/android/get-started/samples/stampertest.md).

# Stamper

Sample Java code for using Apryse SDK to programmatically stamp PDF pages with text, images, or with other PDF pages.

Sample Java code for using Apryse SDK to programmatically stamp PDF pages with text, images, or with other PDF pages. ElementBuilder and ElementWriter should be used for more complex PDF stamping operations. Learn more about our [Android SDK](/core/get-started/languages/java.md).

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2019 by PDFTron Systems Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------

package com.pdftron.android.pdfnetsdksamples.samples;

import com.pdftron.android.pdfnetsdksamples.OutputListener;
import com.pdftron.android.pdfnetsdksamples.PDFNetSample;
import com.pdftron.android.pdfnetsdksamples.R;
import com.pdftron.android.pdfnetsdksamples.util.Utils;
import com.pdftron.pdf.ColorPt;
import com.pdftron.pdf.Font;
import com.pdftron.pdf.Image;
import com.pdftron.pdf.PDFDoc;
import com.pdftron.pdf.Page;
import com.pdftron.pdf.PageSet;
import com.pdftron.pdf.Rect;
import com.pdftron.pdf.Stamper;
import com.pdftron.sdf.SDFDoc;

import java.util.ArrayList;

/**
 * The following sample shows how to add new content (or watermark) PDF pages
 * using 'com.pdftron.pdf.Stamper' utility class.
 * <p>
 * Stamper can be used to PDF pages with text, images, or with other PDF content
 * in only a few lines of code. Although Stamper is very simple to use compared
 * to ElementBuilder/ElementWriter it is not as powerful or flexible. In case you
 * need full control over PDF creation use ElementBuilder/ElementWriter to add
 * new content to existing PDF pages as shown in the ElementBuilder sample project.
 */
public class StamperTest extends PDFNetSample {

	private static OutputListener mOutputListener;

	private static ArrayList<String> mFileList = new ArrayList<>();

    public StamperTest() {
        setTitle(R.string.sample_stamper_title);
        setDescription(R.string.sample_stamper_description);
    }

	@Override
	public void run(OutputListener outputListener) {
		super.run(outputListener);
		mOutputListener = outputListener;
		mFileList.clear();
		printHeader(outputListener);
        String input_filename = "newsletter";

        //--------------------------------------------------------------------------------
        // Example 1) Add text stamp to all pages, then remove text stamp from odd pages.
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();
            Stamper s = new Stamper(Stamper.e_relative_scale, 0.5, 0.5);
            s.setAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_center);
            ColorPt red = new ColorPt(1, 0, 0); // set text color to red
            s.setFontColor(red);
            String msg = "If you are reading this\nthis is an even page";
            PageSet ps = new PageSet(1, doc.getPageCount());
            s.stampText(doc, msg, ps);
            //delete all text stamps in even pages
            PageSet ps1 = new PageSet(1, doc.getPageCount(), PageSet.e_odd);
            Stamper.deleteStamps(doc, ps1);

            doc.save(Utils.createExternalFile(input_filename + ".ex1.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

        //--------------------------------------------------------------------------------
        // Example 2) Add Image stamp to first 2 pages.
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();

            Stamper s = new Stamper(Stamper.e_relative_scale, .05, .05);
            Image img = Image.create(doc, Utils.getAssetTempFile(INPUT_PATH + "peppers.jpg").getAbsolutePath());
            s.setSize(Stamper.e_relative_scale, 0.5, 0.5);
            //set position of the image to the center, left of PDF pages
            s.setAlignment(Stamper.e_horizontal_left, Stamper.e_vertical_center);
            ColorPt pt = new ColorPt(0, 0, 0, 0);
            s.setFontColor(pt);
            s.setRotation(180);
            s.setAsBackground(false);
            //only stamp first 2 pages
            PageSet ps = new PageSet(1, 2);
            s.stampImage(doc, img, ps);

            doc.save(Utils.createExternalFile(input_filename + ".ex2.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

        //--------------------------------------------------------------------------------
        // Example 3) Add Page stamp to all pages.
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();

            try (PDFDoc fish_doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + "fish.pdf").getAbsolutePath())) {
                fish_doc.initSecurityHandler();

                Stamper s = new Stamper(Stamper.e_relative_scale, 0.5, 0.5);
                Page src_page = fish_doc.getPage(1);
                Rect page_one_crop = src_page.getCropBox();
                // set size of the image to 10% of the original while keep the old aspect ratio
                s.setSize(Stamper.e_absolute_size, page_one_crop.getWidth() * 0.1, -1);
                s.setOpacity(0.4);
                s.setRotation(-67);
                //put the image at the bottom right hand corner
                s.setAlignment(Stamper.e_horizontal_right, Stamper.e_vertical_bottom);
                PageSet ps = new PageSet(1, doc.getPageCount());
                s.stampPage(doc, src_page, ps);

                doc.save(Utils.createExternalFile(input_filename + ".ex3.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
            }
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

        //--------------------------------------------------------------------------------
        // Example 4) Add Image stamp to first 20 odd pages.
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();

            Stamper s = new Stamper(Stamper.e_absolute_size, 20, 20);
            s.setOpacity(1);
            s.setRotation(45);
            s.setAsBackground(true);
            s.setPosition(30, 40);
            Image img = Image.create(doc, Utils.getAssetTempFile(INPUT_PATH + "peppers.jpg").getAbsolutePath());
            PageSet ps = new PageSet(1, 20, PageSet.e_odd);
            s.stampImage(doc, img, ps);

            doc.save(Utils.createExternalFile(input_filename + ".ex4.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

        //--------------------------------------------------------------------------------
        // Example 5) Add text stamp to first 20 even pages
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();

            Stamper s = new Stamper(Stamper.e_relative_scale, .05, .05);
            s.setPosition(0, 0);
            s.setOpacity(0.7);
            s.setRotation(90);
            s.setSize(Stamper.e_font_size, 80, -1);
            s.setTextAlignment(Stamper.e_align_center);
            PageSet ps = new PageSet(1, 20, PageSet.e_even);
            s.stampText(doc, "Goodbye\nMoon", ps);

            doc.save(Utils.createExternalFile(input_filename + ".ex5.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

        //--------------------------------------------------------------------------------
        // Example 6) Add first page as stamp to all even pages
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();

            PDFDoc fish_doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + "fish.pdf").getAbsolutePath());
            fish_doc.initSecurityHandler();

            Stamper s = new Stamper(Stamper.e_relative_scale, 0.3, 0.3);
            s.setOpacity(1);
            s.setRotation(270);
            s.setAsBackground(true);
            s.setPosition(0.5, 0.5, true);
            s.setAlignment(Stamper.e_horizontal_left, Stamper.e_vertical_bottom);
            Page page_one = fish_doc.getPage(1);
            PageSet ps = new PageSet(1, doc.getPageCount(), PageSet.e_even);
            s.stampPage(doc, page_one, ps);

            doc.save(Utils.createExternalFile(input_filename + ".ex6.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

        //--------------------------------------------------------------------------------
        // Example 7) Add image stamp at top right corner in every pages
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();

            Stamper s = new Stamper(Stamper.e_relative_scale, .1, .1);
            s.setOpacity(0.8);
            s.setRotation(135);
            s.setAsBackground(false);
            s.showsOnPrint(false);
            s.setAlignment(Stamper.e_horizontal_left, Stamper.e_vertical_top);
            s.setPosition(10, 10);

            Image img = Image.create(doc, Utils.getAssetTempFile(INPUT_PATH + "peppers.jpg").getAbsolutePath());
            PageSet ps = new PageSet(1, doc.getPageCount(), PageSet.e_all);
            s.stampImage(doc, img, ps);

            doc.save(Utils.createExternalFile(input_filename + ".ex7.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

        //--------------------------------------------------------------------------------
        // Example 8) Add Text stamp to first 2 pages, and image stamp to first page.
        //          Because text stamp is set as background, the image is top of the text
        //          stamp. Text stamp on the first page is not visible.
        try (PDFDoc doc = new PDFDoc(Utils.getAssetTempFile(INPUT_PATH + input_filename + ".pdf").getAbsolutePath())) {
            doc.initSecurityHandler();

            Stamper s = new Stamper(Stamper.e_relative_scale, 0.07, -0.1);
            s.setAlignment(Stamper.e_horizontal_right, Stamper.e_vertical_bottom);
            s.setAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_top);
            s.setFont(Font.create(doc, Font.e_courier, true));
            ColorPt red = new ColorPt(1, 0, 0, 0);
            s.setFontColor(red); //set color to red
            s.setTextAlignment(Stamper.e_align_right);
            s.setAsBackground(true); //set text stamp as background
            PageSet ps = new PageSet(1, 2);
            s.stampText(doc, "This is a title!", ps);

            Image img = Image.create(doc, Utils.getAssetTempFile(INPUT_PATH + "peppers.jpg").getAbsolutePath());
            s.setAsBackground(false); // set image stamp as foreground
            PageSet first_page_ps = new PageSet(1);
            s.stampImage(doc, img, first_page_ps);

            doc.save(Utils.createExternalFile(input_filename + ".ex8.pdf", mFileList).getAbsolutePath(), SDFDoc.SaveMode.LINEARIZED, null);
        } catch (Exception e) {
            mOutputListener.printError(e.getStackTrace());
            return;
        }

		for (String file : mFileList) {
			addToFileList(file);
		}
		printFooter(outputListener);
	}
    //---------------------------------------------------------------------------------------
    // The following sample shows how to add new content (or watermark) PDF pages
    // using 'pdftron.PDF.Stamper' utility class.
    //
    // Stamper can be used to PDF pages with text, images, or with other PDF content
    // in only a few lines of code. Although Stamper is very simple to use compared
    // to ElementBuilder/ElementWriter it is not as powerful or flexible. In case you
    // need full control over PDF creation use ElementBuilder/ElementWriter to add
    // new content to existing PDF pages as shown in the ElementBuilder sample project.
    //---------------------------------------------------------------------------------------

}
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2019 by PDFTron Systems Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------

package com.pdftron.android.pdfnetsdksamples.samples

import com.pdftron.android.pdfnetsdksamples.OutputListener
import com.pdftron.android.pdfnetsdksamples.PDFNetSample
import com.pdftron.android.pdfnetsdksamples.R
import com.pdftron.android.pdfnetsdksamples.util.Utils
import com.pdftron.pdf.*
import com.pdftron.sdf.SDFDoc
import java.util.*

/**
 * The following sample shows how to add new content (or watermark) PDF pages
 * using 'com.pdftron.pdf.Stamper' utility class.
 *
 *
 * Stamper can be used to PDF pages with text, images, or with other PDF content
 * in only a few lines of code. Although Stamper is very simple to use compared
 * to ElementBuilder/ElementWriter it is not as powerful or flexible. In case you
 * need full control over PDF creation use ElementBuilder/ElementWriter to add
 * new content to existing PDF pages as shown in the ElementBuilder sample project.
 */
class StamperTest : PDFNetSample() {
    init {
        setTitle(R.string.sample_stamper_title)
        setDescription(R.string.sample_stamper_description)
    }

    override fun run(outputListener: OutputListener?) {
        super.run(outputListener)
        mOutputListener = outputListener
        mFileList.clear()
        printHeader(outputListener!!)
        val input_filename = "newsletter"

        //--------------------------------------------------------------------------------
        // Example 1) Add text stamp to all pages, then remove text stamp from odd pages.
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()
                val s = Stamper(Stamper.e_relative_scale, 0.5, 0.5)
                s.setAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_center)
                val red = ColorPt(1.0, 0.0, 0.0) // set text color to red
                s.setFontColor(red)
                val msg = "If you are reading this\nthis is an even page"
                val ps = PageSet(1, doc.pageCount)
                s.stampText(doc, msg, ps)
                //delete all text stamps in even pages
                val ps1 = PageSet(1, doc.pageCount, PageSet.e_odd)
                Stamper.deleteStamps(doc, ps1)

                doc.save(Utils.createExternalFile("$input_filename.ex1.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        //--------------------------------------------------------------------------------
        // Example 2) Add Image stamp to first 2 pages.
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()

                val s = Stamper(Stamper.e_relative_scale, .05, .05)
                val img = Image.create(doc, Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + "peppers.jpg")!!.absolutePath)
                s.setSize(Stamper.e_relative_scale, 0.5, 0.5)
                //set position of the image to the center, left of PDF pages
                s.setAlignment(Stamper.e_horizontal_left, Stamper.e_vertical_center)
                val pt = ColorPt(0.0, 0.0, 0.0, 0.0)
                s.setFontColor(pt)
                s.setRotation(180.0)
                s.setAsBackground(false)
                //only stamp first 2 pages
                val ps = PageSet(1, 2)
                s.stampImage(doc, img, ps)

                doc.save(Utils.createExternalFile("$input_filename.ex2.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        //--------------------------------------------------------------------------------
        // Example 3) Add Page stamp to all pages.
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()

                PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + "fish.pdf")!!.absolutePath).use { fish_doc ->
                    fish_doc.initSecurityHandler()

                    val s = Stamper(Stamper.e_relative_scale, 0.5, 0.5)
                    val src_page = fish_doc.getPage(1)
                    val page_one_crop = src_page.cropBox
                    // set size of the image to 10% of the original while keep the old aspect ratio
                    s.setSize(Stamper.e_absolute_size, page_one_crop.width * 0.1, -1.0)
                    s.setOpacity(0.4)
                    s.setRotation(-67.0)
                    //put the image at the bottom right hand corner
                    s.setAlignment(Stamper.e_horizontal_right, Stamper.e_vertical_bottom)
                    val ps = PageSet(1, doc.pageCount)
                    s.stampPage(doc, src_page, ps)

                    doc.save(Utils.createExternalFile("$input_filename.ex3.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
                }
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        //--------------------------------------------------------------------------------
        // Example 4) Add Image stamp to first 20 odd pages.
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()

                val s = Stamper(Stamper.e_absolute_size, 20.0, 20.0)
                s.setOpacity(1.0)
                s.setRotation(45.0)
                s.setAsBackground(true)
                s.setPosition(30.0, 40.0)
                val img = Image.create(doc, Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + "peppers.jpg")!!.absolutePath)
                val ps = PageSet(1, 20, PageSet.e_odd)
                s.stampImage(doc, img, ps)

                doc.save(Utils.createExternalFile("$input_filename.ex4.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        //--------------------------------------------------------------------------------
        // Example 5) Add text stamp to first 20 even pages
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()

                val s = Stamper(Stamper.e_relative_scale, .05, .05)
                s.setPosition(0.0, 0.0)
                s.setOpacity(0.7)
                s.setRotation(90.0)
                s.setSize(Stamper.e_font_size, 80.0, -1.0)
                s.setTextAlignment(Stamper.e_align_center)
                val ps = PageSet(1, 20, PageSet.e_even)
                s.stampText(doc, "Goodbye\nMoon", ps)

                doc.save(Utils.createExternalFile("$input_filename.ex5.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        //--------------------------------------------------------------------------------
        // Example 6) Add first page as stamp to all even pages
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()

                PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + "fish.pdf")!!.absolutePath).use { fish_doc ->
                    fish_doc.initSecurityHandler()

                    val s = Stamper(Stamper.e_relative_scale, 0.3, 0.3)
                    s.setOpacity(1.0)
                    s.setRotation(270.0)
                    s.setAsBackground(true)
                    s.setPosition(0.5, 0.5, true)
                    s.setAlignment(Stamper.e_horizontal_left, Stamper.e_vertical_bottom)
                    val page_one = fish_doc.getPage(1)
                    val ps = PageSet(1, doc.pageCount, PageSet.e_even)
                    s.stampPage(doc, page_one, ps)

                    doc.save(Utils.createExternalFile("$input_filename.ex6.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
                }
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        //--------------------------------------------------------------------------------
        // Example 7) Add image stamp at top right corner in every pages
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()

                val s = Stamper(Stamper.e_relative_scale, .1, .1)
                s.setOpacity(0.8)
                s.setRotation(135.0)
                s.setAsBackground(false)
                s.showsOnPrint(false)
                s.setAlignment(Stamper.e_horizontal_left, Stamper.e_vertical_top)
                s.setPosition(10.0, 10.0)

                val img = Image.create(doc, Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + "peppers.jpg")!!.absolutePath)
                val ps = PageSet(1, doc.pageCount, PageSet.e_all)
                s.stampImage(doc, img, ps)

                doc.save(Utils.createExternalFile("$input_filename.ex7.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        //--------------------------------------------------------------------------------
        // Example 8) Add Text stamp to first 2 pages, and image stamp to first page.
        //          Because text stamp is set as background, the image is top of the text
        //          stamp. Text stamp on the first page is not visible.
        try {
            PDFDoc(Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + input_filename + ".pdf")!!.absolutePath).use { doc ->
                doc.initSecurityHandler()

                val s = Stamper(Stamper.e_relative_scale, 0.07, -0.1)
                s.setAlignment(Stamper.e_horizontal_right, Stamper.e_vertical_bottom)
                s.setAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_top)
                s.setFont(Font.create(doc, Font.e_courier, true))
                val red = ColorPt(1.0, 0.0, 0.0, 0.0)
                s.setFontColor(red) //set color to red
                s.setTextAlignment(Stamper.e_align_right)
                s.setAsBackground(true) //set text stamp as background
                val ps = PageSet(1, 2)
                s.stampText(doc, "This is a title!", ps)

                val img = Image.create(doc, Utils.getAssetTempFile(PDFNetSample.INPUT_PATH + "peppers.jpg")!!.absolutePath)
                s.setAsBackground(false) // set image stamp as foreground
                val first_page_ps = PageSet(1)
                s.stampImage(doc, img, first_page_ps)

                doc.save(Utils.createExternalFile("$input_filename.ex8.pdf", mFileList).absolutePath, SDFDoc.SaveMode.LINEARIZED, null)
            }
        } catch (e: Exception) {
            mOutputListener!!.printError(e.stackTrace)
            return
        }

        for (file in mFileList) {
            addToFileList(file)
        }
        printFooter(outputListener)
    }

    companion object {

        private var mOutputListener: OutputListener? = null

        private val mFileList = ArrayList<String>()
    }
    //---------------------------------------------------------------------------------------
    // The following sample shows how to add new content (or watermark) PDF pages
    // using 'pdftron.PDF.Stamper' utility class.
    //
    // Stamper can be used to PDF pages with text, images, or with other PDF content
    // in only a few lines of code. Although Stamper is very simple to use compared
    // to ElementBuilder/ElementWriter it is not as powerful or flexible. In case you
    // need full control over PDF creation use ElementBuilder/ElementWriter to add
    // new content to existing PDF pages as shown in the ElementBuilder sample project.
    //---------------------------------------------------------------------------------------

}
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/android/get-started/samples/stampertest.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
