Copy link to clipboard
Copied
Guten Morgen
Ich möchte gerne im Wasserzeichen den Dateinamen ohne .pdf geschrieben haben. Ebenso gibt es manchmal, dass nach einem Bindestrich - eine oder zwei Zahlen im Dateinamen sind. diese sollten ebenfalls abgeschnitten werden. Ist nicht immer der Fall.
Die Farbe müsste rot sein, Schriftgrösse 14 und 1,5mm vom uneren Rand, vom linken Rand 10mm
Ein Beispiel: Philips_1005_2_1_1-1.pdf Neu: Philips_1005_2_1_1
Ich danke im Voraus herzlich für eine Hilfe.
Liebe Grüsse
Good Morning
It does not always have a hyphen (-), the script should per PDF either this.documentFileName.replace (".pdf", "",) or this.documentFileName.split ("-") [0] Is this possible? I would be very grateful for your help.
Kind regards
Copy link to clipboard
Copied
You can use the addWatermarkFromText command to add the watermark, or even using a (read-only) text field or annotation.
The text itself is just a string that you can manipulate using JavaScript's built-in command from that object.
For example, to remove the ".pdf" extension you can use the following:
this.documentFileName.replace(".pdf", "")
Copy link to clipboard
Copied
You can use the addWatermarkFromText command to add the watermark, or even using a (read-only) text field or annotation.
The text itself is just a string that you can manipulate using JavaScript's built-in command from that object.
For example, to remove the ".pdf" extension you can use the following:
this.documentFileName.replace(".pdf", "")
Copy link to clipboard
Copied
Thanks for the answer. After the sign - the numbers should be cut off. Unfortunately, I can not program
Copy link to clipboard
Copied
Use this:
this.documentFileName.split("-")[0]
It will also get rid of the file extension, so the other code is not needed.
Copy link to clipboard
Copied
Thank you very much. I will try this on Monday. have a good weekend. Kind regards
Copy link to clipboard
Copied
Good Morning
It does not always have a hyphen (-), the script should per PDF either this.documentFileName.replace (".pdf", "",) or this.documentFileName.split ("-") [0] Is this possible? I would be very grateful for your help.
Kind regards
Copy link to clipboard
Copied
OK, you should have mentioned that before...
The code would be something like this, then:
if (/-/.test(this.documentFileName)) {
// add watermark for file name with hyphen
} else {
// add watermark for file name without hyphen
}
Copy link to clipboard
Copied
Danke viel Mal
Copy link to clipboard
Copied
You can use:
this.documentFileName.replace(".pdf","").split("-")[0]
Copy link to clipboard
Copied
Thank you very much, it worked out great greetings