[basiljs] remove all pages except one

In a script, I create pages, export to PDF, remove pages and then create a new etc.

Right now I use this:

[code]

for (var j = b.pageCount (); j > 1; j-) {}

b.removePage (j);

}

[/ code]

But it's really slow. I think that indesign made many calculation after deleting a page (deadline: link textfields) so it would be more efficient to remove all pages at once.

Now my question is how do?

I tested and if I delete about 5500 empty pages with the script it takes about 8 minutes.

If I select all in indesign, and then delete it takes about 10 seconds.

Another way to speed up a litle is to erase all the content. It will take a long time but probably a bit faster.

Thing is that I have

b.Clear (b.doc ());

but this removes the master page as well and I need to keep the master page.

In short, how to remove all pages (except one since indesign needs a single page) at the same time?

Hello

I will remove a lot of pages in indesign with

  • Use documentPreferences.pagesPerDocument (faster)
  • use while loop or for
  • Close doc without saving changes, and then open again. (in some cases)

Here's the test code, run with old Macbook Air + CS5 + OSX10.7

var pp = function (args) {
  $.writeln(args);
}

var remove_all_pages_use_pref = function (doc) {
  pp("start deleting (use preferences)");
  $.hiresTimer;
  doc.documentPreferences.pagesPerDocument = 1;
  pp("end deleting");
  pp($.hiresTimer);
}

var remove_all_pages_use_loop = function (doc) {
  var i = doc.pages.length;
  pp("start deleting (while --)");
  $.hiresTimer;

  while (i--) {
    if (i==1) {break;}
    doc.pages[i].remove();
  }
  pp("end deleting");
  pp($.hiresTimer);
}

function main() {
  var doc = app.documents.add();
  $.hiresTimer;
  doc.documentPreferences.pagesPerDocument = 5500;
  pp('# create 5500 pages');
  pp($.hiresTimer);
  var indd = new File("~/Desktop/5500.indd");
  doc.save(indd);

  pp("------------");
  remove_all_pages_use_pref(doc);
  doc.close(SaveOptions.NO);

  pp("------------");
  pp("# try another way");
  var doc2 = app.open(indd);
  remove_all_pages_use_loop(doc2);
  doc2.close(SaveOptions.NO);
}
main();

result

# create 5500 pages
30395026
------------
start deleting (use preferences)
end deleting
28215999
------------
# try another way
start deleting (while --)
end deleting
268641063

Thank you

mg

Tags: InDesign

