[CS 5.5] [JS] copy a graphic page between documents element

Hi, I'm still learning script and am struggling with what is probably a simple problem to someone more knowledgeable. The task is to copy the text & chart of a few pages of a document from one to the other based on a similar model. The block of text and graphic blocks are named. I was able to get the part of the text, but I'm stuck on how to address them - stick in a graphic block.

At this point, I got the graph to copy, but it does not quite work because the duplicate method allows only a table of 2 units, fattening, Page or layer target and source document positions are slightly different, and copy the chart only leaves out necessary style of the frame. I really want to stick it in the page element, but differs from the method for duplication of text. Tips to approach this? Should I instead to select the graphic and paste it into the new document? How I would achieve the equivalent of sticking in there?

A snippet of my code so far:

var docPages = docRef.pages.everyItem().getElements();
var cemwpsP1 = 3;
var newWPS = createWPS(templatePath, wpsTemplateName, wpsFileName, wpsSaveFolder);
var graphsRE = new RegExp (/graph/i);
var textsRE = new RegExp (/body|chart/i);

var srcPage = docPages[cemwpsP1];
var wpsPage = newWPS.pages[0];
for (i = srcPage.pageItems.length -1; i >=0; i--) {
 var pi = srcPage.pageItems[i];
 if ( pi.name.match(textsRE) ) {
 // copy the text element
 pi.texts[0].duplicate(LocationOptions.AT_BEGINNING, wpsPage.pageItems.itemByName(pi.name)); 
 }
 if ( pi.name.match(graphsRE) ) {
 // it's a graphic element
 // still stumped here! only copies to to the same coordinates on the new page...
 pi.allGraphics.duplicate(wpsPage);
 }
}

OK, if anyone is interested, I solved it by copying the graphic dimensions of empty graphic images of the model, and then nuking replacing them with a chart double. This technique works for all elements of the page are appointed in the same way on the source and target pages.

