Skip to main content
Known Participant
November 5, 2009
Question

import pdf into indesign

  • November 5, 2009
  • 1 reply
  • 2224 views

Hi,

i want to import pdf into indesign through script. That will select the pdf on verso pages alone with supplied input value and align

the pdf accordingly. it should not touch recto page.

verso side values

x-axis 0p2

y-axis 0p1.2

Here i attacehd my script

TopMargin=app.activeDocument.pages[0].marginPreferences.top;
LeftMargin=app.activeDocument.pages[0].marginPreferences.left;
FirstLayer=app.activeDocument.layers[0];
var OriginPoint=new Array();
OriginPoint[0]=TopMargin;
OriginPoint[1]=LeftMargin;
myInDesign=app;
myDocument=app.activeDocument;

  myFileName=File.openDialog("Choose a PDF File");
 
  if(myFileName == null){
     alert("Select a PDF file to Import!");
   }

    myInDesign.pdfPlacePreferences.pdfCrop = PDFCrop.cropContent;
    myCounter = 0;
    pg=0;
    myBreak = false;
    while (myBreak ==false){
        if (myCounter > 0){
            myDocument.pages.add();
        }
        PDFpg=pg;
        PDFpg++;
        app.pdfPlacePreferences.pageNumber =PDFpg;
        app.activeDocument.layoutWindows[0].activePage=app.activeDocument.pages[pg];
        myPDFPage=app.activeDocument.pages[pg].place(myFileName,OriginPoint);
        alert(myCounter)
        alert(myPDFPage)
   
          if(myCounter == 0){
         myFirstPage = myPDFPage.pdfAttributes.pageNumber;
         }
        else{
            if (myPDFPage.pdfAttributes.pageNumber ==myFirstPage){
                app.activeDocument.pages[pg].remove();
                alert("All pages in the pdf document are imported!");
                myBreak = true;
            }
        }
        myCounter++;
        pg++;
    }

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
November 5, 2009

What is the problem?

Oviya___Author
Known Participant
November 5, 2009

HI john,

Thanks for ur reply

Actulay i import pdf into my indesign document. i want to use UI to set recto and verso x & y axix values. if i enter x&y for recto pages. i want to align

recto page only. like that if i enter x&y for verso. i want to align recto page only.

Jongware
Community Expert
Community Expert
November 5, 2009

Hi Ovyia... (Me not a "John", by the way, me "Theun".)

Isn't that based on the original PlaceMultiPDF from Adobe? If I understand you correctly, there are only a few minor changes required.

1. The Place command always places a new image on the (0,0) origin of the current ruler settings. You could move the image after placing, but this script does it another way: it moves the origin instead while placing. Change the lines at the top to

TopMargin="0p2";
LeftMargin="0p1.2";

-- the array OriginPoint gets used in the Place command.

2. The script uses the variable "pg" twice -- first time, to select a page in the PDF (PDFpg=pg;), second time to point to the actual page the image is placed on (myPDFPage=app.activeDocument.pages[pg].place). So these are synchronized to work together -- PDF page #1 goes to page 1, PDF page #2 to page 2, and so on. You need to break this :-)

Change the 'place' line to

myPDFPage=app.activeDocument.pages[2*pg].place(myFileName,OriginPoint);

This now should place PDF page #1 (which gets counted as '0') on page 2*0 = 0 -- the first recto --, PDF page #1 onto page 2*1 = page 2 -- the next recto.

If you need to start placing pages somewhere later, not on the first page, just add that offset:

myPDFPage=app.activeDocument.pages[16+2*pg].place(myFileName,OriginPoint);

(this will start at page number 17, since the pages array starts counting at 0).