Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Can You write a script for PLACING LINKS of multipage PDF?

Community Beginner ,
Aug 08, 2016 Aug 08, 2016

Can You write a script for PLACING LINKS of multipage PDF?

For "imposing" linked PDF files in AI (like Quite, Signa, Preps...)

TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Valorous Hero ,
Aug 08, 2016 Aug 08, 2016

Look up the great Multi-Page PDF script written by the legendary Carlos Canto. I use it sometimes so I do not have to write it, why re-invent the wheel right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2016 Aug 08, 2016

This script OPEN pdf.

I need PLACE ONLY LINKED pdf (no problem with fonts etc.) for imposing and output to imagesetter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 09, 2016 Aug 09, 2016

Oh, then, excellent, you inspired me to learn something new. Indeed, the seemingly inaccessible task of choosing a PDF's page link can be accomplished with setting preferences. It works by setting a preference first, then creating a new placed file with script - when it appears, the correct page will show!

#target illustrator

function test(){

  var doc = app.activeDocument;

  var myPDF = File.openDialog("Choose PDF file", "*.pdf");

  if(!myPDF){return;}

  app.preferences.setIntegerPreference("plugin/PDFImport/PageNumber", 2);

  var newPlaced = doc.placedItems.add();

  newPlaced.file = myPDF;

};

test();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 09, 2016 Aug 09, 2016

"It works by setting a preference first..."

How can I do this? (Other words for dummies)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 09, 2016 Aug 09, 2016

This line here makes the page of the next placed PDF be page # 2:
app.preferences.setIntegerPreference("plugin/PDFImport/PageNumber", 2);

If you hang around these forums for 5 years and stay up till 2 am most days doing this stuff, believe me, you will get there, do not give up. Be crazy!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2016 Aug 10, 2016

It opened the first page only.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2016 Aug 10, 2016

What am I doing wrong?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2016 Aug 10, 2016

Another script open specified number of pages.

but all of them are FIRST (not "i")

var doc = activeDocument,

    f = File.openDialog ('pdf', '*.pdf'),

    p = prompt ('minimum 1 page', 5, 'specified')

    i = 0;

for (; ++i <= p;) {

    app.preferences.setIntegerPreference('plugin/PDFImport/PageNumber', i);

    doc.placedItems.add().file = f;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2016 Aug 10, 2016

pic1.JPGHow to use this function (select a page in Place PDF)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 10, 2016 Aug 10, 2016

Which version are you using? Maybe in a different version the preferences command was moved around.

In CC 2015.3, this following script worked to accomplish your desired goal.

To find the preferences string 'plugin/PDFImport/PageNumber', I opened the file located here:

C:\Users\<<me>>\AppData\Roaming\Adobe\Adobe Illustrator 20 Settings\en_US\x64\Adobe Illustrator Prefs

#target illustrator

function test(){

  var doc = app.activeDocument;

  var myPDF = File.openDialog("Choose PDF file", "*.pdf");

  if(!myPDF){return;}

  for(var i=0; i < 5; i++){

    app.preferences.setIntegerPreference("plugin/PDFImport/PageNumber", i + 1);

    var newPlaced = doc.placedItems.add();

    newPlaced.file = myPDF;

    newPlaced.left = i * 630;

  };

};

test();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2016 Aug 10, 2016

AI CS5.

In my AIPfefs:

PDFImport {

/PageNumber 1

/CropTo 4

/DlgPosY 204

/DlgPosX 494

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 10, 2016 Aug 10, 2016

If this part is not inside a

/plugin {

}

then your string would probably be just "PDFImport/PageNumber"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2016 Aug 10, 2016

Maybe, the function "doc.placedItems.add()" must have an argument?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2016 Aug 10, 2016

OR

It may be function like  "PageToOpen"  (Specifies which page are used when PLACING a multipage document)?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 10, 2016 Aug 10, 2016

I do not think so, because your code worked for me on Win7 CC2015.3

I do have CS5 at home on Windows, maybe I can test on it soon.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2016 Aug 12, 2016

Hi guys, check this thread about increasing the pageToOpen

How to "Place as linked file" (not "import") a multipage PDF file on a single Artboard ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 12, 2016 Aug 12, 2016
LATEST

pdfOptions.pageToOpen++;

This function returns error

error2.JPG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines