Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

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

$
0
0

ILLUSTRATOR CS4

 

Hello,

 

I often use the import multiPDF script from Carlos Santo and it works great.

But i sometimes get multipage PDFs from customers only with text, and the fonts are so rarely embedded.

As you may know, the solution to have this fonts "vectorised" even if you don't have it in your Font collection is to place your pdf as linked file (menu File-> Place with the "link" box checked) in an open document (or to drag and drop it), and then, via the Menu Object->Flatten Transparency, i check the box "Embed text" to have it done.

 

So to automate it with a multipage PDF, and inspired by Carlos' script, I tried this :

 

/////////////////////////////////////////////////

var doc = app.activeDocument;

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

var pdfOptions = app.preferences.PDFFileOptions;

 

var firstPage = 1;

var lastPage = 10;

 

pdfFile = File.openDialog("Open Multi-page PDF", "*.pdf", false);

 

for (i= firstPage;i<lastPage;i++)

     {

         pdfOptions.pageToOpen = i;

         var  thisPlacedItem = doc.placedItems.add();

         thisPlacedItem.file = pdfFile;

     };

/////////////////////////////////////////////////

 

It doesn't work ! I end up with 10 placedItems of the page number 1 of the pdf file. Maybe that the pageToOpen option only works when i use the Open method ? In fact no, cause if i launch only the following 2 lines and then i drag and drop the pdf file, the page specified (page 8 in the example) is right placed.

 

//////////////////

var pdfOptions = app.preferences.PDFFileOptions;

pdfOptions.pageToOpen = 8;

/////////////////

 

I don't know how to do to fix it. I have 2 solutions but it only makes it "semi automatic" :

 

- Create a palette dialog with a button than increases one by one the pageToOpen option and then drag and drop my file one time for every pages (easy)

 

- Without the palette and the button, but with an event listener with a function that increases the pageToOpen value each time i drag and drop a new file (maybe by listening to changes in document.placedItems.length), but is it possible ?

 

Any suggestions ?

 

Thank you for your help!


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>