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

PDF- Filename automated from labelscript (after data merge)

Community Beginner ,
Oct 06, 2011 Oct 06, 2011

Copy link to clipboard

Copied

Hello,

first of all I'm quite new in javascripting... but some simular scripts I have found on the internet could provide a solution for my problem.

What I've done is the following:  I've used Data Merge and created a 200-paged file with 1 label on each page. Each label has a labelnumber.

What I could do is export the file - split it up in 200 different pages - rename each file to the specific labelname. Seems a lot of work and this job I need to repeat about once a month.

I looked for a solution and came to these discussion: http://forums.adobe.com/thread/289666http://      http://forums.adobe.com/message/3178412#3178412

What I want to create is a script that I can run every month after I have updated my 200 labels and overrides all the pdf-files of the old labels.

With the different scripts I have found I constructed the code below.

The script works, it prints to multiple pdf's which have the correct labelnames, export is according to the requested presets,  but the CONTENT of each label is the content of the FIRST label (first page).

I have tried a lot of thing (trail&error) but as I said, I'm quite new to this matter...

So.... I can use some help or advice on this one.

Thanks in advance,

Dheart

function getLABEL_A(page) {

          for (var  currentTextFrameIndex=0;currentTextFrameIndex<page.textFrames.length; ++currentTextFrameIndex) { // Iterates over frames

               if (page.textFrames[currentTextFrameIndex].label=="LABEL_A") // if label is LABEL_A..

                    return page.textFrames[currentTextFrameIndex].contents; // ..returns text frame contents

          }

          return null; // if not found, returns null

    }

var LABEL_A;

     var pagesList=app.activeDocument.pages;

     for (var currentPageIndex=0;currentPageIndex<pagesList.length;++currentPageIndex) { // Iterates over pages list

          currentPage=pagesList[currentPageIndex];

          LABEL_A=getLABEL_A(currentPage);

          if (LABEL_A!=null) { // If we have a LABEL_A - PDF file name-

                var export_preset = app.pdfExportPresets.item("[Smallest File Size]");

               app.activeDocument.exportFile(ExportFormat.pdfType,"F:/.../"+LABEL_A+".PDF",false,export_preset); //.. and save the file

          } else {

               alert("Page number "+currentPageIndex+" NO LABEL_A");

               alert(LABEL_A);

          }

     }

TOPICS
Scripting

Views

1.3K

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

correct answers 1 Correct answer

Community Beginner , Oct 08, 2011 Oct 08, 2011

Thx for the reply, indeed this is a solution for consecutive numbering, however, the numbering is following another 'system' and in this case the numbering is given randomly.

Anyway, trying a lot of things,  gave me a working script!!!

The script exports a multipaged indesign file to single-paged pdf files. The namegiving of the pdf-files is automated and follows a labelscript (textlabel) on each page.

function getLABEL(page) {

          for (var  currentTextFrameIndex=0;currentTextFrameIndex<page.

...

Votes

Translate

Translate
Community Beginner ,
Oct 08, 2011 Oct 08, 2011

Copy link to clipboard

Copied

Does anyone see why the code generates every label with the same content of the first page?

Maybe this can be helpfull so I know what to look for.

Thanks in advance!

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
Community Expert ,
Oct 08, 2011 Oct 08, 2011

Copy link to clipboard

Copied

are the label numbers consecutive and logical; or are they all over the show and more than numbers?

there is a cheat's way to do something similar using acrobat and bridge.

take a large PDF and go to the extract pages feature in acrobat. go from page 1 to the last page and make sure that "extract as individual pages" is turned on. a new dialog appears asking where to save this - choose a directory where to save the files to. once done, close out of acrobat.

if indesign's data merge feature allowed exporting to specific page lengths, this would be possible to do directly in indesign; (and the dialog is there to do it) but it doesn't work. i've reported this as a bug and encourage others to do so.

ANYWAY... next, in bridge, navigate to the folder which the single page files have been exported to. from here, go to tools options and go batch rename. from here, it is possible to completely rename or add to filenames, including sequence numbers.

this is all i can think of i'm afraid.

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

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
Community Beginner ,
Oct 08, 2011 Oct 08, 2011

Copy link to clipboard

Copied

LATEST

Thx for the reply, indeed this is a solution for consecutive numbering, however, the numbering is following another 'system' and in this case the numbering is given randomly.

Anyway, trying a lot of things,  gave me a working script!!!

The script exports a multipaged indesign file to single-paged pdf files. The namegiving of the pdf-files is automated and follows a labelscript (textlabel) on each page.

function getLABEL(page) {

          for (var  currentTextFrameIndex=0;currentTextFrameIndex<page.textFrames.length; ++currentTextFrameIndex) { // Iterates over frames

               if (page.textFrames[currentTextFrameIndex].label=="LABEL") // if label is LABEL..

                    return page.textFrames[currentTextFrameIndex].contents; // ..returns text frame contents

          }

          return null; // if not found, returns null

    }

var LABEL;

     var currentPage;

     var pagesList=app.activeDocument.pages;

     for (var currentPageIndex=0;currentPageIndex<pagesList.length;++currentPageIndex) { // Iterates over pages list

          currentPage=pagesList[currentPageIndex];

          LABEL=getLABEL(currentPage);

          if (LABEL!=null) { // If we have a LABEL PDF -file name-

              app.pdfExportPreferences.pageRange=String(currentPageIndex+1); // set up the export range..

                var export_preset = app.pdfExportPresets.item("[High Quality Print]");

                 app.activeDocument.exportFile(ExportFormat.pdfType,"F:// fill in destination"+LABEL+".PDF",false,export_preset); //.. and save the file

          } else {

               alert("Page number "+currentPageIndex+" without LABEL box");

               alert(LABEL);

          }

     }

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