• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Add current date to PDF documents

New Here ,
Nov 01, 2005 Nov 01, 2005

Copy link to clipboard

Copied

This doesn't seem like it should be hard, but I have been unable to find information on how to do it.

I have about 100 PDF files. Somewhere on them, I need to display "Date Printed: dd mmm yyyy", and have the current date displayed.

I don't care whether this is placed at the top of the page, the bottom, or opaque in the background.

I would like to be able to accomplish it using the batch command, but will perform manually if necessary.

I have Acrobat 7 Professional.

Can someone please help me out?

Views

40.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
replies 128 Replies 128
LEGEND ,
Dec 13, 2007 Dec 13, 2007

Copy link to clipboard

Copied

Acrobat Standard only allows editing the JavaScript in bookmarks, page actions, print actions, and save actions these options do not provide direct edit of the document level or form scripts. You would need a user that knows how to create a bookmark that can open the JavaScript Console and then know enough Acrobat JavaScript to modify the field level and add document level scripts. The modification of JavaScripts by the JavaScript statements is tricky for most programers and if they are good enough to do that they should know better than changing them.

Using Acrobat's password security can lock the PDF to limit entering form data and printing the form, then the user would need to crack the password to modify the scripts. And if they did that your employer could have grounds for damages and termination.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 18, 2007 Dec 18, 2007

Copy link to clipboard

Copied

<< CODE works in Acrobat Professional but NOT in Reader - Please help>><br /><br />Hello Everyone:<br /><br />I am using Acrobat 8.0 Professional.<br /><br />I created a Batch File that Prints at the bottom of each page <This document expires at: Todays date>. Using Acrobat Professional, I am able to apply this code to all PDF's in a selected folder using the Batch Processing menu.<br /><br /><< == CODE BEGIN ====================================== >> <br /><br />var myWillPrintScript = 'for (var i = 0; i < this.numPages; i++){\r'<br />+ 'var aRectangle = this.getPageBox( {nPage: i} ); \r'<br />+ 'aRectangle[1] = aRectangle[3] +14; \r \r'<br />+ 'var fld = this.addField("ComboDatePrint", "text", i, aRectangle ); \r \r'<br />+ 'fld.alignment = "center"; \r'<br />+ 'fld.textSize = 7; \r'<br />+ 'fld.textColor = color.blue; \r'<br />+ 'fld.textFont = font.HelvB; \r'<br />+ 'fld.fillColor = color.white; \r'<br />+ 'fld.readonly = true; \r'<br />+ 'fld.print = true; \r'<br />+ 'fld.display = display.noView; \r \r'<br />+ 'fld.value = "This Document Expires at: " + util.printd("mmmm dd, yyyy",new Date()) + " 11:59 PM"; \r'<br />+ '} \r'<br />this.setAction("WillPrint", myWillPrintScript);<br /><br /><< == CODE END ======================================== >> <br /><br />This code works perfectly for users who have Acrobat Professional Installed. When they print the PDF, the selected message prints on the bottom of each page.<br /><br />However NOTHING prints for users using Acrobat Reader 8.0.<br /><br />They get an error message if the Error Console is turned on that reads:<br /><<<br />NotAllowedError: Security settings prevent access to this property or method <br />Doc.addField:5:Doc undefine:Will Print<br />>><br /><br />I only have 12 users in our company, and only 3 have Acrobat Professional because of cost reasons. Is there a way to bypass the security message, and permit the date to print for users using only Acrobat Reader.<br /><br />Thanks so much for your help.<br />GC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 18, 2007 Dec 18, 2007

Copy link to clipboard

Copied

When using Reader, one can not create a form field with JavaScript, so one has to use Acrobat Professional to crate the the field, and then modify the will print script to just change the field's value.

A possible batch processing script to add the field to each page of a PDF and the "Will Print" action to the PDF.

// for each page of open PDF add the following field:
for (var i = 0; i < this.numPages; i++) {
var aRectangle = this.getPageBox( {nPage: i} ); // get page size
aRectangle[1] = aRectangle[3] +14; // set location
var fld = this.addField("ComboDatePrint", "text", i, aRectangle ); // define field to add
'fld.alignment = "center"; // alignment of field
fld.textSize = 7; // text size for field
fld.textColor = color.blue; // text color for field
fld.textFont = font.HelvB; // font for field
fld.fillColor = color.white; // fill color
fld.readonly = true; // write protect the field
fld.print = true; // print field
fld.display = display.noView; // do not display field
} // end for loop

