Twitter Updates

Jan 10, 2010

IDML: About Self of Attribute and ID of Property

Is it possible to select page items on an InDesign document associated with elements of IDML? It is written like this on idml-specification.pdf :

8.2 IDML Component Names An IDML component name can only be defined for a spread, story, or master spread. In an IDML package, each instance of these elements appears as a separate file. The component name is used as the file name for an object instance and it’s also used to refer to the file in designmap.xml. Note the component name does not change the value of the self attribute of the element.
8.2.4 Scripting Interface Component names can be accessed through the IDMLComponentName property on spread, story, and master spread objects.

Are they only spread, story and master spread objects? If so, can’t we mutually refer to other objects and their elements? For example text frame, rectangle and other things. I tried to test the matter with scripts.

  1. Selected any element of page items had attribute “Self” and got the value.
  2. Removed a character, u or U that was the first value of the attribute.
  3. Treated the value as hexadecimal digit sequence, and converted it to decimal digit sequence.
  4. Selected a page item using the decimal number on the document of InDesign. Used following the script:
display dialog "Enter a number for searching a page item." default answer ""
set id_number to (text returned of result) as integer

tell application "Adobe InDesign CS4"
  tell active document
    try
      set a_object to page item id id_number
    on error
      tell application "Finder" to display dialog "It seemed that you entered the wrong."
      error number -128
    end try
    
    if not (show_object of me given a_reference:a_object) then
      tell application "Finder" to display dialog "It failed selecting the page item."
      error number -128
    end if
  end tell
end tell

--------------------------------------------------------------------------------
on show_object given a_reference:a_object
  tell application "Adobe InDesign CS4"
    try
      tell active window to set current_zoom_oar to zoom percentage
      tell active document to select a_object
      tell active window to set zoom percentage to current_zoom_oar
    on error
      return false
    end try
    return true
  end tell
end show_object

The test was successful. It’s possible to access the page item using the value of Self attribute. But note when the IDML package was opened by InDesign, there are cases that a different UID was created on the document. Read following the paragraph:

8.2.3 Reset Component Name on Import When an IDML package is opened by InDesign, user-defined component names will be saved in the document so they can be used when the document is exported (that is, they are preserved for round-trip). Default names are not saved with the document because the object created during import may have a different UID. A new default name is generated when the document is exported.

It seems that when the document is exported is when an IDML package file is opened by InDesign application. In other words, when a IDML package is opened by InDesign application, there are nothing way to accuses page items(InDesign’s objects) on the document from elements I myself newly added to spread XML. The elements have not a key for accessing directly. If we try to find a page item associated with an element I made, it seems that we should make up a absolute path tracing a relative reference from spread’s, story’s and master spread’s element.

In a case of an element of IDML package that was exported from already existing InDesign’s document, of course it’s possible to access from the element. The opposite is true.

Would anybody tell me whether above my understanding is true or false?

Dec 25, 2009

Environment Variables on Remote Machines

I realized that it is not able to get a clone in remote Git server running on Mac OS X last week. Git said that command git-upload-pack was not found, though I can confirm a path of environment variable on both of my local machine and remote server. It seems to need the option to access the git server via SSH at the time using clone command. So I added an alias to ~/.gitconfig file.

[alias]
rclone = clone --upload-pack=/usr/local/git/bin/git-upload-pack
rpush  = push  --receive-pack=/usr/local/git/bin/git-receive-pack

But this way needs to also make other aliases: push, fetch and perhaps pull. Maybe there are and much more. I think that to setting aliases is not ultimate solution. I searched google for sshd_config and PermitUserEnvironment but I couldn’t resolve this problem, environment variable via SSH.

ssh my_account@my_domain echo \$PATH

Not including needful path in the result of above command is the point of occasion.

I read this blog. I made symbolic links in /usr/bin but I couldn’t fixed. I have suffered all through the day. That‘s enough! I have abandoned to fix it.

Dec 7, 2009

Package Method of IDMLTOOLS.jar

I resumed researching IDML from today and brushed up things I checked out until this spring. Once I wrote an entry about package of IDML. The script in that page is to generate a package from the frontmost document. The following script is to decompress an idml package file. It doesn’t need a system environment that is installed InDesign. I prepared a perl script to understand how to use java applets. It’s verbosity because I want to write an explicit script.

Package method with '-d' option of idmltools.jar makes me confused many times when a destination directory doesn’t exist. So this script automatically makes the destination directory.

#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use open ":utf8";
use open ":std";
use File::Path;

my $IDMLTOOLS_HOME = `printenv IDMLTOOLS_HOME`;
my $command        = 'java';
my @java_argv      = ();
chomp $IDMLTOOLS_HOME;
$java_argv[0] = '-classpath';
$java_argv[1] = "$IDMLTOOLS_HOME/jars/idmltools.jar";
$java_argv[2] = 'com.adobe.idml.Package';

map { utf8::decode( $_ ) } @ARGV;
if ( $ARGV[0] eq '-h' ){
    `$command @java_argv '-h'`;
    exit;
}
elsif ( ! $IDMLTOOLS_HOME ) {
    die "Please define the environment variable IDMLTOOLS_HOME.\n";
}

if( $ARGV[0] eq '-c' and $ARGV[2] !~ /\.idml$/ ){
    $ARGV[2] .= '.idml';
}
elsif( $ARGV[0] eq '-d' and  ! -e $ARGV[2] ){
    umask 0;
    mkpath( ( $ARGV[2] ), {verbose => 0, mode => 0777} ) or die $!;
}

`$command @java_argv @ARGV`;

 
Cross the Sea - Templates Novo Blogger