code_seeeeeker
Participant
code_seeeeeker
Participant
Activity
‎Mar 12, 2025
02:36 AM
This is awesome, Stephen! I'll play around with it to suit my requirements. Thanks, once again 🙂
... View more
‎Mar 11, 2025
01:59 PM
Hi, I have this JavaScript which saves each layer of Photoshop as a Separate PDF. I want an addition to this script so that all the separate PDFs can be merged into a single PDF. The objective is to convert a GIF into a PDF. Here's what I do: 1) open a GIF (containing layers) in Photoshop. 2) execute the JS, which saves each layer of the GIF as a separate PDF at the same location within a temp folder. 3) The third part requires merging all those PDFs into a single PDF. Currently, I'm manually merging those PDFs. It would be nice, if the merging of the PDFs can be done silently, without bringing the Acrobat in front. PS: I use both MAC and PC. // photoshop
// Export GIF layers as PDFs
function exportLayersToPDF() {
if (app.documents.length === 0) {
alert("Please open a GIF file first.");
return;
}
var doc = app.activeDocument;
var filePath = doc.fullName.parent;
var fileName = doc.name.split('.')[0];
var tempFolder = new Folder(filePath + "/tmp_" + fileName);
if (!tempFolder.exists) tempFolder.create();
var originalVisibility = [];
var totalLayers = doc.layers.length;
// Hide all layers and save their visibility states
for (var i = 0; i < totalLayers; i++) {
originalVisibility[i] = doc.layers[i].visible;
doc.layers[i].visible = false;
}
// Export each layer as PDF (reverse order: bottom to top)
for (var i = totalLayers - 1, count = 1; i >= 0; i--, count++) {
doc.layers[i].visible = true;
var pdfFile = new File(tempFolder + "/" + fileName + "_" + count + ".pdf");
var pdfOptions = new PDFSaveOptions();
pdfOptions.embedFonts = true;
pdfOptions.imageCompression = PDFEncoding.JPEG;
pdfOptions.jpegQuality = 12;
doc.saveAs(pdfFile, pdfOptions, true);
doc.layers[i].visible = false;
}
// Restore original visibility
for (var i = 0; i < totalLayers; i++) {
doc.layers[i].visible = originalVisibility[i];
}
alert("PDFs exported successfully! Please use Acrobat to combine them.");
return tempFolder;
}
// Run the script
exportLayersToPDF();
... View more
‎Mar 11, 2025
09:28 AM
2 Upvotes
Thanks, Stephen, this is much help. I'll troubleshoot it further.
... View more
‎Mar 10, 2025
03:03 PM
What are you wanting? An alert to pop up stating the colour mode without having to launch Illustrator? By @Stephen Marsh Yes, Stephen, you got it right. A kind of JS file to loop through all the SmartObjects in a PSD file and pop up if the color mode of the SmartObject is different than the color mode of the PSD file.
... View more
‎Mar 10, 2025
05:48 AM
Thanks for your response, Stephen. you can copy any object from Illustrator and Paste it in Photoshop for testing. I have also attached one for your review. In this, the PSD is in CMYK, whereas the SmartObject is in RGB. If you click the SmartObject in Photoshop, it will open in Illustrator and any changes made in the Illustrator files get reflected in PSD.
... View more
‎Mar 06, 2025
07:22 AM
I'm looking for a tool or a JavaScript that let me know the color mode of a SmartObject in Photoshop. I have copied objects from an Illustrator file and pasted it in a PSD file. The PSD could be in RGB or CMYK, and similarly, the AI objects could be in CMYK or RGB. I want a JavaScript that tells me the color mode of the SmartObject. Can anyone help on this, please.
... View more
‎Feb 04, 2025
01:56 AM
Thanks, for the inputs, Charu. The function removeUnusedSwatches() removes all the swatches except the used Spot and Global swatches. There are other used non-global swatches as well which are getting removed. Secondly, the other link you provided, was giving Error: 1224 Numeric value expected. Line 19: sw.color = newColor., but I'll figure it out. I'm on MAC using Illustrator 2023, but I also work on PC with other versions of Illustrator. The ONLY problem for me is I want a code that converts all the swatches to a GLOBAL swatch. Can you please help me with that.
... View more
‎Feb 03, 2025
01:30 AM
Hi, I have this working script with me which works well in InDesign. It helps me to (a) Add all Unnamed colors, (b) remove all unused swatches, and (c) convert all colours to CMYK Process. I need a similar code for Illustrator with an additional check point. i.e. I want to convert all colours to CMYK Process Global swatch. #target indesign
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;
for (var s = myUnusedSwatches.length - 1; s >= 0; s--) {
var mySwatch = myIndesignDoc.unusedSwatches[s];
var name = mySwatch.name;
if (name != "") {
mySwatch.remove();
}
}
app.activeDocument.colors.everyItem().properties = { space: ColorSpace.CMYK, model: ColorModel.PROCESS }; Can anyone help, please.
... View more
‎Jan 17, 2025
12:52 PM
1 Upvote
‎Jan 16, 2025
09:04 AM
Sure, I'll do.
... View more
‎Jan 16, 2025
05:27 AM
Thanks a ton, Eugene, this is really what I was looking. The code now picks up the profile's list from the system but there's a glitch, everytime, I add a new profile, I have to restart my InDesign. Furthermore, the script is not converting any image to CMYK, it just open it in the Photoshop. I think I can figure it out. Thanks again for your time and support on this.
... View more
‎Jan 16, 2025
01:16 AM
Hi Eugene, You have given me my code in return, there's no difference, the script is pulling the profile's list manually instead of auto-fetching. I think this is not a doable task, so let's close this chapter here. Anyway, thanks everyone for your time and suggestions!
... View more
‎Jan 15, 2025
02:51 AM
Any suggestions!!
... View more
‎Jan 13, 2025
01:18 AM
Thanks, Eugene, for your understanding. The problem becomes really frustrating when people are not ready to accept the correct processes. There are still so many people around who prefer to work in the old-fashioned manner. They strickly say, 'please follow instructions' and we're left with no choice. I think it will take decades for them to understand. Here's is my modified script that works well on the selected image. I have list-down all the possible profiles in the 'getCMYKProfile()' function. The script is working fine, but if a particular profile is missing, then no conversion takes place. So, I was wondering, if the script can fetch the profile list like Photoshop do, then my script will be more productive. function convert2CMYK() {
var doc = app.activeDocument;
var selection = doc.selection;
if (!selection || selection.length === 0) {
// No selection, process all images in the document
var links = doc.links;
for (var i = 0; i < links.length; i++) {
var link = links[i];
if (link.status === LinkStatus.NORMAL) {
var image = link.parent;
if (image.constructor.name === "Image" && image.space === "RGB") {
processImage(link);
}
}
}
} else {
// Process selected items regardless of shape
for (var j = 0; j < selection.length; j++) {
var selectedItem = selection[j];
if (selectedItem.constructor.name === "Image") {
var selectedLink = selectedItem.itemLink;
if (selectedLink && selectedLink.status === LinkStatus.NORMAL && selectedItem.space === "RGB") {
processImage(selectedLink);
}
} else if (selectedItem.images && selectedItem.images.length > 0) {
for (var k = 0; k < selectedItem.images.length; k++) {
var nestedImage = selectedItem.images[k];
var nestedLink = nestedImage.itemLink;
if (nestedLink && nestedLink.status === LinkStatus.NORMAL && nestedImage.space === "RGB") {
processImage(nestedLink);
}
}
}
}
}
UpdateAllOutdatedLinks();
//===================== FUNCTIONS ===============================
function processImage(link) {
var newPath = DuplicateAndRenameFile(link.filePath);
var profile = getCMYKProfile();
if (profile) {
CreateBridgeTalkMessage(newPath, profile);
RelinkFile(link, newPath);
} else {
// alert("No CMYK profile selected. Conversion canceled.");
}
}
function CreateBridgeTalkMessage(imagePath, profile) {
var bt = new BridgeTalk();
bt.target = "photoshop";
bt.body =
"(function() {" +
" var psDoc;" +
" app.displayDialogs = DialogModes.NO;" +
" psDoc = app.open(new File('" + imagePath + "'));" +
" if (psDoc) {" +
" psDoc.convertProfile('" + profile + "', Intent.RELATIVECOLORIMETRIC, true);" +
" psDoc.save();" +
" psDoc.close(SaveOptions.SAVECHANGES);" +
" }" +
" app.displayDialogs = DialogModes.ALL;" +
"})();";
bt.onError = function (errObj) {
// alert("Error in BridgeTalk: " + errObj.body);
};
bt.onResult = function () {
alert("Image successfully converted to CMYK!");
};
bt.send(30);
}
function UpdateAllOutdatedLinks() {
var link, c;
for (c = doc.links.length - 1; c >= 0; c--) {
link = doc.links[c];
if (link.status == LinkStatus.LINK_OUT_OF_DATE) link.update();
}
}
function DuplicateAndRenameFile(filePath) {
var file = new File(filePath);
var folderPath = file.path;
var fileName = file.name;
var fileExtension = fileName.substring(fileName.lastIndexOf("."));
var baseName = fileName.substring(0, fileName.lastIndexOf("."));
var newFileName = baseName + "_C" + fileExtension;
var newFilePath = folderPath + "/" + newFileName;
var newFile = new File(newFilePath);
if (file.copy(newFilePath)) {
return newFilePath; // Return the path of the duplicated file
} else {
alert("Failed to duplicate and rename file: " + filePath);
return filePath;
}
}
function RelinkFile(link, newPath) {
var newFile = new File(newPath);
if (newFile.exists) {
link.relink(newFile);
link.update();
} else {
alert("Failed to relink file: " + newPath);
}
}
function getCMYKProfile() {
var profiles = [
"Coated FOGRA39 (ISO 12647-2:2004)",
"Coated FOGRA27 (ISO 12647-2:2004)",
"Coated GRACoL 2006 (ISO 12647-2:2004)",
"ISO Web Coated",
"ISOnewspaper26v4",
"Japan Color 2001 Coated",
"Japan Color 2001 Uncoated",
"Japan Color 2002 Newspaper",
"Japan Color 2003 Web Coated",
"Japan Web Coated (Ad)",
"U.S. Sheetfed Coated v2",
"U.S. Sheetfed Uncoated v2",
"U.S. Web Coated (SWOP) v2",
"U.S. Web Uncoated v2",
"Uncoated FOGRA29 (ISO 12647-2:2004)",
"US Newsprint (SNAP 2007)",
"Web Coated FOGRA28 (ISO 12647-2:2004)"
];
var profileName = showDropdown(profiles);
return profileName;
}
function showDropdown(profiles) {
var dialog = new Window("dialog", "Select CMYK Profile");
dialog.orientation = "column";
var dropdown = dialog.add("dropdownlist", undefined, profiles);
dropdown.selection = 0;
dialog.add("button", undefined, "OK", { name: "ok" });
if (dialog.show() == 1) {
return dropdown.selection.text;
} else {
return null;
}
}
}
convert2CMYK();
... View more
‎Jan 11, 2025
12:05 AM
Opinios, opinions, and opinions, that's all I get here. As I said, I know all these things. I can simply open the images in Photoshop and do the conversion. I am also aware of the Batch thing. I know the importance of RGB images and converting them while exporting a PDF. I know the difference between Change-Mode and Convert-to-Profile methods. I know the usage and differences between JPG, PNG Tiff etc images. I know this, I know that............................................................................. What I was looking is a JavaSript which when executed from InDesign tracks all the RGB images and convert them to CMYK. The script from Kasyan's site is very useful and I'm able to modify it to use the 'Convert to Profile' method, and also able to create a manual color profile list. The modified version is working fine. Here are the excerpts: " if (psDoc) {" +
" psDoc.convertProfile('" + profile + "', Intent.RELATIVECOLORIMETRIC, true);" +
" psDoc.save();" +
" psDoc.close(SaveOptions.SAVECHANGES);" + function getCMYKProfile() {
var profiles = [
"Coated FOGRA39 (ISO 12647-2:2004)",
"Coated FOGRA27 (ISO 12647-2:2004)",
"Coated GRACoL 2006 (ISO 12647-2:2004)",
"ISO Web Coated", I was wondering if the script could auto fetch the profile list as Photoshop do, then my script is completed. But I think, there's no one to sort my problem here. Anyway, thanks for all your SUGGESTIONS.
... View more
‎Jan 10, 2025
10:20 AM
Would you be kind enough to provide me the code, please leave other things with me.
... View more
‎Jan 10, 2025
08:56 AM
Thanks, Willi, I know about this. But I also need this script as part of my job requirement. The client insist the images to be CMYK in InDesign itself. So, a workaround with JavaScript would be much appreciated.
... View more
‎Jan 10, 2025
07:45 AM
Hi, I want my RGB images in InDesign to convert to CMYK using the Photoshop's 'Convert to Profile' method. I found this script on the net: http://kasyan.ho.ua/indesign/swatch_color/convert_rgb_grayscale_images_to_cmyk.html However, this script is using the Change Mode method, whereas I want the 'Convert to Profile' method to convert my images to CMYK along with an option to select the desired Colour Profile from the Dropdown list. Like we do in Photoshop > Convert to Profile > select destination profile. Any suggestions.
... View more
‎Nov 02, 2024
11:25 AM
Please help me with the code. I'm not a coder by profession.
... View more
‎Nov 02, 2024
08:09 AM
Thanks, Peter for the suggestions. Can a single scroll bar be added to the right despite two?
... View more
‎Nov 01, 2024
08:40 AM
Hi Everyone, I need your support in adding a vertical scrollbar to my custom palette for InDesign. The current palette is growing as I add a new button to it. so I want two vertical scroll bars, one for the 'Custom Checks' and the other for the 'Custom Fixes'. Here's my code: If easily doable, can we also reduce the margins between the buttons. Thanks, in advance, M #targetengine 'customChecksAndFixes'
// Create the panel window
var myWindow = new Window('palette', "Checks & Fixes - InDesign, v5.0", undefined, { resizeable: true });
// Add here a message "Please Save Your File Before Running a Script!"
var messageText = myWindow.add('statictext', undefined, "Save Your File Before Clicking a Button...");
messageText.alignment = 'center';
// Add buttons to the panel
myWindow.alignChildren = 'column';
myWindow.alignChildren = 'left';
// ************************************************ CUSTOM CHECKS – B U T T O N S
var checkFonts = myWindow.add('button', undefined, 'CHECK - Fonts Status)');
var checkTextSize = myWindow.add('button', undefined, 'CHECK - Text Less than 6pt)');
var checkBaselineShift = myWindow.add('button', undefined, 'CHECK - Text with Baseline Shift)');
var checkRGB = myWindow.add('button', undefined, 'CHECK - RGB Image(s)');
var checkResolution = myWindow.add('button', undefined, 'CHECK - Effective Resolution Below 300');
var checkScaling = myWindow.add('button', undefined, 'CHECK - Image Scaling above 110%');
var checkProportional = myWindow.add('button', undefined, 'CHECK - Non-Proportionally Scaled Image(s)');
var checkEmbedded = myWindow.add('button', undefined, 'CHECK - Pasted & Embedded Image(s)');
myWindow.add('panel', undefined); // Creates a visual separator
// ************************************************ FIXES – B U T T O N S
var removeSpaceBeforePunctuation = myWindow.add('button', undefined, 'FIX - Remove Double & Space(s) Before Punctuation');
var leadingFix = myWindow.add('button', undefined, 'FIX - Leading at the End of a Paragraph');
var fixSwatches = myWindow.add('button', undefined, 'FIX - Convert All Swatches to CMYK');
var reg2BlackFix = myWindow.add('button', undefined, 'FIX - Registration Colour to Black');
var strokeBelow025Fix = myWindow.add('button', undefined, 'FIX - Stroke Below 0.25pt');
var pasteBoardCleanup = myWindow.add('button', undefined, 'FIX - Delete Pasteboard Items');
// ************************************************ F U N C T I O N S
// Show the panel
myWindow.show();
... View more
‎Oct 22, 2024
04:53 AM
Try this out… https://creativepro.com/script-cleaning-empty-text-frames/
... View more
‎Oct 18, 2024
01:31 PM
Hello, Coders, I'm trying to create an InDesign Extension that will allow me to hold buttons/Links to some of my JavaScripts. However, with ChatGPT, I can create an Extension, but it does not display any buttons/Links, I tried a lot, but nothing works. The link below holds the bundle I'm using to create a ZXP. https://drive.google.com/drive/folders/11ETyDraYrpLfqu9MqEWojN5f_25lTQ4S?usp=sharing I'm on MAC OS 14.4.1 using InDesign CC 2017 to CC2024. I use "Anastasiy's Extension Manager" to install the ZXP extension. I created a Palette, but that requires loading from the Script Panel, so instead, I'm trying to create a menu item that will always be available under the Extension and can be docked to my workspace. Can you please help me create a ZXP template, so that I can add buttons/Links and JSX scripts to it as per my requirement. Thanks, The current output Extension Palette does not display any buttons/Links… Instead of a Blank Extension Palette, I want something like this…
... View more
‎Oct 16, 2024
05:57 AM
Solved!!
... View more
‎Oct 16, 2024
05:09 AM
Thanks, m1b, I'll try this and let you know if it works.
... View more
‎Oct 16, 2024
05:08 AM
Thanks, RobOctopus, I already tried changing the 'Dialog' to 'Palette', but as I said, some scripts stopped working then.
... View more
‎Oct 15, 2024
08:22 AM
Solved!!
... View more
‎Oct 01, 2024
06:10 AM
Any suggestions, please…
... View more
‎Sep 30, 2024
06:39 AM
Solved!!
... View more
‎Sep 20, 2024
04:44 AM
Hi, I'm trying to create an Event Listener to use in Adobe InDesign, to alert me if the document contains RGB images. I tried this, but this is not working. Can you please correct the code for me. Also I want the same listener for Illustrator as well. //DESCRIPTION: Event Listener to check if the document contains any RGB images
#targetengine "save"
app.addEventListener("beforeSave", function () {
var doc = app.documents[0];
for (var i = 0; i < doc.allGraphics.length; i++) {
try {
var img = doc.allGraphics[i];
// Only check raster images (e.g., JPEG, PNG, TIFF)
if (img.constructor.name === "Image") {
if (img.imageColorSpace === ColorSpace.RGB) {
alert("Document contains RGB image(s). Please convert them to CMYK!");
break;
}
}
} catch (e) {
// Handle errors silently
}
}
});
... View more