Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

Copy Paragraphs from Source files and Paste to Destination File

$
0
0

Hi,

I have a Book with multiple Source files (Source_1, Source_2, ...) and a Destination File. I need to copy all paragraphs from Source files to a global array and finally paste to the Destination file without altering its Paragraph Format.

I tried with below code, it is copying to the array but failing to paste at Destination file. Please suggest.

 

var book = app.ActiveBook;

var Data = [] ;

if(!book.ObjectValid())

{

    book = app.FirstOpenBook;

}

if(book.ObjectValid())

{

    app.ActiveBook = book;

    var pgf, pgf1, doc, SrcDoc, DstDoc, index, lastPgf, i ;

    var comp = book.FirstComponentInBook;

    while(comp.ObjectValid()) // Book loop to push all paragraphs from Source files

    {

         doc = OpenFile(comp.Name); // Have function to Open File

         if (doc.Name.match ("Source"))

         {

            SrcDoc = doc;

            pgf = SrcDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

            while (pgf.ObjectValid())

            {

                Data.push(pgf);    

                pgf = pgf.NextPgfInFlow;

            }

        }

        comp = comp.NextBookComponentInDFSOrder;

    }

    comp = book.FirstComponentInBook;

    while(comp.ObjectValid()) // Book loop to find Destimnation file

    {

        doc = OpenFile(comp.Name);

        if (doc.Name.match ("Destination"))

        {

            DstDoc = doc;

            lastPgf = DstDoc.MainFlowInDoc.FirstTextFrameInFlow.LastPgf;

            pgf = DstDoc.NewSeriesPgf (lastPgf);

            tRange = new TextRange; 

            index = Data.length; 

            for (i = 0;  i < index; i++) // Loop to add all pushed paragraphs to Destimnation file

            {

                pgf1 = Data[i]; 

                tRange.beg.obj = pgf1; 

                tRange.beg.offset = 0; 

                tRange.end.obj = pgf1; 

                tRange.end.offset = Constants.FV_OBJ_END_OFFSET; 

                DstDoc.TextSelection = tRange;  

                PushClipboard ();

                DstDoc.Copy (0);

                textLoc = new TextLoc (pgf, 0);

                textRange = new TextRange (textLoc, textLoc);

                DstDoc.TextSelection = textRange;

                DstDoc.Paste ();

                PopClipboard ();

            }

            break;

        }

        comp = comp.NextBookComponentInDFSOrder;

    }

}


Viewing all articles
Browse latest Browse all 888

Trending Articles



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