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

Script exporting multiple sinlge page PDF's named as database field from multiple page InDesign file

Community Beginner ,
Jan 20, 2025 Jan 20, 2025

I want to create labels to put on carboard boxes containing products, the labels have product information om them, text and logos. The data comes from an Excel database.

So I found a software to handle this. Teacup bar code maker & Teacup data linker.

 

Then comes the next problem. What I want to do is to auto generate let’s say for example 25 labels with the push of a button (once I have set up the template for the label) with data from a database.

 

Then I want these labels to be exported from Indesign as separate PDF documents, each page/label, named with a prefix and the item code for the specific item, for example “Outer box label 123123” (“Prefix Item code”)

 

I've been told this can be done with a script, but I have none whatsoever experience in scripting. Does anyone know if a script like this exist or if I can get someone to produce it for me?

 

Best regards Fredrik

 

TOPICS
Scripting
936
Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

If you share an example INDD file with information from which "places" on the page information should be extracted - someone here should be able to help you - either for free or for a fee. 

 

Translate
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 ,
Jan 21, 2025 Jan 21, 2025

OK. So hoefully someone can help me 🙂

Here is the sample file that I have created. (Before I buy the software this is a testfile to see if this works as I want it too so this is made with the trial software.)

I have created the template, and linked information from the database as I want to.

I tested to do an export to separate PDF files and this works as I want it to.

 

The only thing left now is to be able to export these pages as separate PDF files with the naming I want it to have.

 

I have attaced the InDesign file. I have also attached an image of the item code I want to be part of the name. It's marked in yellow. The Item code is called "artnr" in the database I use. 

I have also attached the sample database.

 

The software I will use is called Teacup DataLinker

The thing is, that I will create different template files for different types of products so the item number (artnr) will not always be in the same place as in the template attached.

 

Is it possible to get the script to collect the name from the data base?

I aslo want a prefix specifying what type of label it is. Outer packaging or inner packaging pallet and perhaps something else that I can't think of now, so I need to be able to change the prefix.

 

So it should be named 

"Prefix Item code"

 

So for example " Outer packaging label 101131-E" or "Inner packaging label 101132-E"

 

Best regards Fredrik

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

I'm not sure you really need TeaCup for that...

 

It's simple enough for DataMerge - unless, you need to be able to constantly update / synchornise data...

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

They've "flattened" your XML:

 

RobertatIDTasker_0-1737482812953.png

 

This should look more like in your CSV file - more columns and less rows.

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

If they would've left ParaStyles or CharStyles - it would be much easier:

 

RobertatIDTasker_0-1737482930625.png

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

But even without Styles - it's not a big deal for my tool:

 

RobertatIDTasker_0-1737483361905.png

 

I've sorted by POS Y and PAGE INDEX - green rects - to get first TFs on pages sorted together.

Your codes for file names - red rectangle.

 

Now I just need to prepare extra Tasks to export - but that's piece of cake.

 

 

My tool isn't free (everything that can be seen on screenshots is available in the free version) - and PC only (from your file I can see that you work on Windows) - but if you have a lot of this kind of stuff to do...

 

My tool could even build those tickets for you - so you could have a true one-click-solution - XLS->PDF(s)->upload-to-ftp or whatever.

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

Here is an example of DataMerge solution - built-in free solution - but without export:

 

RobertatIDTasker_1-1737484286685.png

 

And here is an example of final document:

 

RobertatIDTasker_2-1737484458471.png

 

Of course you would've to do something with BarCodes...

 

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

Attached are both INDD files - DataMerge template and example file.

 

Database you already have - so just download those files to the same folder as your CSV file.

 

I've also re-uploaded IDML versions.

 

You'll get a lot of oversets - just edit ParaStyles - I made texts bigger for the Pages Panel preview.

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

Looking at the price of the TeaCup...

 

Here is a free solution to export named PDFs: 

 

https://creativepro.com/data-merging-individual-records-separate-pdfs/

 

I'll also try to find script that takes info from objects on pages - I think someone posted one some time ago.

 

Translate
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 ,
Jan 21, 2025 Jan 21, 2025

Thank you. 

 

I will check your files tomorrow, its late heter in Sweden now. 

 

But does this solution allow me to create bar codes?

 

