• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

export jpg with specific filename

New Here ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

I have generated 500 labels with a XML file. On each label there is a number and a name.

What I now need to do is export it to JPG files.

The difficult part is I want to make the file names the "number" "underscore" "name" so for axemple 12345_Tom.

I have taged the number and name with "number" and "name".

Is there a way to do this with a script? I am not a programmer but a designer so I do not know that much about javascript and scripts in Indesign.

I hope somebody can help me!

TOPICS
Scripting

Views

864

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

Could you show a snippet of xml?

What is it that you want to export?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

I want to generate jpg files.

The xml is for example:

<labels>

     <label>

          <number>12345</number>

          <name>Tom</name>

     </labels>

     <label>

          <number>12346</number>

          <name>Chris</name>

     </label>

</labels>

I want the jpg's to have the filename's:

12345_Tom.jpg

12346_Chris.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

Did you import the xml in the document?

Are there any images in the document that you want to export?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

I have imported the xml, there are no images used.

The labels are fine there is no problem with the xml import or with the indesign file.

The problem is with the jpg export.

I can not controle the jpg filenames that every label gets, I can only give the first jpg label a name and the rest of the jpg labels have the same name including a number (1,2,3, etc..).

My question is, is this possible with a script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

Yes it is possible via scripting but you have to loop over each pageItem that you want to export and pass the desired filename:


pageItem.exportFile(ExportFormat.JPG, new File(filename));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

I have tryed the script but I get a error "pageItem is undefined".

How can I link "pagItem" to a text field?

Sorry like i mentioned I am a designer and not a programmer so this is not everyday work for me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 05, 2010 Nov 05, 2010

Copy link to clipboard

Copied

LATEST

You need to place every label in a textframe:

var labels = app.activeDocument.xmlElements[0].xmlElements;

for (var i=0; i<labels.length; i++){

var myPage = app.activeDocument.pages.add();

var myTextFrame = myPage.textFrames.add({geometricBounds:[0,0,100,100]});

myTextFrame.placeXML(labels);

}

This script loops through every label and places it in a textframe on a new page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines