Skip to main content
Inspiring
June 19, 2019
Answered

• Saving PDF with "embedded ICC profiles", doesn't work...

  • June 19, 2019
  • 2 replies
  • 1277 views

Hello -

I try to write up a script that will generate a PDF on the fly.

The PDF must embed the "ICC profile" and must have all images embedded.

The PDF is generated, but neither the "ICC profile" nor "images" are embed 

Any idea why?

Here is a snippet of my code:

#target Illustrator

#targetengine main

app.activeDocument.selection = null; // Ensure there is nothing in the document selected already. This way you only get the selection you want. 

app.redraw(); 

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

var myDoc = app.activeDocument;

var myLayers = myDoc.layers;

var PDF_HRpreset = "[Press Quality]";

var HighResOpts  = new PDFSaveOptions(); // Create the PDFSaveOptions object to set the PDF options/properties

HighResOpts.embedICCProfile = true;

HighResOpts.pDFPreset = PDF_HRpreset;

//

// Embed ALL images (So we don't loose images' links when we open the PDF with Illustrator   <-  Client's late request)

//

if ( myDoc.length > 0 ) {

while ( app.activeDocument.placedItems.length > 0 ) {

        placedArt = app.activeDocument.placedItems[0];

        placedArt.embed();

    }

}

myDoc.saveAs(File("~/Desktop" + "/" + myDoc.name.replace(".ai", "_MOCKUP.pdf")), lowResOpts);

Thank you for any help. Regards,

- Dimitri

Message was edited by: Vasily Hall

This topic has been closed for replies.
Correct answer CarlosCanto

you probably need

HighResOpts.colorProfileID = ColorProfile.INCLUDEALLPROFILE;

about embedding...your problem is line 25

2 replies

Inspiring
June 21, 2019

Hello Carlos -

Thx, it works like a charm 

Solution to embed the profiles is thus:

HighResOpts.colorProfileID = ColorProfile.INCLUDEALLPROFILE;

Regarding the embed all images problem, I finally decided to work with this piece of code:

//

// Embed ALL images (So we don't loose images' links when we open the PDF with Illustrator   <-  Client's late request)

//

function embedInAllDocuments_fct() {

    var placedArt;

    for (var i=app.documents.length-1; i>-1; i--) {

        while ( app.documents.placedItems.length > 0 ) {

            placedArt = app.documents.placedItems[0];

            placedArt.embed();

        }

    }

}

So, thank you again Carlos for your time and knowledge  :-)

Regards,

- Dimtiri

CarlosCanto
Community Expert
Community Expert
June 21, 2019

you're welcome,

but did you see what the issue was with line 25 in your first script?

Inspiring
June 21, 2019

Nope… :-(

Except if "MyDoc" was undefined or something like this.

I'm sorry.

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
June 20, 2019

you probably need

HighResOpts.colorProfileID = ColorProfile.INCLUDEALLPROFILE;

about embedding...your problem is line 25

Inspiring
June 20, 2019

Good morning Carlos -

Thank you for your quick reply.

I'll definitively give it a try and give some feedback.

Regards,

- Dimitri