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

Batch export PDF/PNG with custom file names (csv variable library)

Community Beginner ,
Jan 19, 2022 Jan 19, 2022

Hi there,
I'm still fairly new to Illustrator, so hope someone can help me out.


What I want to achieve:

I want to automate some tasks and thus, be able to import a .csv spreadsheet as a variable library that creates x no. of datasets with different headlines, images and a source/text.

I want to be able to batch export these as both pdf and png (png = zoom 300%, clipped to arboard) as individual files (2 for each dataset) with a custom name for each dataset based on some variable. See the example below where I have imported the variable library. If I can export as pdf and png with name = HeadlineVariable (object name) for each dataset - that would be ideal:

default1ep727ek5sdt_1-1642615008914.pngexpand image

All exports can go to the same folder. It is fine if this is the same folder each time, say called "export" in some specific path. However, ideally I would want 2 subfolders in "export" called "pdf" and "png" - but not necessary.

 

Where I am currently:

I can import my csv sheet and see my different datasets which are all showing correctly as I cycle through them.

However, I do not know how to batch export these with a custom name for each. Seems like it will only let me name them as the dataset name, or filename + number, etc.

Normally I would achieve something like this using recorded actions, however, I don't know how to do this using datasets with a custom name for each as explained above:

default1ep727ek5sdt_0-1642614874774.pngexpand image

Not sure if I need a script. If so, I have never used scripts before and would like some help setting this up.

 

Thanks,
Rasmus

TOPICS
Import and export , Scripting
8.3K
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
Adobe
Mentor ,
Jan 19, 2022 Jan 19, 2022

Use actions, take a look at this: https://www.youtube.com/watch?v=sW70hB_WeWM

If you have hundreds, or THOUSANDS of graphics to create with the same layout, variable data merge might be the way to go. Learn how to set up one document to pull variables from a spreadsheet in this video! Join our FREE Illustrator Facebook Group: ...
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 19, 2022 Jan 19, 2022

