Skip to main content
January 20, 2009
Question

Problem relink Image - CORBA

  • January 20, 2009
  • 4 replies
  • 892 views
Hallo!

My CS3 Document contains one Rectangle with one Image.
Now I want to change the Image via CS3 Server Java / CORBA Plugin.
After running the code, InD changes the Link, but i can't see the new
image in the Rectangle.
One information for the following Source-Code:
the method startServer initialize the InD-Session and returns the
opened Document as Object of Type Document.
Here is the code:

startServer();
Rectangle ra = doc.getNthChildRectangle(0);
int recId = ra.getId();
Image image = ra.getNthChildImage(0);
int imgId = image.getId();
Link link = image.getItemLink();
int linkId = link.getId();
System.out.println("RectAngleID: " + recId);
System.out.println("ImageID: " + imgId);
System.out.println("LinkID: "+linkId);
link.relink("/Users/fklaes/Downloads/1.jpg");
link.update();
linkId = link.getId();
System.out.println("LinkID: " + linkId);
imgId = image.getId();
System.out.println("ImageID: " + imgId);
recId = ra.getId();
System.out.println("RectAngleID: " + recId);

doc.save(OptArg.noFile(),
OptArg.noBoolean(),
OptArg.noString(),
OptArg.noBoolean());
stopServer();
<-- This lines you can see in the console -->

RectAngleID: 198
ImageID: 319
LinkID: 320
LinkID: 0
ImageID: 0
RectAngleID: 198

I don't know what's wrong in this snippet.
Thanks for your answers.
This topic has been closed for replies.

4 replies

January 26, 2009
Thanks for your help!

That's the way I tried to implement the Update Link Part.
In Java I can't handle the File Object with the InDesign relink
Method. I can only work with a String. :-(

Thanks a lot for you fast answer and help.

For Java / CORBA there must be another way to give the rectangle the Link-Object.
January 26, 2009
Hi,

her a javaScript example. I think, u need a File Object. ...relink(File( newLink ));...
I hope this help u.

main();
function main(){
var myDocument = app.activeDocument;
var newPath = /Volumes/Macintosh/Bilder;
for(var myCounter = 0; myCounter < myDocument.allGraphics.length; myCounter++){
var myGraphic = myDocument.allGraphics[myCounter];
var graphicName = myGraphic.itemLink.name;
var myRegExp = new RegExp(/^_.*_(.*)\.indd$/);
var docName = myDocument.name.replace(myRegExp, "$1");
var newLink = newPath + "/" + docName + "/Links/" + graphicName;
var datei = new File( newLink );
if(datei.exists == true){
// Link löschen
myGraphic.itemLink.relink(File( newLink ));
// Link neu verknüpfen
myGraphic.itemLink.update(File( newLink ));
}
else{
alert("Die Datei " + newLink + " ist nicht vorhanden. Bild oder Grafik wurde nicht gewechselt!");
}
}
}
January 26, 2009
Hello Andreas!

My Link Status is Normal!
After relinking and updateing the Link, do i have to update the rectangle, also?

If I have to do that, how can I update the rectangle?
What functions or interface do you use for that?
Can you send me a little Code Snippet, if you have written the
part in JavaScript?

Thanks for your help.

Best regards
Fabian
January 25, 2009
Hi Nitro,

i do not have experience with Java. I program only with Javascript. With Javascript I would test the link status (link.status;). Which response do you get?

Greeting Andreas