// add will print script to populate field - all fields with same name will have the same value
var myWillPrintScript = 'var fld = this.getField("ComboDatePrint"); fld.value = "This Document Expires at: " + util.printd("mmmm dd, yyyy",new Date()) + " 11:59 PM"; \r' + '} \r' this.setAction("WillPrint", myWillPrintScript);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 18, 2007 Dec 18, 2007

Copy link to clipboard

Copied

Hi Geo:<br /><br />Thanks so much for the code revision. However when I executed your code aftering revising my batch script, I get an error in the Javascript debugger: <br /><br />syntax error<br />2:Doc:Will Print<br /><br /><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<br />for (var i = 0; i < this.numPages; i++) <br /><br />{ <br /><br />var aRectangle = this.getPageBox( {nPage: i} ); <br /><br />aRectangle[1] = aRectangle[3] +14; <br /><br />var fld = this.addField("ComboDatePrint", "text", i, aRectangle ); <br /><br />fld.alignment = "center"; <br /><br />fld.textSize = 7; <br /><br />fld.textColor = color.blue; <br /><br />fld.textFont = font.HelvB; <br /><br />fld.fillColor = color.white; <br /><br />fld.readonly = true; <br /><br />fld.print = true; <br /><br />fld.display = display.noView; <br />} <br /><br /> <br />var myWillPrintScript = 'var fld = this.getField("ComboDatePrint"); fld.value = "This Document Expires at: " + util.printd("mmmm dd, yyyy",new Date()) + " 11:59 PM"; \r' + '} \r' <br /><br />this.setAction("WillPrint", myWillPrintScript); <br /><br />>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br /><br />I ran the batch using: Advanced --> Document Processing --> Batch Processing --> Run Sequence (selected custom batch file named <ReaderAddExpirationDatesToDocs> with your code). <br /><br />The batch ran without any errors.<br /><br />But when I open one of the target PDF's which the batch modified, I get the message<br /><br />Syntax error<br />2:Doc:Will Print<br /><br />Thanks so much for your help. I am not at all good at Scripting in acrobat and your help is very much appreicated.<br /><br />GC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 18, 2007 Dec 18, 2007

Copy link to clipboard

Copied

Hi All:<br /><br />This Code works to add an expiration date at the bottom of each page of a PDF document.<br /><br /><< FOR USERS OF ACROBAT PROFESSIONAL == This has limited use, since most users will not have Acrobat Professional but everyone has Acrobat Reader>><br /><br />var myWillPrintScript = 'for (var i = 0; i < this.numPages; i++){\r'<br />+ 'var aRectangle = this.getPageBox( {nPage: i} ); \r'<br />+ 'aRectangle[1] = aRectangle[3] +14; \r \r'<br />+ 'var fld = this.addField("ComboDatePrint", "text", i, aRectangle ); \r \r'<br />+ 'fld.alignment = "center"; \r'<br />+ 'fld.textSize = 7; \r'<br />+ 'fld.textColor = color.blue; \r'<br />+ 'fld.textFont = font.HelvB; \r'<br />+ 'fld.fillColor = color.white; \r'<br />+ 'fld.readonly = true; \r'<br />+ 'fld.print = true; \r'<br />+ 'fld.display = display.noView; \r \r'<br />+ 'fld.value = "This Document Expires at: " + util.printd("mmmm dd, yyyy",new Date()) + " 11:59 PM"; \r'<br />+ '} \r'<br />this.setAction("WillPrint", myWillPrintScript);<br /><br /><< == FOR ACROABT READERS ===========================><br /><br />for (var i = 0; i < this.numPages; i++) <br /><br />{ <br /><br />var aRectangle = this.getPageBox( {nPage: i} ); <br /><br />aRectangle[1] = aRectangle[3] +14; <br /><br />var fld = this.addField("ComboDatePrint", "text", i, aRectangle ); <br /><br />fld.alignment = "center"; <br /><br />fld.textSize = 7; <br /><br />fld.textColor = color.blue; <br /><br />fld.textFont = font.HelvB; <br /><br />fld.fillColor = color.white; <br /><br />fld.readonly = true; <br /><br />fld.print = true; <br /><br />fld.display = display.noView; <br /><br />} <br /><br /> <br />var myWillPrintScript = 'var fld = this.getField("ComboDatePrint"); fld.value = "This Document Expires at: " + util.printd("mmmm dd, yyyy",new Date()) + " 11:59 PM"; \r' <br /><br />this.setAction("WillPrint", myWillPrintScript); <br /><br /><< == END CODE ========================================== >><br /><br />FYI: How to Write a Batch Process that will process all files in a selected folder and add custom code to each file.<br />==================================================================<br /><br />In Acrobat 8.0 Professional, I clicked on Menu:<br /><br />Advanced --> Document Processing --> Batch Processing<br />-- <Click on New Sequence Button> --> <Choose a name for this sequence: Test><br /><br />In the <Edit Batch Sequence - Test Dialog Box><br />Click on <1. Select Commands> button<br />In the <Edit Sequence Dialog Box><br /> Click on <JavaScript -- Execute JavaScript> from the List box on left side. Then click on the <Add> button. Next click on the <Edit> button. Paste the Code above into the <Create and Edit JavaScripts> text-area and then click on <OK><br />Then Click <OK> to close the <Edit Sequence> dialog box.<br /><br />Next In the <Edit Batch Sequence - Test Dialog Box> <br />Click on <2. Run commands on: Selected Folder - and specify the folder><br /><br />Click on <3. Select output location: In my case I selected Same Folder as Originals><br /><br />Finally click on <Output Options if necessary> then click on <OK><br /><br />Next in the <Batch Sequences Dialog Box> click on the Batch. In this case <test> and then click on <Run Sequence>.<br /><br />That will execute the sequnce.<br /><br /><<The Acrobat Reader code creates a field on each page of the PDF's>><br />To actually see where the Code is that Prints Today's date:<br /><br />1. Open one of the files which was processed using the Batch above.<br />2. Click on <Advanced -- Document Processing -- Set Document Actions> You should see a Green bubble next to the <Document Will Print> document action. Click on Edit to actually see the code when a user goes to print the PDF. In this case it will show:<br /><br />var fld = this.getField("ComboDatePrint"); fld.value = "This Document Expires at: " + util.printd("mmmm dd, yyyy",new Date()) + " 11:59 PM"; <br /><br />3. Click on <OK> to close the JavaScript Editor.<br /><br />Hope someone will benefit from these instructions.<br />Gyan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2008 Jul 02, 2008