I cant sen to find any solution except teacuo that can handle bar codes.

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

You're welcome. 

 

Yes, the only "problem" is in generating barcodes.

 

TeaCup isn't the only solution / generator. 

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

There are two more ways you can avoid using TeaCup - if you don't need updates and can just re-generate everything from sratch if needed:

 

1) You could export XML from Excel.

2) You could export InDesign Tagged Text from Excel.

 

And if your labels are so simple - my tool also would be an overkill... Unless you need true one-click-solution and you have a lot of labels to produce.

 

So you only need a way to generate barcodes.

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

And here is a bit "quick and dirty" solution for exporting your pages 😉

 

You would've to export from Excel script with structure like this:

 

 

export_page(page_num, folder, pdf_file_name);
export_page(page_num, folder, pdf_file_name);
export_page(page_num, folder, pdf_file_name);
export_page(page_num, folder, pdf_file_name);
//...

 

 

Where in each row, istead of "page_num" you would simply put row/record number of the CSV file - which is page number in your final INDD file, instead of "folder" - full destination path, instead of "pdf_file_name" - I'm sure you know what 😉

 

Then, at the end - add this:

 

 

function export_page(page, folder, name) {
    var pdf_file = File(folder + '/' + name + '.pdf');
    app.pdfExportPreferences.pageRange = page;
    doc.exportFile(ExportFormat.pdfType, pdf_file, false, pdf_preset);
}

 

 

So your sample script could look like this:

 

 

var pdf_preset = app.pdfExportPresets[0]; // High Quality Print

export_page('1', 'c:\\IDT\\', 'Outer packaging label 101131-E');
export_page('2', 'c:\\IDT\\', 'Outer packaging label 101132-E');

function export_page(page, folder, name) 
{
    var pdf_file = File(folder + '/' + name + '.pdf');
    app.pdfExportPreferences.pageRange = page;
    app.activeDocument.exportFile(ExportFormat.pdfType, pdf_file, false, pdf_preset);
}

 

 

TESTED - works 😉

 

RobertatIDTasker_1-1737499475034.png

 

 

So, again, you only need to find solution for generating barcodes.

 

Translate
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
LEGEND ,
Jan 21, 2025 Jan 21, 2025

This way - you can even name your PDFs using information that's not present in the INDD Document 😄 

 

Translate
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 ,
Jan 21, 2025 Jan 21, 2025

This is fantastic.

 

Thank you very much 🙏

I just woke up here so I will test this during the day.

 

And for the labels. i have a lot of labels to produce so, thousands for the coming years, soI need to find an easy solution to work with.

Translate
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
LEGEND ,
Jan 22, 2025 Jan 22, 2025

You're welcome. 

 

You've 3x options to generate labels - all free:

1) using InDesign's built-in DataMerge - I've already posted sample files(*), 

2) export XML from Excel, 

3) export InDesign Tagged Text from Excel, 

 

So, again, you only nerd to find a way to generate barcodes. 

 

(*) I skipped there placing barcodes as images - but if you'll have files with barcodes on your drive - DataMerge will import them automatically.

 

Translate
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
LEGEND ,
Jan 22, 2025 Jan 22, 2025

OR...

 

Any chance you can switch to QR codes? 

 

Those InDesign can generate by itself... 

 

Translate
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 ,
Jan 22, 2025 Jan 22, 2025

No, it needs to be bar codes.

 

Again, thanks. I'll try to figure this out somehow. Put all the pieces together.

 

Best regards Fredrik 

Translate
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
LEGEND ,
Jan 22, 2025 Jan 22, 2025

https://barcode.tec-it.com/en/EAN13

 

You're welcome 😉

 

RobertatIDTasker_0-1737553943532.png

2nd code is incorrect - I've just replaced "2" at the end with "3" - to show that it works.

 

 

RobertatIDTasker_1-1737554044261.png

 

RobertatIDTasker_2-1737554079304.png

 

Translate
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
LEGEND ,
Jan 22, 2025 Jan 22, 2025
LATEST

Or, instead of graphic objects - it can be done as Text:

 

RobertatIDTasker_0-1737556046428.png

(but it's more for future reference than for you directly Fredrik)

 

Translate
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