How to Automatically Apply a Watermark to the Last Page in Adobe Acrobat
Question details
The user needs to dynamically program a watermark to specifically target the final page of multiple PDF documents that have varying page lengths.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Batch applying watermarks using the Action Wizard across multiple PDF files where the total page count is inconsistent.
- Observed behavior
- Standard Acrobat Action watermark settings require static page ranges and cannot dynamically recognize the last page of uneven PDF batches natively.
Ensure you are using Adobe Acrobat Pro, as the ability to create Actions and run batch JavaScript workflows is not available in the free Adobe Acrobat Reader.
Use an Acrobat Action with JavaScript execution
By integrating a custom JavaScript into Acrobat's Action Wizard, you can dynamically calculate the page count of each document and apply the watermark to the last page, regardless of document length.
Since the standard Watermark dialog forces you to define a fixed page span, batch processing PDFs with unequal page counts results in the watermark being placed on the wrong page or missing entirely. Using the `this.numPages` JavaScript property allows the software to calculate the document's total pages in real-time.
Acrobat utilizes 0-based indexing for pages via JavaScript, which means the first page is '0' and the last page is always `this.numPages - 1`.
Launch Adobe Acrobat Pro, navigate to the 'Tools' tab, and select 'Action Wizard' from the Customize section.
Click on 'New Action' in the top toolbar to open the workflow configuration menu.
In the left panel under 'More Tools', find 'Execute JavaScript'. Click the '+' icon in the middle pane to add it to your Action.
Uncheck 'Prompt user' and click 'Specify Settings'. In the JavaScript editor, define the last page with `var lastPage = this.numPages - 1;` and use the `addWatermarkFromText` method targeting `nStart: lastPage` and `nEnd: lastPage`.
Click 'OK', proceed to save the Action giving it a clear name (e.g., 'Last Page Watermark'), and run the Action by selecting the target folder of PDFs.

Apply Custom Watermarks Easily with WPS Office
If you do not have Acrobat Pro or wish to bypass complex JavaScript completely, WPS Office provides a highly intuitive graphical interface to precisely insert, format, and apply watermarks to exact custom page ranges in your PDF documents.
- 1. Open your PDF in WPS Office: Launch WPS Office on your computer and open the target PDF file you want to watermark.
- 2. Access the watermark settings: Navigate to the 'Insert' tab located on the top ribbon, click 'Watermark', and select 'Insert Watermark'.
- 3. Customize your watermark appearance: Type your watermark text or upload a logo. Use the intuitive sliders to tweak opacity, size, tile display, and rotation angle.
- 4. Specify the exact page range: Under the Page Range section within the dialog box, select 'Custom' and input the page number representing the final page of your file, then click 'OK'.

Frequently Asked Questions
Why can't I select the last page dynamically in standard Acrobat settings?
Adobe Acrobat's built-in 'Add Watermark' dialog requires discrete, static page numbers (e.g., pages 1-10) or simple odd/even configurations. It currently lacks a native UI toggle for dynamic 'last page' selections when running a batch process on files with differing lengths.
Can I apply different watermarks to the first, middle, and last pages simultaneously?
Yes, this can be achieved using JavaScript in Acrobat's Action Wizard. You can write a sequential script that identifies the first page (index 0), the last page (numPages - 1), and middle pages, assigning a separate set of watermark parameters to each variable.
Does adding a watermark via JavaScript overwrite existing watermarks?
No, the `addWatermarkFromText` script method simply adds another graphical layer to the PDF document. If you need to replace or update an existing watermark, you must manually remove the old watermark or script its removal prior to applying the new one.
Can I use this JavaScript workflow on multiple PDFs at once?
Yes. Once you have created and saved the custom Action containing the 'Execute JavaScript' tool, you can simply load an entire folder of PDF files into the Action Wizard interface and execute it as an unattended batch process.