Copy link to clipboard

Copied

Steve-
We are using the java script mentioned in this thread. However, we have discovered that the font must be = to an embedded font in the pdf document for the routine to work via an online publisher. We have tried to change the font to Arial or TimesNewRoman which are both embedded fonts in the document. The JS routine will not work after we change the font. Can you help with this?
Thank you,
Judy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 02, 2008 Jul 02, 2008

Copy link to clipboard

Copied

You mean doesn't work online, or at all?
I tried 3 different font changes in a typical document, with no issues. Can you email me the document to test?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2008 Jul 03, 2008

Copy link to clipboard

Copied

Hi Steve-
I haven't gotten it to work off line. Attached are sample documents that we are using to test this. One already has the batch run w/the Helvetica font in the JavaScript which we can't get to change (date test.pdf). The other did not receive the JS routine at all even after we made TimesNewRoman and embedded font. Below is the script we are using:

/* Times New Roman Print Date */

for (var i = 0; i < this.numPages; i++)

{ var aRectangle = this.getPageBox( {nPage: i} );

aRectangle[1] = aRectangle[3] +50;

var fld = this.addField("ComboDatePrint", "text", i, aRectangle );

fld.alignment = "center";

fld.textSize = 8;

fld.textColor = color.black;

fld.textFont = font.TimesNewRoman;

fld.fillColor = color.white;

fld.readonly = true;

fld.print = true;

fld.display = display.visible; }

var myWillPrintScript = 'var fld = this.getField("ComboDatePrint"); fld.value = "PRINT DATE: " + util.printd("mmmm dd, yyyy",new Date()); \r'

this.setAction("WillPrint", myWillPrintScript);

Thank you, Steve, for taking a look at this.

Regards,

Judy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 03, 2008 Jul 03, 2008

Copy link to clipboard

Copied

Ah, confusion. Maybe there is another Steve in the thread? I don't use header/footer scripts: my short script is in a text field (where the font is simply selected rather than written as code), so can't offer any help with this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2008 Jul 03, 2008

Copy link to clipboard

Copied

Thom-
Would you mind taking a look at the last few messages on this thread? I addressed them to Steve Foxall by mistake. Perhaps you would have some knowledge about my java script not working when changing the font. Thanks in advance for your insight.
Judy McKinney

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2008 Jul 03, 2008

Copy link to clipboard

