Skip to main content
karolcholewa
Known Participant
July 27, 2015
Question

Convert EPS to PDF with Artboard Resize

  • July 27, 2015
  • 1 reply
  • 766 views

Hi,

I needed a script for a batch conversion from EPS to PDF files. In addition, the output PDF had to fit into A4/Letter size documentation page.

I've created one and now as I've tested it and it won't make any harm to your machine, I am sharing the script on Github.

Feel free to use it and modify it.

This topic has been closed for replies.

1 reply

pixxxelschubser
Community Expert
Community Expert
July 27, 2015

Hi karolcholewa‌,

do you have any questions?

I did not tested your script, but IMHO this part cannot works:

//Sometimes the file contains hidden layers and I want to remove all hidden layers

function removeHiddenLayers(doc) {

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

        var activeLayer = doc.layers;

        if (!activeLayer.visible) {

            activeLayer.visible = true;

            activeLayer.locked = false;

            activeLayer.remove();

            }

        }

    };

In this case it is better to loop backwards like this:

for (var i = doc.layers.length -1; i >=0; i) {

Have fun

karolcholewa
Known Participant
July 27, 2015

Thanks for spotting this. What's the difference between iterating from  bottom up VS top down?

pixxxelschubser
Community Expert
Community Expert
July 27, 2015

You remove layers. And that's why you cannot reach all layers while looping forward.

By the way: Sorry, i forgotten the -- at the end

for (var i = doc.layers.length -1; i >=0; i--) {

This is the correct one.