Copy link to clipboard
Copied
Hello guys,
i have a situation while laoding an artboard. This artboard consists of 4 images. while trying to load it into illustrator its working fine and while loading on to an extension only the first image is opening fine and all the remaining were breaking.
I have tried loading different artboards with multiple images. They worked fine.
That file which i am unable to load into extension was given by our client. I dont know whether there is a problem in that .ai file or what ever. This is the only file i am unable to load to extension.
Could come one please help me with this
Copy link to clipboard
Copied
Hey, what extension are you using, can you take a bunch of screenshots of it and post them here to show us more about what this extension is and what it does?
Copy link to clipboard
Copied
sorry for the delayed reply as i am not feeling well and my sincere apologies.
And extension in the sense we have developed some extensions for Illustrator. The functionality of that extension is that, whatever file you open in illustrator that will be reflected into our extension. How this is achieved is that, first the artboard is exported to png format to a local folder using app.activedocument.exportFile();. Those png files will be loaded on to extension.
But Whats the problem is that all the .ai files(artboards) which have multiple images can be converted to png format and those can be shown in our extension. but for a file given by our client, that app.activedocument.exportFile(); is not converting into png format. Could you please help me with this.
Sorry for the screenshots as we have no access for attaching screenshots and highly secured.
Copy link to clipboard
Copied
hmm. without a test file or screenshots, it's very difficult to know what the problem might be.
Is it possible for you to try and re-create the error with a file that isn't so sensitive? That way you could share the file without giving up any info, and that will give us the opportunity to debug the problem.
Any additional information you can give is also helpful. For example, when you say "is not converting to png format" do you mean that you get an error? does it proceed silently without saving anything in your desired location? does it save the png but the extension isn't properly importing it?
Copy link to clipboard
Copied
Hello williamadowling,
Thank you for the reply.
I do not have any other file to replicate the issue. only one file by the client is creating this issue.
yes my execution is proceeding silently with out any error while converting to png.
There are 4 images in an artboard out of which only the first one is able to be converted to png and the remaining are not.
I am attaching a screenshot of the original image in illustrator and code where it will be converted to png
Only the first one is able to be converted to png. I have tried changing the names of artboard to confirm that there is no problem with naming convention.
Tried creating another artboard with the same images and failed converting to png.
Copy link to clipboard
Copied
Bonjour,
Je n'ai peut être pas tout compris ? (problème de traduction)
Je propose tout de même un script simple pour tester...
// JavaScript Document de elleere
// Exporte le document ouvert au format PNG24 avec les options spécifiées
// Seul le plan de travail actif est sauvegardé
if ( app.documents.length > 0 ) {
var exportOptions = new ExportOptionsPNG24();
var type = ExportType.PNG24;
var fileSpec = new File("~/essai_PNG24.png");
exportOptions.antiAliasing = true;
exportOptions.transparency = false;
exportOptions.matte = true; //white par défaut matteColor
//exportOptions.matteColor = spécifier une couleur
//exportOptions.saveMultipleArtboards = true;
exportOptions.artBoardClipping = true;
exportOptions.horizontalScale = 100;
exportOptions.verticalScale = 100;
exportOptions.saveAsHTML = true;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
Copy link to clipboard
Copied
Hello,
I have tried both your methods.. Its not working.
Copy link to clipboard
Copied
can you run any of these tests on another file so we know whether the code isn't working or whether there's something corrupt about the file?
have you tried duplicating all of the artwork into a new file and re-saving to see if that might clear out any lingering bugs in the file that are causing your export issues?
Copy link to clipboard
Copied
1. yes, i have tried working on other files in my pc and able to convert all the files except the one which i have mentioned.
2. I have duplicating the artwork into a new file and re-saved and the problem is same as the original one.
Copy link to clipboard
Copied
And here is my code
function(designNumber, exportPath){
//alert('designNumber:'+val);
var num_exported = 0;
var options = getThumbnailOptions();
var failed_artboards=[];
var exportArtboards=[];
var opts = new ExportOptionsPNG24();
opts.artBoardClipping = true;
opts.matte = false;
opts.horizontalScale = opts.verticalScale = 100;
opts.transparency = false;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
if(app.documents.length==0)
return JSON.stringify(exportArtboards);
var docRef = app.activeDocument;
for (var i = 0; i < docRef.artboards.length; i++ ) {
var artboard = docRef.artboards;
var artboardName = artboard.name.replace(/\s+/g, '-');
//alert(artboardName);
docRef.artboards.setActiveArtboardIndex(i);
var d = new Date();
var t = d.getTime();
if(designNumber)
//n = designNumber.replace(/\s+/g, '-')+n;
n = designNumber.replace(/\s+/g, '-');
//fName is appended in file name
fName = (app.activeDocument.fullName.fsName.split(/(\\|\/)/g).pop());
//alert(app.activeDocument.fullName.fsName);
fName=fName.substring(0, fName.indexOf('.'));
fName = fName.replace(/ /g,"_");
// prefix is combibation of exp and design number and filename
var prefix="exp_"+n+'_'+fName+'_';
var suffix=".png";
var base_path= app.path + '/CEP/extensions/com.cgsinc.illustrator.plm.artboards/ai_exports/';
base_path = exportPath;
var exportArtboard={};
if (true){
try{
var exportFileName = prefix + artboardName + suffix;
var base_filename = base_path + exportFileName;
//TODO : if file exist, reame base_filename
expFile = File(base_filename);
expFile = new leader(base_filename);
docRef.exportFile(expFile, ExportType.PNG24, opts);
exportArtboard.artboardName=artboardName;
exportArtboard.con_exportFileName = prefix + artboardName +'_con'+ suffix;
exportArtboard.artboardIndex=i;
exportArtboard.selected = false;
exportArtboard.designNumber= designNumber;
exportArtboard.fkey= 0;
exportArtboard.pkey= 0;
exportArtboard.imageByte= null;
exportArtboard.imageCategory= "";
exportArtboard.imageType= "";
exportArtboard.imageDescription= "";
exportArtboard.imageNote= "";
exportArtboard.fileName= unescape(base_filename.replace('/c/','/'))+ "?stamp=" +t;
exportArtboard.exportFileName=exportFileName;
var a=app.activeDocument.fullName.fsName;
exportArtboard.masterFileName=app.activeDocument.fullName.fsName;
exportArtboards.push(exportArtboard);
}catch(e){
failed_artboards.push(e);
alert('error:'+e);
}
}
}
Copy link to clipboard
Copied
perhaps try changing the app.userInteractionLevel...? maybe you are getting some kind of message, but it's being suppressed?
Copy link to clipboard
Copied
Could you please make it clear?
Copy link to clipboard
Copied
My apologies, i just wrote a whole long post that was an answer to a totally different question because apparently i don't read very well.
check out this snippet :
var opts = new ExportOptionsPNG24();
opts.artBoardClipping = true;
opts.matte = false;
opts.horizontalScale = opts.verticalScale = 100;
opts.transparency = false;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
change that last line to:
app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;
perhaps that will reveal some issue that is occurring silently?
Copy link to clipboard
Copied
Hello williamadowling,
i tried changing code as per your suggestion. Even though there is no result of showing alerts.
Copy link to clipboard
Copied
Why don't you use imageCapture method?
Re: Creating a jpeg preview from Illustrator file that contains slices
Copy link to clipboard
Copied
Hello Ten,
i need only png format. not jpeg.
Copy link to clipboard
Copied
Have you checked my link?
The imageCapture method generates PNG file.
Copy link to clipboard
Copied
Hey Ten, sorry. I have tried your link.
Previous export method converted atleast one among the four and now the method you have suggested not even converting atleast one image.
Copy link to clipboard
Copied
Pour convertir tous les plans de travail dans des fichiers différents,
Remplace la ligne 17 par :
var doc = activeDocument;
var nbPage = doc.artboards.length;
for (var i = 0; i < nbPage; i ++) {
doc.artboards.setActiveArtboardIndex(i)
fileSpec = new File("~/essai_PNG24 "+i+".png ");
doc.exportFile( fileSpec, type, exportOptions );
}
Copy link to clipboard
Copied
Hello guys,
Now Whats the intresting thing i found is that, as i have said that there are 4 iamges in an artboard(lets say ARt1) which i wanna convert to png and among them i am able to convert only the first one itself and the remaing three were not able to get convert.
Now what i did is that, i have created a new artboard(lets say Art2) and copied the content of only 2nd image of Art1 to Art2 and saved. Now export(); able to convert it to png. Now again i have copied the content of 3rd iamge of Art1 to Art2 and now Art2 contains 2 images with content of 2nd and 3rd images of Art1 and saved Art2. Even now Export(); converted this Art2 successfully to png.
What i mean to say is that, the images which were not being converted to png in Art1 were successfully converted to png in Art2.
I have continued copying the content of 4th image of Art1 to Art2. Now Art2 contains the 3 images of Art1(2,3,4). Now saved Art2 and tried converting to png. But surprisingly only the first one in Art1 got converted and the remaining has not converted.
This is the strange behaviour i have noticed.
Copy link to clipboard
Copied
So no matter how you order the images, or what their parent artboard is, the script only exports the first image, then ignores the rest? If you open the file exactly as the customer sent it, then just rearrange the images in the layers panel, does that change the image that gets exported? In other words, can you successfully export any image, so long as it's the first one that's processed? Or are there any specific images that cause problems during export?
Again without being able to see and test the file it's difficult to know what's going on, but i think i understand what you're saying.
If we can identify that it's not any of the individual images that cause a problem, then that's one more thing to check off the troubleshooting list.
Copy link to clipboard
Copied
Sorry for the late reply williamadowling.
I performed all the tests what ever you have suggested.
At the last line you have suggested me that to perform on more check left over. whats that?
Copy link to clipboard
Copied
I'm sorry. I think there's probably a translation issue here. I'm not sure what you're asking.
So, you have 4 images in your document. Let's give them aliases from left to right for demonstration purposes.
Image A, Image B, Image C, and Image D
When you run your script, you say that Image A gets exported, but the remaining images get ignored.
What happens when you re-arrange the images like this:
Image B, Image C, Image D, Image A
or
Image D, Image A, Image C, Image B
If you try either of the above scenarios, which image is exported? is it always the same image that is exported? Or is it always the first image in the hierarchy?
Copy link to clipboard
Copied
Hello williamadowling,
As per your suggestion i have made some changes to the Artboard. These are the tests i have performed.
1. Rearranged all the images in an artboard in different orders.
2. Created an empty artboard with 4 blank pages. Now tried coping one by one image from original file to new artboard.
while i tried to copy the third one then it self the fourth image breaking. The below two images make it clear.
Could you suggest me now something after seeing these?
Copy link to clipboard
Copied
I'm sorry. I still don't quite understand the issue, and i think the language barrier is getting to me.
Hopefully someone else around here will have some input, but without access to a test file and the script, i can't really provide anything further.