Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Display Filename in PDF File

$
0
0

Hi there, hoping for some help on what I think is quite a simple issue.

 

I want to create a blank single page PDF file which has a text field automatically and dynamically completed based on the file name of the pdf document. So for example if the file is named "My Sample File.pdf", the pdf file will display "My Sample File.pdf" and that is all. If I then rename the pdf file in Windows Explorer to "My Renamed File.pdf", when I next open the file it will display "My Renamed File.pdf".

 

I would then insert this one page pdf into an array of existing pdf files as their new page no1 to effectively be a title page for each created automatically based on their current filenames.

 

My research suggests this is possible using Javascript in a text field, or a form field (although I would prefer text field), however, as I have no experience of Javascript or its implementation within Acrobat, is proving impossible for me to do. The nearest I have got is a script which puts the filename as a watermark; unfortunately that script keeps overlaying the new filename over the old filename watermark, rather than updating it. For information that script was:-

 

this.addWatermarkFromText({

cText: this.documentFileName,

nTextAlign: app.constants.align.center,

nHorizAlign: app.constants.align.center,

nVertAlign: app.constants.align.bottom,

nFontSize: 12,

nVertValue: 12});

 

Ideally I would like the script to strip the file extension and if possible split the output onto two lines based on the filename portion which preceeds/follows a comma in the filename (which it would also strip). For example, if a had a file which was named "My Sample File, created on Monday.pdf", it would display as:-

 

My Sample File

created on Monday

 

If anyone has any ideas on this, it would be greatly appreciated.

 

Regards and thanks in advance,

Malcolm Dowers


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>