Copied

Hello Judy,
How is the script you posted above being executed? You are reporting an unusal problem so please be specific in how the process proceeds.

Are there any errors reported in the Console Window?

The only way for the font to be causing a problem is if it did not exist at the time the assignment was made. Acrobat instantly embeds a font as soon as it is assigned to a field.
Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2008 Jul 03, 2008

Copy link to clipboard

Copied

Thom-
Here is what was in the console window:

Acrobat Database Connectivity Built-in Functions Version 8.0
Acrobat EScript Built-in Functions Version 8.0
Acrobat Annotations / Collaboration Built-in Functions Version 8.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 8.0
Acrobat Multimedia Version 8.0
Acrobat SOAP 8.0

InvalidSetError: Set not possible, invalid or unknown.
Field.textFont:9:Batch undefined:Exec

InvalidSetError: Set not possible, invalid or unknown.
Field.textFont:9:Batch undefined:Exec

InvalidSetError: Set not possible, invalid or unknown.
Field.textFont:9:Batch undefined:Exec

InvalidSetError: Set not possible, invalid or unknown.
Field.textFont:9:Batch undefined:Exec

After the routine is run, we open the document and print to see if the routine worked. And nothing prints.

I can send a sample document if you think it would help.
Judy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2008 Jul 03, 2008

Copy link to clipboard

Copied

> fld.textFont = font.TimesNewRoman;

font.TimesNewRoman is undefined.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 03, 2008 Jul 03, 2008

Copy link to clipboard

Copied

Check the JavaScript API Reference, "TimesNewRoman" is not the name for use in JavaScript.

The following script works without a problem:

// Times New Roman Print Date //
app.calculate = false; // turn off auto calculate

// add field to each page
for (var i = 0; i < this.numPages; i++) {

var aRectangle = this.getPageBox( {nPage: i} ); // get media box
aRectangle[1] = aRectangle[3] + 50; // set location
var fld = this.addField( {cName: "ComboDatePrint", cFieldType: "text",
nPageNum: i, ocoords: aRectangle} ); // add field
fld.alignment = "center"; // center contents
fld.textSize = 8; // text size
fld.textColor = color.black; // font color
fld.textFont = font.Times; // font name
fld.fillColor = color.white; // fill color
fld.readonly = true; // read only
fld.print = true; // print field
fld.display = display.visible; // display field

} // end for each page

app.calculate = true; // restore auto calculate

// add WillPrint script to populate the form field
this.setAction({cTrigger: "WillPrint",
cScript: "var fld = this.getField(\"ComboDatePrint\"); fld.value = \"PRINT DATE: \" + util.printd(\"mmmm dd, yyyy\",new Date()); \r"});

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 30, 2008 Nov 30, 2008

Copy link to clipboard

Copied

Hi,

How can i do in order to place this text in vertical aligment in the right side of the page?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2008 Nov 30, 2008

Copy link to clipboard

Copied

If you want the text rotated then set the field's "rotation" property.

fld.rotation = 270:

If you want the letters arranged vertically then you can make the fld tall and thin, and set the fild's multiline option.

Either way you'll need to set the field'd position and size for it to display correctly. Look at these articles.

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/page_bounds/

http://www.acrobatusers.com/tutorials/2007/js_add_buttons_to_pdf/

Thom Parker
WindJack Solutions
The source for PDF Scripting Info
pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often
http://www.adobe.com/devnet/acrobat/javascript.html
Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 30, 2008 Nov 30, 2008

Copy link to clipboard

Copied

Hi Thom,

Thank you very much for your support and your quick response. I dont have much experience programming in javascript under Acrobat. After take a look to the links that you have attached, I could rotate and relocate the text in the page, but after run the secuence I realized that in a document with several pages, just the first page shows the text correctly, the other ones are horizontal and out of location. I have pasted below the code with the revisions that I have done according to the articles that you sent me.

Kind Regards.

for (var i = 0; i < this.numPages; i++)

{

var aRectangle = this.getPageBox( {nPage: i} );

aRectangle[0] = aRectangle[2]-14;

var fld = this.addField("ComboDatePrint", "text", i, aRectangle );

fld.alignment = "center";

fld.textSize = 11;

fld.textColor = color.black;

fld.textFont = font.Times;

fld.fillColor = color.white;

fld.rotation = 270;

fld.readonly = true;

fld.print = true;

fld.display = display.noView;

}



