Skip to main content
Participating Frequently
July 19, 2019
Answered

Copy entire page with textframe at the end of pasted document

  • July 19, 2019
  • 1 reply
  • 473 views

Hi, in this topic:

Copy whole page to another document when textFrame exist

We covered a lot, but there is one major problem with that script

Lets say:

"Tree" TextFrame is on page - 6

"Apple" TextFrame is on page - 11

"Mango "TextFrame is on page - 43

So after selecting Tree Apple Mango, pages are duplicated but in the copied document they are on the same pages... Can they be copied at the end of document no matter how many pages document has?. If copierd document doesnt have these pages, ERROR

var dialog = new Window("dialog");  

        dialog.text = "Dialog";  

        dialog.preferredSize.width = 54;  

        dialog.preferredSize.height = 53;  

        dialog.orientation = "column";  

        dialog.alignChildren = ["left","top"];  

        dialog.spacing = 14;  

        dialog.margins = 36;  

    var panel1 = dialog.add("panel");  

        panel1.text = "Select Text";  

        panel1.preferredSize.width = 134;  

        panel1.orientation = "column";  

        panel1.alignChildren = ["left","center"];  

        panel1.spacing = 10;  

        panel1.margins = 18;  

        panel1.alignment = ["left","top"];  

    var statictext1 = panel1.add("statictext");  

        statictext1.text = "Include Texts";  

    var checkbox1 = panel1.add("checkbox");  

        checkbox1.text = "Tree";    

    var checkbox2 = panel1.add("checkbox"); 

        checkbox2.text = "Apple";

    var checkbox3 = panel1.add("checkbox");  

        checkbox3.text = "Mango";

    var group1 = dialog.add("group");  

        group1.orientation = "row";  

        group1.alignChildren = ["left","center"];  

        group1.spacing = 10;  

        group1.margins = 0;  

    var Ok = group1.add("button");  

        Ok.text = "Ok";  

        Ok.justify = "center";  

    var Cancel = group1.add("button");  

        Cancel.text = "Cancel";  

        Cancel.justify = "center";  

    ////// 

    if(dialog.show() == 1){ 

        var tmpArr = []; 

        for(var x = 0; x < panel1.children.length; x++){ 

            if(panel1.children.constructor.name.toLowerCase() == "checkbox"){ 

                if(panel1.children.value){ 

                    tmpArr.push(panel1.children.text.toString()); 

                    } 

                } 

            } 

        if(tmpArr.length > 0){ 

            /// here 

            process(tmpArr); 

            } 

        else{ 

            alert ("No text included", "", true) 

            } 

        } 

PS: Thanks Sunil Yadav for previous work

This topic has been closed for replies.
Correct answer Sunil Yadav

Then you can try replace this line:(line number 80 Re: Copy whole page to another document when textFrame exist )

frames.parentPage.duplicate(LocationOptions.BEFORE, doc2.pages[frames.parentPage.documentOffset]);

with this line:

This will duplicate your page at the end only:

frames.parentPage.duplicate(LocationOptions.AFTER, doc2.pages[doc2.pages.length-1);

You just need to play with the page before or after which page you are going to duplicate it.

Play with page index only and location options.

Best

Sunil

1 reply

Sunil Yadav
Sunil YadavCorrect answer
Legend
July 19, 2019

Then you can try replace this line:(line number 80 Re: Copy whole page to another document when textFrame exist )

frames.parentPage.duplicate(LocationOptions.BEFORE, doc2.pages[frames.parentPage.documentOffset]);

with this line:

This will duplicate your page at the end only:

frames.parentPage.duplicate(LocationOptions.AFTER, doc2.pages[doc2.pages.length-1);

You just need to play with the page before or after which page you are going to duplicate it.

Play with page index only and location options.

Best

Sunil

Participating Frequently
July 19, 2019

Thank you! works! best!