Indesign (IDML file) Viewer using HTML5 and Javascript
Copy link to clipboard
Copied
I’m working on IDML file automation. My requirement is to showcase an IDML template in an HTML5 editor.
I have a simple TextFrame
with Hello World text. I saved the file as: sample.idml
. Then, I unzipped sample.idml
and got a few files. Went to the stories
folder and opened: story_d8.xml
.
Since I’m a developer, I did this using Java and exposed the file path as a REST call. The biggest stopping point is: the jQuery/AngularJS script is saying:invalid file.
Can someone suggest options to address the points below:
- Get
Content
data using JavaScript (jQuery/AngularJS) - Put "Demo Hello" in the
Content
and regeneratestory_d8.xml
(using JavaScript) - Is this the correct approach? Are there alternative to this approach?
Note: My Requirement is to modifying IDML file at client side (javascript) only.
Copy link to clipboard
Copied
Hi @krishnaraoveera1294 , I just tried to re-create the situation since you didn't provide any code or link to see what's going on, and I didn't have any issue to print out the content of the story_ID.idml to the browser,
I didn't use Angularjs however, since I didn't need it for this, you just need JQuery (and probably xml2json library if you wanna have JSON instead in your app), the process was actually simple but I'll put the code here if you want to have a look (it's the whole html):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
</head>
<body>
<pre class="result"></pre>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//cdn.jsdelivr.net/jquery.xml2json/1.2/jquery.xml2json.js" type="text/javascript" charset="utf-8" async defer></script>
<script type="text/javascript">
var mim;
$.ajax({
type: "POST",
url: "test.xml",
dataType: "xml",
success: function (data) {
mim = $.xml2json(data);
console.log(mim.Story.ParagraphStyleRange.CharacterStyleRange.Content);
}
});
</script>
</body>
</html>
mim,
Copy link to clipboard
Copied
Dear mim_armand
I tried the same. By the way, i using xml file path from tomcat7 webserver. like "url: "http://localhost:8080/APP/idemlfp/test.xml"
I'm getting CORS issue. My server not allowing me to read file from path.
later, I tried "dataType:jsonp" , browser console shows JSON parse error but getting xml file structure. :=)
i don't to know who to hack this. Kindly help out in this.
you can reach me @ my skype id: "krishnaraoveera1294"
Copy link to clipboard
Copied
Of-course You can't send requests to your server from anywhere just like that, if you wanna enable CORS on your server I guess your best bet is to looks somewhere else (not in InDesign extendScript forums) like here!
Then if your server respond with XML to your requests (and you can't change it server-side) I don't know why you try json-p! you can't work around same-origin-policy like that on client-side! it's either jsonp (server-side) or CORS enabled, no other solution or hacks is possible!
I'll be happy to help if I can but I can't do it in your place my friend
Goodluck,
m,

