Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InDesign and XML 1

Status
Not open for further replies.

raeben

Technical User
Nov 21, 2001
7
0
0
US
Has anyone experience importing and Exporting XML from InDesign on a PC?

We are facing a catalog job with a database-generated XML file for import into InDesign (or Quark XPress). This catalog has product titles, descriptions, images, and tables with order number, miscellaneous info and price.

How would InDesign handle the table imports? The graphics?

Any info you have would be appreciated.

Rae
 
It depends what version Indesign you have.
I use xml for paragraph styles (character styles are not possible in my current Indesign version) only. In indesign I made tags which I linked to paragraph styles (best to use the same name for tag and corresponding style) In your xml file you use the tag names for the required style. I do this in Indesign 2.0.2. I do not have experience with exporting xml, but I do know you have to tag text to be able to export it. The Xml feature in Indesign CS is much broader, but I do not have any experience with this. I believe there are a couple of forums on this site which deal with Indesign scripting, you should check these out.
 
I have quite the same idea - to get data from database to InDesign. There was a XML tutorial CD together with my InDesign 2. I was able to import XML data but first I had to make placeholders and set them to right structure - that's a lot of work if you have hundreds of items... I wonder if there is any way to set up placeholders and the structure more automatically?
 
Now, about a year later I found that I've posted here something ;) I'll explain how I solved my problem...

I used javaScript to enter data into InDesign3, instead of XML.

I had my data in mysql database, so, having some experience in web programming, I made a short php script and that script made me a very long (one line for each object) javascript. It took few minutes for InDesign to run the script and after that I had all my data on pages and places where I wanted it to be. And they even had right paragraph styles :)

The hardest thing to me was to learn how the Javascript I needed should look like.

Thanks!
Peeter
 
Dear Kraabus, this sounds like exactly what I need too!

I have an SQL database, PHP and need to extract and format into Indesign and don´t want to spend endless time figuring out the details of Indesign XML formatting.

Would you be willing to post some tips explaining how it's done with PHP and JS?


Regards,

Carl
 
Hi,

First I made javascript functions for different needs - here you can see 3 of them:


-------------
var myDocument=app.activeDocument;


function addtextbox(pagenr,x1,y1,x2,y2,tstyle,tcontents) {
with(myDocument){
with(pages.item(pagenr-1)){
tTextFrame=textFrames.add();
tTextFrame.geometricBounds=[y1,x1,y2,x2];
tTextFrame.contents=tcontents;
tTextFrame.texts.item(0).appliedParagraphStyle=tstyle;
}
}
}

function addtextboxwithstroke(pagenr,x1,y1,x2,y2,tstyle,tcontents,tstrokeWeight,tstrokeSwatch) {
with(myDocument){
with(pages.item(pagenr-1)){
tTextFrame=textFrames.add();
tTextFrame.geometricBounds=[y1,x1,y2,x2];
tTextFrame.contents=tcontents;
tTextFrame.strokeWeight=tstrokeWeight;
tTextFrame.cornerEffect=CornerEffects.roundedCorner;
tTextFrame.cornerRadius=0.5;
tTextFrame.strokeColor=swatches.item(tstrokeSwatch);
tTextFrame.texts.item(0).appliedParagraphStyle=tstyle;
}
}
}



function drawrectangle(pagenr,x1,y1,x2,y2,tFillSwatch) {
with(myDocument){
with(pages.item(pagenr-1)){
tRectangle=rectangles.add();
tRectangle.geometricBounds=[y1,x1,y2,x2];
tRectangle.fillColor=swatches.item(tFillSwatch);
tRectangle.strokeWeight=0;
}
}
}

--------------

Now I made php script that took data from my database, calculated the right page numbers and locations and printed out a lot of lines like this:

addtextbox(3,-20,122,-10,130,"style1","My text");

(if you look at function definitions, you'll probably understand what these numbers mean)

Now you can run the php script in your browser, save the result (source) as .js file (with the functions of course) to C:\Program Files\Adobe\Adobe InDesign CS\Presets\Scripts (or whatewer it may be in you system) and the run it from the script window.

Peeter
 
Hi again,

Thanks for posting the code snippets.
I can understand what the Javascript does, but since I have no experience with PHP, I don't know how to create a PHP script to extract the data from the database.How does the PHP script generate the JS? Can you expand on this please?

Thanks again!

Carl




 
Hi Carl,

It's pretty hard to give an universal code, as it depends on your database structure and document layout.

If it helps, I've uploaded my code here:
(sorry, the comments are in Estonian)

And here are some pages from the booklet:
(well, there was some work after running the script - placing pictures etc.)

Peeter
 
Thanks!

It is much easier when I can see the entire code.

Thank you again so much for your help!

Regards,

Carl
 
is there a plug-in or method technique for exporting Indesign paragraph styles into excel?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top