// step through page items on each page, checking item name matches as set in graphsRE & textsRE above & moving over to the new pages
var srcPage = docPages[cemwpsP1];
var wpsPage = newWPS.pages[0];
for (i = srcPage.pageItems.length -1; i >=0; i--) {
    var pi = srcPage.pageItems[i];
    if ( pi.name.match(textsRE) ) {
        // it's a textual element, either ta.wpsFrameName or ta.wpsChartFrameName
        pi.texts[0].duplicate(LocationOptions.AT_BEGINNING, wpsPage.pageItems.itemByName(pi.name));
    }
    if ( pi.name.match(graphsRE) ) {
        // it's a graphic element, and should only contain one graphic
        // since ID doesn't allow copying into frames (or I never found how)
        // get its matching info from the wps template
        wpsBounds = wpsPage.pageItems.itemByName(pi.name).geometricBounds;
        wpsObjStyle = wpsPage.pageItems.itemByName(pi.name).appliedObjectStyle;
        // kill the original & duplicate the graphic to wps
        wpsPage.pageItems.itemByName(pi.name).remove();
        pi.allGraphics[0].duplicate(wpsPage);
        // get a reference to the newly placed graphic; it'll be the only nameless one, as they are all named on the template
        for (g = wpsPage.pageItems.length -1; g >=0; g--) {
            if ( wpsPage.pageItems[g].name == "" ) {
                gfc = wpsPage.pageItems[g];
            }
        }
        // name, size and style
        gfc.name = pi.name;
        gfc.geometricBounds = wpsBounds;
        gfc.appliedObjectStyle = wpsObjStyle;
    }

Tags: InDesign

Similar Questions

  • Copy master pages between documents.

    I'm carrying a book with chapters 36 and I formatted my template and finished a chapter.  Chapter 2 is a new document and I want to carry on A master to each successive.  I think there must be a way to do it, but nothing I've tried works.  I use Windows 7 and InDesign 5.5, version 7.5.

    Make a blank template with your master pages and styles file, then use it to make the chapter files.

  • Copy blocks of text between documents

    I have two documents which have the same number of pages. I want to write a script to copy blocks of text on each page of the document source to the corresponding page in the target document. There is usually only a single block of text on each page, and I want it placed exactly the same in the target as the source. I tried the following:

    for (var i = 0; i < fromDoc.pages.length; i ++) {}

    for (var j = 0; j < fromDoc.pages [i].textFrames.length; j ++) {}

    var fromTextFrame = fromDoc.pages [i] .textFrames [j];

    App.Select (fromTextFrame);

    App.Copy ();

    toPage var = toDoc.pages [i];

    App.Select (toPage);

    App.Paste ();

    }

    }

    It gives me an error on the statement of app.copy: "Cannot copy/cut because of invalid selection."

    Can someone help me with the right code? That the ks!

    Sorry - it's a bug in the forum software that is sometimes

    submitted by email do not appear. What I said is:

    You should avoid the use of copy(), paste() etc. - There is almost always a

    best way to do things.

    In this case, see the duplicate of a textFrame method:

    TextFrame.duplicate (for: varies by: table of unit of measure (number or))

    String)): PageItem

    Adobe InDesign CS6 (8,0) Object Model

    Duplicates the TextFrame to the location specified or offset.

    of: Data Type: varies

    The location of the new TextFrame, in coordinates specified in the

    format. Can accept: table of 2 units, spread, Page or layer.

    (Optional)

    by: Data Type: table of unit of measure (number or string)

    Amount to compensate for the new original TextFrame

    TextFrame position. (Optional)

    You can see that the setting 'to' duplicate() accepts various

    things, which seems to be what you are looking for: page.

    So if you set myPage to a page in a second document, likely to be you

    will find that it has been reproduced on this page:

    myTextFrame.duplicate (myPage)

    Try and see how the text block lands facing upward.

    If this isn't in the right place, I suggest to copy the

    the source for the new textFrame textFrame geometricBounds (he can be)

    have other ways to do it). Just ensure that the origin of the rule and

    units of measure in the two documents are the same.

    HTH,

    Ariel

  • Move pages between documents without synchronization with master?

    I want to combine two indesign files using 'move page', but it synchronizes them with the captain in the new document. I released most of the objects on the master pages, but I like to keep editable parts so making them in empty master pages until synchronization is not an option. Is there a way?

    I would rename the master in one of the docs. When you move pages, pages from masters of the same name will use the master page of the destination file, but if they are based on different names of masters the missing master page will be added to the destination. If you do this there is no need to override anything.

  • bind the pages between documents (is it possible?) CS6

    I acquired the task at my new job of recasting of the operators manuals and parts lists. I know a little bit in indesign, we can say more than the average. (I learn everyday more and more). But on my question as stated above. Is this possible?

    I made models for the manuals I've created, but I always find myself change one aspect of design on a page or two and trying to keep everything looking nice and uniform, that I have to open each and make the same changes to match. Although I get manuals more again, opening and changes to all these documents Gets a little intimidating and monotonous. Now I like say my back cover page for example who don't exchange any document for the document, is there a way to link it to all the other blankets back so that if I change something on a that it changes all the back covers all related documents?

    Also I can be me going but I have a few pages where all that is deferred like a few words (I like to consider as variables) such as the name of the product manual to address. If its possible to link the pages it would be possible to say ID to "ignore" a piece of text say inbetween two sets of characters? IE: "it's the best" (variable) "in the world".

    I can just dream but if theres a function or tool that everyone knows (or even a script, a person brought) please feel free to share it with me!

    Thanks for your time!

    Well, for your No. 2 question, Yes, there are a text variables in InDesign that do exactly what you ask. Type menu->-> set text Variables.

    For question No. 1: you can place an InDesign document to another as an image, so if you have identical pages, you can place this way. If you need text content are identical, but the presentation format for change, I would say now your text in Word or Google Docs and looking in WordFlow or DocsFlow from Em Software. Finally, the more complicated, less use-able is to include your documents in a book file to use Sync Master Pages causes changes in a master page in waterfall to your other files.

    You can get a lot fancier with Q No 1, in the form of structured writing, content management systems, and so on, but I think that place the InDesign files in other InDesign files pretty much exactly what you're looking for.

  • pop-up menu displays a small copy of the page

    pop-up menu displays a small copy of the page

    screenshot: https://drive.google.com/file/d/0B0WFSu8N2MiEVWZZajZxeDVUcXc/edit?usp=sharing

    Hello

    Try Firefox Safe mode to see if the problem goes away. Safe mode is a troubleshooting mode, which disables most of the modules.

    (If you use it, switch to the default theme).

    • Under Windows, you can open Firefox 4.0 + in Safe Mode holding the key SHIFT key when you open the desktop Firefox or shortcut in the start menu.
    • On Mac, you can open Firefox 4.0 + in Safe Mode holding the key option key when starting Firefox.
    • Under Linux, you can open Firefox 4.0 + with leaving Firefox then go to your Terminal and running Safe Mode: firefox-safe-mode (you may need to specify the installation path of Firefox for example/usr/lib/firefox)
    • Or open the Help menu and click on the restart with the disabled... modules menu item while Firefox is running.

    Once you get the pop-up, simply select "" boot mode safe. "

    If the issue is not present in Firefox Safe Mode, your problem is probably caused by an extension, and you need to understand that one. To do this, please follow article Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems .

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.

    When find you what is causing your problems, please let us know. It might help others who have the same problem.

    Thank you.

  • Copy the Web page address

    How to copy a Web page address in the Google app on my compact z3

    Hello

    It's Google Chrome that you use or what soft do you mean Google? If it's Chrome you should be able to copy the URL by registering once on and he'll get marked > now double tap the URL (when it is marked) and you'll have the icons of cut/copy.

  • When I press OK on my 4280 printer to copy the alignment page, it shows "paper"? Nothing prints.

    All-in-one printer, HP Photosmart 4200

    Windows Vista 32-bit

    When I press OK on my 4280 printer to copy the alignment page, it shows "paper"? Nothing prints.

    Thank you very much for your answer. As suggested, I tried the hard reset nothing helps. Since then, my printer has me faithfully helped the last 4 years, I thought that it is preferable to ask for rest & buy another HP printer. I am proud to say, I am very pleased. Thanks Shane.

  • Hi, I can not paste the copied text of pages for Adobe applications, why is this? I have can´t even paste text in InDesign...

    Hi, I can not paste the copied text of pages for Adobe applications, why is this? I have can´t even paste text in InDesign...

    Duplicate thread: I can´t paste the copied text in any application adobe... InDesign, Photoshop, Prime Minister...

  • I document for which the security of the document does not allow me to assemble documents, copy of content, page extraction, form filling, signature &amp; creating the model. Buy adobe acrobat won't solve all?

    I document for which the security of the document does not allow me to assemble documents, copy of content, page extraction, form filling, signature & creating the model. Buy adobe acrobat won't solve all?

    The result is that Adobe does not provide any software to defeat the security of a PDF file. If the creator of the PDF file set to this level of security, intentionally or not, that's what it is! The solution to your problem is to go to the creator of the document and ask the password or an unprotected PDF file version.

    -Dov

  • Copy and paste pages

    Hello

    Any suggestions help!

    I created a website with different products. Two other company sells the same products if I still do a lot of pages / products for the second company (all inside my web)

    As Muse allow copy and paste pages or a group of pages how can I manage to not do once again that hard work, as well as modify master pages (logos and so forth)

    Any idea to save the first page "save under" and start a new folder?

    Any idea / suggestion appreciatted

    Jose Felix

    Muse supports slide it / move, in order to open the two pages where you transfer the content, and the other where the content will be transferred, and then you can drag the content.

    Thank you

    Sanjit

  • copy of a page of dashboard

    Hello

    Is it possible to create a copy of a page of dashboard in obiee 10g?

    Thank you

    Yes, 2 optios
    -Use the option manage Presentation catalog and go to the corresponding page, select copy/move, copy on my dashboard, change the name of the page and then copy on the Original dashboard. As BI is not smart enough to use the same name of the page
    OR
    -Try the method described above using Catalog Manager

  • I can copy a Master Page from one document to another?

    HI - it is perhaps a fundamental issue, but I did not yet understand the answer. I have a site .muse with a Master Page that I used... I want to use the same Master Page on another .muse site that I'm working on. Is there a way I can copy the Master Page of the site ended up in it that I work? Any help is appreciated.

    Thank you

    Blair

    Hey Blair,

    You should be able to do by simply selecting (Ctrl + A) and copy (Ctrl + C) all content from the page master of the Site1 and paste in Place (Ctrl + Alt + Shift + V) into the master page of Site2.

    Thank you

    Vinayak

  • Copy of dashboard Page

    Hello
    Is it possible to copy the dashboard Page? If Yes please let me know.

    Rahul-

    Hello Rahul,
    Yes you can the dashboard page

    (1) first of all open the catalog using the Catalog Manager and open it in any mode(offline/Online)

    (2) the way _portal search you can find your dashboard and the respective pages...

    (3) copy files (attribute) .atr and folder in the address bar you can find the location as

    The catalog path : samplesales\root\shared\sample + sales\_portal

    (4) and then return to your installed obiee drive (path OracleBIData\web\catalog\sampelsalees\...your)

    so that you can copy what ever you want

    Note:you can directly follow step 4 (but to get a clear understanding of the concept of track 1-3Steps)

    Thank you
    saichand.v

  • HR 2015 crashes when you import a 420-page Word document

    Hi all

    I have a manual which has more than 400 pages, his style is really simple and unique to each page. Yet everytime I try to import it into Robohelp slows down and stay a long time, then stops working.

    I tried the same thing with the PDF version of the document, but it also hangs.

    Is this a general problem with Robohelp and long Word and PDF files or what exactly?

    HR 2015 has worked well when I imported a Word 63 page document, so I was wondering if it is possible to divide a document this size in several pieces and put them then with the same table of contents, and how can I do this effectively?

    Thank you very much in advance!

    A

    It should not fail. I tried before to import the 500-page document, and it works fine. I met only error when I tried to import using our model. So, I copy everything to a new document and then I continue in import. Try to copy your content into another document, and then click Edit in HR to parse the file.

Maybe you are looking for