var myWillPrintScript = 'var fld = this.getField("ComboDatePrint"); fld.value = "PRINT EXPIRATION: " + util.printd("dd/mm/yyyy h:MM:ss tt",new Date(new Date().getTime()+1000*60*60*24*5)) \r'

this.setAction("WillPrint", myWillPrintScript);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2008 Nov 30, 2008

Copy link to clipboard

Copied

You've done execellent so far!!

The problem is that all of the fields have the same name. They are in essence the same field. The appearance of the field on the page is called a Widget. Anything having to do with the field appearance is a Widget property and only affects the field on a specific page.

The addField function always returns the object for the first widget, even though it creates a new widget. You have to explicitly acquire the widget to set it's properties. And this is done with the widget dot notation.

this.getField("ComboDatePrint.1")

this code acquires the 2nd widget for the "ComboDatePrint" field.

Add this line of code into your script right after the addField()

var fld = this.getField("ComboDatePrint." + i);

I think that should do the trick.

Thom Parker
WindJack Solutions
The source for PDF Scripting Info
pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often
http://www.adobe.com/devnet/acrobat/javascript.html
Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 30, 2008 Nov 30, 2008

Copy link to clipboard

Copied

Hi Thom....Terrific Support!!!!

Great! I have followed your advise and now the document is printed just like I wanted, but I have another issue (I hope the last one).....I have a document with multiple alternates letter/legal pages. The legal pages are in horizontal orientation and the problem is the same like above but only in legal pages, the vertical oriented pages are OK.

Thank you very much for your help!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2008 Dec 01, 2008

Copy link to clipboard

Copied

You can get the page rotation before adding the annotation and put some intelligence into setting the field rotation.

use:
var nRot = this.getPageRotation(i);

Thom Parker
WindJack Solutions
The source for PDF Scripting Info
pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often
http://www.adobe.com/devnet/acrobat/javascript.html
Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2008 Dec 01, 2008

Copy link to clipboard

Copied

Hi Thom,

I try a document with just horizontal oriented pages and I filled the box in black color and the letters in white, and I noticed that box its correctly placed according coordinates, but the text inside the box is rotated. In veritcal pages the text and box are aligned. The getPageRotation method could fix this issue?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2008 Dec 01, 2008

Copy link to clipboard

Copied

Getting the page rotation will tell you how the field needs to be rotated for correctly displaying the text. Give it a try.

Thom Parker
WindJack Solutions
The source for PDF Scripting Info
pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often
http://www.adobe.com/devnet/acrobat/javascript.html
Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2008 Dec 01, 2008

Copy link to clipboard

Copied

Hi Thom,

I am trying with this script in order to diferetiate the horizontal and Vertical pagel, but I get a problem in syntax with the condition if/else

for (var i = 0; i < this.numPages; i++)

{

var rCrop = this.getPageBox("Crop",this.pageNum);

if (rCrop[1] >= rCrop[2]);

var aRectangle = this.getPageBox( {nPage: i} );

aRectangle[0] = aRectangle[2]-14;

var fld = this.addField("ComboDatePrint", "text", i, aRectangle );

var fld = this.getField("ComboDatePrint." + i);

fld.alignment = "center";

fld.textSize = 11;

fld.textColor = color.black;

fld.textFont = font.Times;

fld.fillColor = color.white;

fld.rotation = 270;

fld.readonly = true;

fld.print = true;

fld.display = display.noView;

else if (rCrop[1] < rCrop[2]);

var nRot = this.getPageRotation(i);

var aRectangle = this.getPageBox( {nPage: i} );

aRectangle[1] = aRectangle[3]+14;

var fld = this.addField("ComboDatePrint", "text", i, aRectangle );

var fld = this.getField("ComboDatePrint." + i);

fld.alignment = "center";

fld.textSize = 11;

fld.textColor = color.black;

fld.textFont = font.Times;

fld.fillColor = color.white;

fld.readonly = true;

fld.print = true;

fld.display = display.noView;

}



var myWillPrintScript = 'var fld = this.getField("ComboDatePrint"); fld.value = "EXPIRATION. Vence: " + util.printd("dd/mm/yyyy h:MM:ss tt",new Date(new Date().getTime()+1000*60*60*24*5)) \r'

this.setAction("WillPrint", myWillPrintScript);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2008 Dec 01, 2008

Copy link to clipboard

Copied

The equality operator is "==" not "=", which is the set operator.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2008 Dec 01, 2008

Copy link to clipboard

Copied

I am trying to use >= and < in order to know when the page is horizontal and when is vertical

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines