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

Copy and Paste at a specific time.

New Here ,
Feb 24, 2023 Feb 24, 2023

Copy link to clipboard

Copied

I am looking for help.

I have a headcount form with a counter box at the bottom of the page. I also have 24 smaller boxes below the main counter box. Is there a way to copy the number in the counter box to one of the other boxes at a specific time.

 

ie: at 9:00 am it copies the nimber from coutner box to a specific bow. 

Again at 10:00 am to the next box over in the line of boxes

TOPICS
PDF forms

Views

1.2K

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 ,
Feb 24, 2023 Feb 24, 2023

Copy link to clipboard

Copied

Maybe, if it can be done then a script is required.

All actions in Acrobat and the PDF are triggered by something. If the time is the only trigger, then this will need to be done with an interval timer, and the document will need to be open in Acrobat the entire time.   

 

However, before going down this path I'd suggest walking through all the usage scenarios to make sure you understand how it should work. For example, a copy of this form is opened and the timer is started, the day goes by and all the fields get filled, the form is saved and closed. Days later the form is opened. What happens? Does the existing data get overwritten? Or does the existing form data need to be kept?

 

 

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 ,
Feb 26, 2023 Feb 26, 2023

Copy link to clipboard

Copied

I am trying to copy from the current headcount box to the lower boxes at specific 30 min intervals.top box being on the hour and lower the 1/2.

 

I am not to familiar adobe. Everything in the page I have done good old fashioned hunt and find code then make it work. I just need to know where to go.

Thanks in advance

Rob 

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 ,
Feb 26, 2023 Feb 26, 2023

Copy link to clipboard

Copied

What you are asking for has some complexities that I'm sure you haven't thought about. 

But here's a basic solution.

 

To copy automatically at specific times, you'll need an interval timer. 

There are 3 parts to the solution

1. A document level function to perform the copy

2. A start button, to start the interval timer

3. A stop button, to stop the interval timer.

 

Here's the reference page for the interval timer function

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#setinterval

 

 

1. Put this code in a document script. Change the field names and expand the if structure. 

 

function DoIntervalCopy()
{
   // Get Current time
    var oCurDate = new Date();
    // get base for new time comparisons
    var nYear = oCurDate.getYear() + 1900;
    var nMonth = oCurDate.getYear();
    var nDay = oCurDate.getYear();
    // Compare with last time first, then in decending order
    // 5:30pm
    if(oCurDate >= (new Date(nYear, nMonth,nDay, 17, 30, 0)))
        this.getField("TargetField1").value = this.getField("CounterField").value;
    else if(oCurDate >= (new Date(nYear, nMonth,nDay, 10, 30, 0)))// 10:30am
        this.getField("TargetField2").value = this.getField("CounterField").value;
    else if(oCurDate >= (new Date(nYear, nMonth,nDay, 9, 30, 0))) // 9:30am
    {
        this.getField("TargetField3").value = this.getField("CounterField").value;
        // Since this is the last copy, turn off interval timer
        app.clearInterval(this.oIntTimer);
    }
}
    

 

 

2. Add this code to the MouseUp of the start button

 

// Set interval to run every 60 seconds
this.oIntTimer = app.setInterval("DoIntervalCopy()",60000);

 

 

2. Add this code to the MouseUp of the stop button

 

 


app.clearInterval(this.oIntTimer);

 

 

 

 

 

 

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 ,
Feb 26, 2023 Feb 26, 2023

Copy link to clipboard

Copied

Thank you so much for the info!!!

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 ,
Feb 26, 2023 Feb 26, 2023

Copy link to clipboard

Copied

LATEST

Note that in the code I posted the earliest date is first in the "if" sequence, whereas it should be last. I fixed the code in the previous post.  

 

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