Similar Questions

  • Removes all characters except numbers

    Hi all

    I want to reformat to following phone numbers. As you can see it in what follows, I want to delete all characters except numbers and it does not start wirh 0 0 at the beginning of the f-number. And the length is 11. What do you recommend?

    (543) 456-35-50 = > 05434563550

    (555) 555-55-55 = > 05555555555

    (210) 111-11 / 11 = > 02101111111

    Thank you

    Hello

    3018678 wrote:

    Hi all

    I want to reformat to following phone numbers. As you can see it in what follows, I want to delete all characters except numbers and it does not start wirh 0 0 at the beginning of the f-number. And the length is 11. What do you recommend?

    (543) 456-35-50-online 05434563550

    (555) 555-55-55-online 05555555555

    111-11 / 11 (210)-online 02101111111

    Thank you

    To remove all characters except the 10 digits, you can use REGEXP_REPLACE

    REGEXP_REPLACE (str, '\D')

    To put a "0" at the beginning of the string (if it isn't already begin with a '0'), you can use REGEXP_REPLACE even once:

    REGEXP_REPLACE (REGEXP_REPLACE (str, '\D')

    , '^([^0])'

    , "0\1".

    )

    I don't think that there is a way to do both things wih a single integrated function call.

    There is a requirement on the length being 11?  What happens if that comes into conflict with one of the other requirements?  For example, if the string is already long of 11 characters, but does not begin with a '0', do you want to add a "0", which makes 12 characters?  What happens if the length, after removing the numbers no, is very small, say 1?  (You can use LPAD adds however many ' 0 s you need.)  If the length (after removing the numbers) is 12 or more?  What happens if the string does not contain any what numbers at all?

    If these things are questions, then post CREATE TABLE and INSERT statements for some examples of data, accurate results, you want that data, and explanations.

    Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

  • clear all items except one

    Hello all,.

    Can someone tell me how can I create a process that erases all the elements of a page except one Singel. I don't want a list of all the items on the process. Thanks in advance.

    I use Apex V4



    Zeng

    What is

    DECLARE
      lc_item_name VARCHAR2 := ''; --Name of the Item
      lc_item_value VARCHAR2;
    BEGIN
      --Get the Value of Special Item from Session
      lc_item_value := v(lc_item_name);
      --Clear the Page Cache
      APEX_UTIL.CLEAR_PAGE_CACHE (p_page => );  --Use the page whose cache has to be cleared
    
      --Set the session state of the item once again
      APEX_UTIL.SET_SESSION_STATE (p_name     => lc_item_name
                                                       ,p_value      => lc_item_value
                                                       );
    
    END;
    

    Alternatively, if the same thing using a branch that clears the cache of the page and in the section of item value, specify the name of the item in the to and from fields.

  • Cannot print continue on all pages except the last page in the xml editor

    I designed a model that prints continues on all pages except the last page in my xml report. Currently, it works very well when the report has two continuous pages prints the first page and last page prints my footer which is exactly my requirement. But if the release of the report is more that continue to two pages, that prints the first page and last page prints my footer but in the pages of the Middle continue is not printed

    Can someone help me with this problem. Its urgent

    Thank you

    Neednt have you checked.
    If you have inserted a front section break , and then click the new section and remove "link to the previous.

    This will ensure that you will have the same header/foot in all but the last page.

    See the user guide
    http://download.Oracle.com/docs/CD/E10415_01/doc/bi.1013/e12187/T421739T481157.htm#4535357

  • How to properly temporarily disable all channels except one in the multichannel PID control loop?

    Hi all

    Help me please to solve the problem. How to correctly temporarily disable/enable all channels except one in the multichannel PID control loop?

    Thanks in advance,

    Oleg

    Hi Oleg,

    the entry "Car?" of the AdvancedPID is a table – as well as MS and pv entries.

    So what's the problem say - / allowing for a control (aka of entry) instead of all loop?

  • clear the cache of full page except one

    I need to reset the whole page (clear your cache), except one. How are you? I try not to go out all the items in the list. Can you help me?

    Thank you.

    WAN

    Hello

    You can try this kind process

    DECLARE
      l_temp VARCHAR2(32000);
    BEGIN
      l_temp := :Px_YOUR_ITEM;
      APEX_UTIL.CLEAR_PAGE_CACHE ('YOUR_PAGE_NUMBER');
      :Px_YOUR_ITEM := l_temp;
    END;
    

    Replace Px_YOUR_ITEM and YOUR_PAGE_NUMBER according to your need

    BR, JAri

  • userChrome.CSS - remove all toolbars except front/rear, refresh and home

    I need to configure firefox in almost-kiosk mode. I want to disable all toolbars except for the "back" button, next button, refresh and home buttons.

    I did find something that allows you to hide the bookmarks toolbar. And if I keep at the entrance of #urlbar, front and rear buttons appear, but do not work (they're grayed out)?

    That's what I have so far:

    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */
    #searchbar {
    	display: none;
    }
    #main-menubar  {
    	display: none;
    }
    #urlbar  {
      display: none;
    }

    You can hide the Bookmarks Toolbar window and customize with these identifiers:

    #PersonalToolbar { display:none!important; }
    #CustomizeToolbarWindow { display:none!important; }
    

    ID #personal - brand - pages is for the bookmarks toolbar item that can be placed on a toolbar through the window customize.

    Try to drag the URL bar and search and other items that you hide in the toolbar palette.

    It seems in the history of the button B/F run after a reboot.

    It is usually best to use the DOM Inspector to get the ID or class of items of toolbar names.

  • Remove all lines except 10 random lines

    Hello

    How to remove all the lines in the JOBS table except 10 lines at random?

    Someone asked him before (not here...): http://stackoverflow.com/questions/10820105/t-sql-delete-except-top-1

    but I didn't get the answer, and I don't think it will work in PL/SQL.

    If the answer to StackOverflow's works in PL/SQL, I will be happy if someone explains me with a better example.

    If the answer to StackOverflow does'nt work in PL/SQL, I will be happy if somebody give me an example.

    Thank you!

    Try this

    delete from jobs where rowid not in (select rowid from jobs where rownum <= 10)
    
  • [BUG]? SelectOneChoice ValueChangeListener works for all elements except one

    Hello


    I have a SelectOneChoice that displays a warning in different languages.

    I have a LOV to select and an input field to display the warning.

    Everything works to display the following warning language except for the first choice in the SelectOneChoice.

    Here is the method in my bean
        public void languageSelectOne_valueChanged(ValueChangeEvent valueChangeEvent)
        {
         //Update the model
         this.setValueToEL("#{bindings.PageLanguage.inputValue}",
                     valueChangeEvent.getNewValue()); 
         log.info("Selected Value: " +
               JSFUtils.resolveExpression("#{bindings.PageLanguage.attributeValue}"));
         log.info("Display Value: " +
               JSFUtils.resolveExpression("#{bindings.PageLanguage.selectedValue ne ' ' ? bindings.PageLanguage.selectedValue.attributeValues[0] : ''}"));
    
         BindingContainer bindings = ADFUtils.getBindingContainer();
         DCIteratorBinding iter =
                 (DCIteratorBinding) bindings.get("DisclaimerIterator");
         ViewObject disclaimerVo = iter.getViewObject();
         Integer langChosen =
                 Integer.parseInt((String) JSFUtils.resolveExpression("#{bindings.PageLanguage.attributeValue}"));
         Object[] keys = new Object[1];
         keys[0] = langChosen;
         Row[] disclaimerRow = disclaimerVo.findByKey(new Key(keys), -1);
         log.info("Rows returned: " + disclaimerRow.length);
         BlobDomain languageText =
                 (BlobDomain) disclaimerRow[0].getAttribute("PageText");
         log.info("Page Text length: " + languageText.getLength());
         try
         {
             log.info(new String(languageText.getBytes(1,
                                        (int) languageText.getLength()),
                        "UTF-8"));
             this.getDisclaimerText().setValue(new String(
                                  languageText.getBytes
                                  (1,
                                  (int) languageText.getLength()
                                   ),"UTF-8"));
             this.getLangChoice().setLabel((String)disclaimerRow[0].getAttribute("ChooseLanguageText"));
             this.getDisclaimerButton().setText((String) disclaimerRow[0].getAttribute("AgreeButtonText"));
         }
         catch (JboException jboe)
         {
             log.severe(jboe.getMessage());
    
         }
         catch (Exception e)
         {
             log.severe(e.getMessage());
    
         }
         AdfFacesContext.getCurrentInstance().addPartialTarget(getDisclaimerText());
         AdfFacesContext.getCurrentInstance().addPartialTarget(getLangChoice());
         AdfFacesContext.getCurrentInstance().addPartialTarget(getDisclaimerButton());
    
    
        }
    Here's the LOV
    SELECT 
        EPSS_WELCOME_PAGE.PAGE_LANGUAGE PAGE_LANGUAGE, 
        EPSS_WELCOME_PAGE.PAGE_ID PAGE_ID,
    EPSS_WELCOME_PAGE.PAGE_DEFAULT
    FROM 
        EPSS_WELCOME_PAGE
    And here is the VO
    SELECT EpssWelcomePageEO.PAGE_ID, 
           EpssWelcomePageEO.PAGE_LANGUAGE, 
           EpssWelcomePageEO.PAGE_TEXT, 
           EpssWelcomePageEO.PAGE_DEFAULT, 
           EpssWelcomePageEO.CHOOSE_LANGUAGE_TEXT, 
           EpssWelcomePageEO.AGREE_BUTTON_TEXT
    FROM EPSS_WELCOME_PAGE EpssWelcomePageEO
    ORDER BY PAGE_DEFAULT DESC, PAGE_LANGUAGE
    I have a beforePhase method that set the SelectOneChoice to the first element in the list
        // Before Phase method to set the default language in the selectOneChoice
        public void defaultSelectionOnLoad(PhaseEvent phaseEvent)
        {
         RichSelectOneChoice soc;
         soc =
           (RichSelectOneChoice) JSFUtils.findComponentInRoot("langChoice");
         if (soc != null && soc.getValue() == null)
             soc.setValue(new Integer(0));
        }
    The default language is English.

    The first time the page is rendered, the warning in English and the selectOneChoice is IN.
    I choose different languages in the list and everything works as expected. Then I try to display again the English version, and the newspaper returns a zero on the next line
             log.info(new String(languageText.getBytes(1,
                                        (int) languageText.getLength()),
                        "UTF-8"));
    Even if the length of the LOB is equal to 1475 characters

    Now if I change the ranking in my query the native language is Bulgarian.
    The warning is made correctly, switching between languages, and then re - click the first choice (Bulgarian) returns a null value for the waiver.

    The problem has something to do with the first choice in the list.

    Thanks a lot for your help.

    Kind regards
    Senecaux

    Published by: Stessy.Delcroix on June 1, 2011 14:33

    The ValueChangeListener does not fire when the value is back to the original value. It's expected behaviour (i.e. it is how the JSF engine is designed and implemented) and is not a bug. Take a look at Chris Muir comments in these threads:

    {: identifier of the thread = 1098626}
    {: identifier of the thread = 1010102}

    Dimitar

  • Connect all bookmarks except one (all turns and says connection...), why it won't work?

    My Bookmark American Express never works. The location is the same, we found by Google (https://online.americanexpress.com/myca/logon/us/action?request_type=LogonHandler & Face = en_US). I tried to rename, deletion/recreation and different locations (toolbar and files). Don't just connect. Each bookmark else I created works very well. It's so frustrating.

    When I type this link earlier, I got a page that says that "our system is not responding."

    What happens if you try to go through the home page? https://www.americanexpress.com/

  • Computer connects to the Internet on all networks, except one

    A few days ago my computer stopped at random to connect to the internet via an Ethernet cable in my apartment.  It works very well, continuously for more than a year.  I first thought the network was down, but to verify ports three separate wall in our apartment (including the one in question) computer of my roommate and his computer connected perfectly.

    My computer can still connect to other networks (different buildings) both via radio and connected via Ethernet, if this isn't a hardware problem.  Currently, we have a wireless router configuration in our apartment that my computer can connect to.  For some reason when I am connected to the network via an Ethernet cable, the computer cannot access the internet.
    When connected, the State jumps back between "Internet access" and "no Internet access.  I tried to ping www.google.com and several other IPs known without success.  Works fine when I go wireless.
    I tried the following, without success:
    Reinstalled drivers for network cards
    Reset the network settings
    Reset Windows sockets
    Enabled IPv4 and IPv6
    Add favorite DNS servers (google and a few others)
    Restart
    System restore
    If anyone has any ideas, I can provide more information, if it helps...
    Thank you

    The problem was somewhat resolved.  When the connection to the Local network has been filled with the wireless network connection, the Internet took over.  I unplugged the router wireless and internet still works, so I'll consider it a success so far.

  • A document of several pages and the need to remove all other pages.  Document to wholesale remove each page separately.

    I have a multi page document (1, thousands of pages) and you need to delete all the other pages.  I can't understand how to do this and I know it's doable.  I haven't the time to delete this one page at a time.  Help, please.

    If you have Adobe Acrobat DC Pro, you can create a custom command using the following JavaScript code to remove all pages:

    // process document from the last page to the first page
    for (var i = this.numPages-1; i>=0; i--) {
        if (i % 2) { // this will delete all even numbered pages
            this.deletePages(i);
        }
    }
    

    To find out how you can create a custom command, follow the steps detailed here: create orders customized in Adobe Acrobat DC Pro - KHKonsulting LLC

    If you want to remove all odd numbered pages, simply change the line #3 to this:

    if (!(i % 2)) { // this will delete all odd numbered pages
    

    If you use an earlier version of Acrobat Pro, you can use an Action to accomplish the same thing. If you use Adobe Acrobat Standard, you do not have access to the action Wizard or custom orders, and you have to write a script of folder level to create a new menu item that can remove odd or even numbered pages.

  • Resize all pages in a PDF to the same dimensions (height, width)

    I have a big PDF file of several hundred pages in which all the pages have slightly different dimensions. I want to resize these pages in such a way that they will all have the same dimensions. I tried to do it with the crop in Acrobat tool, but if I get all pages in one fell swoop, the resulting dimensions of the page will always be the same for all pages. I can't get page dimensions the same if I harvest each page separately, which is not really fun to do with a 300-page document. Does anyone know if there is a simple way to do this in one fell swoop? I can always crop (rare) pages that do not perfectly match thereafter.

    Hi Bronwater,

    You can print to the Adobe PDF printer to a desired page size, but it will flatten your PDF & the other option is going to be trimming the PDF file.

    Kind regards
    Nicos

  • All messages deleted, except one

    Woke up this morning to find that all SMS my phone had mysteriously been deleted, except one - and in this message, the entire thread has disappeared except for the most recent text (likely received after the removal of mass). Of course I don't have a recent backup, not even with iCloud, but the strange thing is that not even 3rd 3rd party apps such as phone rescue could find no trace of my texts.

    The only thing that I get out of the ordinary last night has been to plug my phone into my computer to charge. I deliberately didn't synchronize it with iTunes or Photos, because they make my computer run very slowly and I was watching a video at the same time.

    I had a conversation by chatting with someone from Apple support and they have been unable to find a solution to the problem - they advised me to configure iCloud to make sure things have increased support, but even then, they said there is no way for messages save on iCloud.

    This happened to anyone before?

    Hi Muggleborn,

    Thanks for posting in the communities of Support from Apple! I understand that you had a few messages disappear randomly on your iPhone. I can certainly understand your concern, because I would not lose anything in my posts or the other. I am pleased to provide you with advice here.

    The first thing I want to make sure that you have checked is the option to keep the text messages. You can check this setting by going to settings > Messages > keep Messages and make sure that it is set to never. The other 2 options 30 days and 1 year will delete messages after this time elapsed.

    If you haven't already done so, you will also need to restart your iPhone.

    Restart your iPhone, iPad or iPod touch

    How do I restart

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo.

    Just be sure that you do not restart power mentioned in the article

    I also recommend that you backup your iPhone regularly to iTunes or to iCloud. A backup also save messages so if ever you lose information on your iPhone in the future, you can easily restore your backup. I've included some resources below that go on what is included in backups and how to get these backups going.

    On safeguards for iOS devices

    The backup of your iPhone, iPad and iPod touch

    Take care!

  • How can I delete all the email our except one

    How to delet all the email our except one

    Try the tools | Accounts show the accounts and then you can delete what you want.  If this does not help, then check out the suggestions of Fazil.

    Steve

Maybe you are looking for

  • Y560p video momentary Intermittent crashes / gel

    Hello I recently bought this laptop because he seemed to have good reviews. It runs fast and efficient, everything was great! Then I went on youtube to watch a video, and I experienced something terrible. The video would make the entire computer to h

  • Boot or admin password recovery for a 2000 HP

    Hello I'm working on a wipe and reload a laptop HP 2000.  The owner forgot the admin or start the password, and after that 3 attempts it gives the code "66233711". What is the way before on that? Thank you Kevin

  • Vista Home premium too slow in Dell Studio 1537

    Hello I use Dell Studio 1537. My laptop takes too long to start and takes too long for all processes. I did a disk cleanup and defragmentation. Please provide me the solution. Thanks in advance.

  • Need my key of origin of the product

    Hello Sir, > I'm * personal information removed for security reasons.* * > I have Sony vaio laptop that's under formatting and unfortunately it deleted the recovery partition. and my backup DVD does not work as well as I do not have any type of media

  • How can I get my Calendar.exe program works in Windows 7?

    Calendar.exe worked with all Windows OS since windows 3.1.  It is easy to use, no problem at all.  It gives me the schedule for the day in 15 minute increments and has an alarm when arrives the time of appointment.  I can't find a program to replace