I just had a quick look.
She is just doing a batch export (using actions as I'm also able to do) and naming the png files as 'filename + data set'.

What I want to accomplish is to give each exported data set a custom name.

 

In the video she has got 4 variables (imported). 2 text variables and 2 image variables. If I can give each file (pdf & png) a name that matches one of my text variables - that would be perfect. However, options are very limited:

default1ep727ek5sdt_0-1642619862028.pngexpand image

Variable 1 ('HeadlineVariable' in my case) is unique for each imported dataset. This is my desired filename for each of the exported pdf's and png's.

If i can somehow change Data Set names so it always matches one of my variables (unique) for each file - that would work.

 

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
Mentor ,
Jan 19, 2022 Jan 19, 2022

I would think you could do this by running a script using the same variable data file to rename the files.

Not something I can help you write, but I hope someone can help, as this seems adaptable to a variety of projects.

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
Valorous Hero ,
Jan 19, 2022 Jan 19, 2022
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 19, 2022 Jan 19, 2022

That indeed looks like what I need. However, I have now tried it.. and it does not work for me for some reason.


I download the script and open it. I choose my file path (.csv sheet). I assign data set names to one of my variables.
It even gives me the option to test data set names and images before I import data - and it looks correct! Problem is, when I then click import none of the variables change in my file. Data set names are correct, however, image, headline and my other text variable do not change whatsoever.
Ps. Also, when importing it gives me this message, which I don't know why:

default1ep727ek5sdt_0-1642639128522.pngexpand image

In this example I try to import 7 datasets, each with 3 variables. But the 'Cycle' button does not do anything.

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 19, 2022 Jan 19, 2022

Not sure if I'm missing a step or something else in the script settings? I've looked through all options and tested some.

Normally, when importing variable libraries, I just import it and it replaces 3 variables in the file by matching it with the header in my .csv. I do not need to do anything else..

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
Valorous Hero ,
Jan 19, 2022 Jan 19, 2022

There's a test thing that lets you make sure you have the proper bindings. Otherwise you'd have to use the variables panel to make sure your variables are bound.
That message isn't that important, it's really for when you are doing some graphs with advanced data and an asterisk appears by the dataset when it's imported automatically (or have multiple visibility variables which can do the same thing).. it's rare what I'm talking about but for those who need it, this button solves those issues.

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 20, 2022 Jan 20, 2022

Well, then it's just a mystery to me why it is not working. It asks me to overwrite my existing 3 variables, I say OK, and then nothing really.
It seems like it does not update the variable 'objects', but removes them in fact:

default1ep727ek5sdt_1-1642684423611.pngexpand image

Before using the script to import variables (my standard work file upon opening):

default1ep727ek5sdt_2-1642684579876.pngexpand image

 

Only thing that seems to work as intended is that it updates the dataset names.

Using the script: Testing dataset names yields correct names, testing image files shows correct paths, testing art bindings (whatever that is) does not seem to find anything?:

default1ep727ek5sdt_0-1642684251941.pngexpand image

 

I really appreciate any help I can get as this would make it possible to automate many tasks.
Thanks,

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
Valorous Hero ,
Jan 20, 2022 Jan 20, 2022

If you want to import the variables that already exist without rebinding them, use the no-auto-binding option.

When auto bind by name is used it will try to find the 'name' in the layers panel of the art object.

So you can either use no auto binding or use named auto binding but ensure your text is named in the layers panel "ImageVariable" and "SourceVariable".

There could be confusion if you do have your text frame's text as "SourceVariable" - make sure the text inside does not say this at the start! It has to be different. 

 

SillyV_0-1642685348897.pngexpand image

SillyV_1-1642685729715.pngexpand imageSillyV_2-1642685769453.pngexpand image

 

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 20, 2022 Jan 20, 2022

Thank you,

So far, so good. They are all showing correctly in the project file and with the desired data set names.

 

I've got 2 problems though. If I can solve them everything will work as intended.

 

Problem 1:

When i batch export my data sets (using a saved/recorded action) I get the correct number of files with correct names, etc. However, images are missing.
To my knowledge, I need to embed the images before exporting as pdf. So far I've done this using individual project files. However, I cannot seem to do this automatically for all files using datasets.

 

I tried recording an action where it imbeds an image - does not work.

If I manually imbed an image and batch export, all files show the same image.

Not sure how to go about this? Cannot find anything useful in setting for exporting pdf.

 

Problem 2:

When exporting as PNG, again using a recorded action, it is able to show images without embedding. Problem is, that for some reason it only exports one png file, and the file is named the same as my project file even though i select "data set name" in output settings when batch exporting. This is an even bigger mystery to me than Problem 1, since the process is the same (record action -> batch export -> choose data set name for output file).

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
Valorous Hero ,
Jan 20, 2022 Jan 20, 2022

Make sure you have the Override Export commands as well as the save commands checkbox checked in the Batch Actions dialog.

It is understandable that linked placed files disappear in the exported PDFs. It's because they are pointing to a different location than where they get written-to, probably, no longer having access to those file paths.

For example, if the linked files are in a "Links" folder, maybe all folders.

So you have at first, the option to export to a more ancient PDF format that automatically embeds images.

Your desired method to having Illustrator work properly and record the embedding command unfortunately is a known issue that has not been fixed in many years. However, even if you were to embed the images, if they were dynamic images whose file paths were supplied by the CSV and the file is written to a drive where those files cannot be found, then the variable image object will become destroyed and it can't replace its image on the next dataset. You would have to run an extra script every dataset which can be put into a batch action with the Insert Menu command. This script would have to duplicate your linked item, hide the original and embed the copy via scripting commands which luckily work.
Then the very first thing your batch action would have to do is 'unhide all', to reveal any items which were previously hidden by the last run.
Even then, you will end up with PDFs that have a hidden layer and that image may not be found and it may produce a non-found image dialog box.
But, can you try to first output all the PDF-files as AI files instead?
There is an option to include linked files, maybe it means they will be embedded. And afterwards you can go through with a Folder batch action to resave them all as PDF in the same place.

SillyV_0-1642706294345.pngexpand image

 

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 20, 2022 Jan 20, 2022
LATEST

Thanks again,

Your work-around seems to work.
I simply batch export as AI to a different folder an get individual files for each set which seem to have images imbedded. Then I open one of them and batch export all files from the folder to a different one as pdf and png.
PDF exports work as intended. When I export as png I get the correct png's, however, additionally I get the AI files too (duplicates at this point). Seems like something I can figure out how to solve though - or can just easily be deleted manually.

 

So everything is working. Not as automated as hoped, but still much much faster than originally. So thank you agian.

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