Skip to main content
Participant
May 17, 2023
Question

Link a PDF with multiple pages to specific squares (rectangle) on my Indesign Page

  • May 17, 2023
  • 1 reply
  • 270 views

Hi!

 

I am having problem to Auto-Mount from a PDF to my Indesign Page. 

 

The set-up I wish to solve:

I have 1 Indesign Page, on that page I have 10 Squares (rectangle).

I want to link each square to take 1 page from a PDF.

 

So square 1 is linked to Page 1 on PDF

Square 2 is linked to Page 2 on PDF

Square 3 is linked to Page 3 on PDF

and so on. 

 

Is it possible?

ATM I Ctrl + D (All pages from the PDF) and click on each square so it mounts them in. But want to make it more efficient.

 

Thanks in advance

Nimzi 

This topic has been closed for replies.

1 reply

m1b
Community Expert
Community Expert
May 18, 2023

Hi @Nimzi if you want to try some scripting, I've written out a little example that does basically what you ask. See what you think. Maybe you can adapt it to suit. - Mark

 

/**
 * Example showing placing each page of a selected
 * PDF/AI file into rectangles in the document.
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/link-a-pdf-with-multiple-pages-to-specific-squares-rectangle-on-my-indesign-page/m-p/13798384
 */
function main() {

    // ask user for a pdf/ai file

    var regex = /\.(ai|pdf)$/i,
        fsFilter = function (f) { return (regex.test(decodeURI(f.name)) || f.constructor.name == 'Folder') },
        file = File.openDialog("Please select a PDF or AI File", fsFilter, false);

    // place the pages

    var doc = app.activeDocument,
        rectangles = doc.pages[0].rectangles;

    for (var i = 0; i < rectangles.length; i++) {

        // attributes of the placed pdf
        app.pdfPlacePreferences.pageNumber = (i + 1);
        app.pdfPlacePreferences.pdfCrop = PDFCrop.CROP_TRIM;
        app.pdfPlacePreferences.transparentBackground = false;

        // place the page
        rectangles[i].place(file, false);

        if (
            i > 1
            && rectangles[i].graphics[0].pdfAttributes.pageNumber == 1
        ) {
            // when the page number reverts to "1"
            // there are no more pages in the pdf
            rectangles[i].graphics[0].remove();
            break;
        }

    }

}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Place PDF Pages');

Edit 2023-05-19: typo in script. Oops.