2 Replies Latest reply on Dec 11, 2011 4:12 PM by JR_Boulay

    Javascript for setting the CropBox Units in Millimetres

    alienA2 Level 1

      Hi

       

      I am looking for a Javascript for setting the CropBox Units in Millimetres.

       

      I have a pdf mag that needs the CropBox settings of all the units to be 7.408 mm.

       

      Any help pretty please?

       

      Thanks

        • 1. Re: Javascript for setting the CropBox Units in Millimetres
          George_Johnson MVP & Adobe Community Professional

          The units for the various page boxes are specified in points. There are 72 points per inch and there are 25.4 millimeters per inch. So you should have enough information to convert millimeters to points.

          • 2. Re: Javascript for setting the CropBox Units in Millimetres
            JR_Boulay Adobe Community Professional

            Hi,

             

            here is a sample script that put boxes size in Millimetres into custom properties metadatas fields.

            It can run from an Action, from the console, or from any form field (button…).

            Feel free to re-use/customize it.

             

            var mbox = this.getPageBox("Media");

            var Mzeroz = Math.round(mbox[0] * 0.3527);

            var Munz = Math.round(mbox[1] * 0.3527);

            var Mdeuz = Math.round(mbox[2] * 0.3527);

            var Mtroiz = Math.round(mbox[3] * 0.3527);

             

            var cbox = this.getPageBox("Crop");

            var Czeroz = Math.round(cbox[0] * 0.3527);

            var Cunz = Math.round(cbox[1] * 0.3527);

            var Cdeuz = Math.round(cbox[2] * 0.3527);

            var Ctroiz = Math.round(cbox[3] * 0.3527);

             

            var tbox = this.getPageBox("Trim");

            var Tzeroz = Math.round(tbox[0] * 0.3527);

            var Tunz = Math.round(tbox[1] * 0.3527);

            var Tdeuz = Math.round(tbox[2] * 0.3527);

            var Ttroiz = Math.round(tbox[3] * 0.3527);

             

            var bbox = this.getPageBox("Bleed");

            var Bzeroz = Math.round(bbox[0] * 0.3527);

            var Bunz = Math.round(bbox[1] * 0.3527);

            var Bdeuz = Math.round(bbox[2] * 0.3527);

            var Btroiz = Math.round(bbox[3] * 0.3527);

             

            var abox = this.getPageBox("Art");

            var Azeroz = Math.round(abox[0] * 0.3527);

            var Aunz = Math.round(abox[1] * 0.3527);

            var Adeuz = Math.round(abox[2] * 0.3527);

            var Atroiz = Math.round(abox[3] * 0.3527);

             

            if (app.language == "FRA")

            {

            this.info.Zone_de_media_en_mm = Mzeroz + ", " + Mdeuz + ", " + Munz + ", " + Mtroiz;

            this.info.Zone_de_recadrage_en_mm = Czeroz + ", " + Cdeuz + ", " + Cunz + ", " + Ctroiz;

            this.info.Zone_de_rognage_en_mm = Tzeroz + ", " + Tdeuz + ", " + Tunz + ", " + Ttroiz;

            this.info.Zone_de_fond_perdu_en_mm = Bzeroz + ", " + Bdeuz + ", " + Bunz + ", " + Btroiz;

            this.info.Zone_graphique_en_mm = Azeroz + ", " + Adeuz + ", " + Aunz + ", " + Atroiz;

            }

             

            else

            {

            this.info.MediaBox_in_mm = Mzeroz + ", " + Mdeuz + ", " + Munz + ", " + Mtroiz;

            this.info.CropBox_in_mm = Czeroz + ", " + Cdeuz + ", " + Cunz + ", " + Ctroiz;

            this.info.TrimBox_in_mm = Tzeroz + ", " + Tdeuz + ", " + Tunz + ", " + Ttroiz;

            this.info.BleedBox_in_mm = Bzeroz + ", " + Bdeuz + ", " + Bunz + ", " + Btroiz;

            this.info.ArtBox_in_mm = Azeroz + ", " + Adeuz + ", " + Aunz + ", " + Atroiz;

            }

             

            boxes.png