Quantcast
Viewing all articles
Browse latest Browse all 888

Inserting a Date text into a document on several different pages

I need to put an ordinal date phrase in several positions in a document.  I have managed to be able to get it to put the phrase on the top of the first page where I then go along and cut and paste it where I need it.  But what I would like is to run the script and have it insert the text exactly where I want it to go in the document with out manually having to do it. Here is the script I am using which I basically got to work copying and fixing it so I could get an output.  I am running extendscript on Adobe FrameMaker v12

//  INSERTING THE VALUE OF A VARIABLE INTO A DOCUMENT THAT WAS CREATED IN SCRIPT

var m_names = new Array("January", "February", "March",

"April", "May", "June", "July", "August", "September",

"October", "November", "December");

 

 

var date = new Date();

//alert(date)  //shows system date

 

 

var curr_date = date.getDate();

//alert(curr_date)  //shows the day date

var sup = "";

if (curr_date == 1 || curr_date == 21 || curr_date ==31)

   {

   sup = "st";

   }

else if (curr_date == 2 || curr_date == 22)

   {

   sup = "nd";

   }

else if (curr_date == 3 || curr_date == 23)

   {

   sup = "rd";

   }

else

   {

   sup = "th";

   }

 

 

var curr_month = date.getMonth();

//alert(curr_month)  //shows the month

var curr_year = date.getFullYear();

//alert(sup)  //shows the suffix for the ordinal number of the day date

var NewordinalDate="the "+curr_date + sup + " day of "+m_names[curr_month] + ", " + curr_year

//alert(NewordinalDate)  // shows the date phrase of the ordinal day with the date.

//here is an example of the output "the 22nd day of August, 2016 "

var doc= app.ActiveDoc;

var mainflow =doc.MainFlowInDoc;

var tframe=mainflow.FirstTextFrameInFlow;mainflow.FirstTextFrameInFlow;

var pgf = tframe.FirstPgf;

var tLoc=new TextLoc();//Create the text location objet

tLoc.obj=pgf;  //make it a paragraph

tLoc.offset=25;   //insert at the start of the paragraphs

doc.AddText(tLoc,(NewordinalDate)); //insert the variable into the document look at the in parenthasse

//make sure paragraph marker is present on the target page or a lot of object references will be undifined.

 

In most of my documents I need to have a current date variable and this ordinal date phrase which I have to create using the parts of the two current date fields.  The result is I don't have a current date that will update. So I thought to create a script and run it just before printing or sending the documents. Most of these date phrases come in on the last page of the document which can be 15 to 16 pages long. As I have said at the moment this Script will write the phrase of the current system date at the left hand top of the document. Where I usually have a Header in bold so I have to drop that down and assign a normal paragraph tag to it before I run the script or I get Upper case in Bold underlined date phrase.  I really need to learn how to put the add text phrase or any other phrase where ever I want the result to go. In the script above I don't seem to get anything from the  tLoc.offset=    I don't believe this is executing I don't know why there is nothing from it. I have almost zero knowledge about how to script I am just fiddling with javascript premade scripts I have pulled off the internet and got them somehow to get results in Framemaker extend script.   I am amazed at how little there is on anything one actually needs to do Why this date phrase is not a built in variable in FrameMaker leaves me a bit weary.  Why framemaker Doesn't have a built in DBF connectivity is also a mystery I guess it is program created before ODBC

any insight or help with this would be immensely appreciated.


Viewing all articles
Browse latest Browse all 888

Trending Articles



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