Skip to main content
Participant
August 5, 2021
Question

How to detect disconnected pages

  • August 5, 2021
  • 4 replies
  • 799 views

Hi all,

 

I want to delete all empty pages of the document. When there are empty disconnected pages added I can't detect them in order to delete. Is there a way to do that?

 

Thanks in advance

    This topic has been closed for replies.

    4 replies

    Bob_Niland
    Community Expert
    Community Expert
    August 9, 2021

    re: I want to delete all empty pages of the document.

    Keep in mind that not all empty pages are disconnected pages.

    In a duplex (double-sided) document, any Paragraph Format (or override) that starts at Top of [L|R] Page can result in a blank page being left behind. Separate Chapter files can result in a blank at end of prior. There is no way to delete these meta-blank pages other than using single sided layout, or implementing some TPILB (ThisPageIntentionallyLeftBlank) scheme, so that no meta-blanks are actually blank.

    Inspiring
    April 28, 2022

    Can you use the "Delete Empty Pages" configuration?

    Format > Page Layout. In the Pagination dialog box, under "Before Saving and Printing", select "Delete Empty Pages".

    Barb Binder
    Community Expert
    Community Expert
    August 5, 2021

    Hi @ars999:

     

    One additional idea: 

    1. Click inside the text
    2. Edit > Select all in Flow
    3. Zoom out to 25%
    4. The pages that don't have text selected are the disconnected pages. If there is content on those pages, you can cut/paste it back into the main flow. Once that is completed, repeat the process and then delete the disconnected pages. 

     

    ~Barb 

    ~Barb at Rocky Mountain Training
    frameexpert
    Community Expert
    Community Expert
    August 5, 2021

    Beautifully illustrated!

    frameexpert
    Community Expert
    Community Expert
    August 5, 2021

    Another way to do it manually: Click in the document's main flow and Edit > Select All. Edit > Cut the content to the clipboard. Delete all pages from the document except the first. Put your cursor in the first page and Edit > Paste.

    frameexpert
    Community Expert
    Community Expert
    August 5, 2021

    If you view your text symbols (View > Text Symbols), you can look for end-of-flow symbols on each page. A page that is not the last that has an end-of-flow symbol is disconnected. If I get some time today, I will post some code to do it programmatically.

    ars999Author
    Participant
    August 9, 2021

    Hi. I think this is a good way to detect the disconnected pages. Can you provide some information how can it be implemented programmatically?

    frameexpert
    Community Expert
    Community Expert
    August 9, 2021

    I would do something like this:

    #target framemaker
    
    main ();
    
    function main () {
    
        var doc, mainFlow, page, textFrame;
    
        doc = app.ActiveDoc;
        if (doc.ObjectValid () === 1) {
            // Get the document's main flow.
            mainFlow = doc.MainFlowInDoc;
            // Loop through each page in the document.
            page = doc.FirstBodyPageInDoc;
            while (page.ObjectValid () === 1) {
                // Get the A flow text frame on the page.
                textFrame = getTextFrame (page, "A");
                if (textFrame) {
                    // See if the text frame's flow is the main flow.
                    if (textFrame.Flow.id !== mainFlow.id) {
                        // If not, you have a disconnected pageg.
                        $.writeln ("Disconnected page: " + page.PageNumString);
                    }
                }
                page = page.PageNext;
            }
        }
    }
    
    function getTextFrame (page, flow) {
        
        var frame, graphic;
        
        frame = page.PageFrame;
        graphic = frame.FirstGraphicInFrame;
        while (graphic.ObjectValid () === 1) {
            if (graphic.constructor.name === "TextFrame") {
                if (graphic.Flow.Name === flow) {
                    return graphic;
                }
            }
            graphic = graphic.NextGraphicInFrame;
        }
    }