Skip to main content
tpk1982
Legend
June 20, 2017
Question

PNG creation with modified date

  • June 20, 2017
  • 1 reply
  • 1992 views

HI,

The following steps are doing.

1) Open two indesign files. One is source and another one is final file.

2) Based on modified date I need to create the png with file naming as _source and _final.

mains(); 

function mains() {     

    var docSou = app.documents[0];

    var docFin = app.documents[1];

    var SouName = File(docSou.fullName);  

    var FinName = File(docFin.fullName); 

    var modifiedDate1= SouName.modified; 

    var modifiedDate2= FinName.modified; 

   

    mycheck1();

   

    function mycheck1(){

        if(modifiedDate1<modifiedDate2){

            var docName =docSou.name.replace(/\.[^\.]+$/, '_source');

            set_png_export_options(); 

            var file = new File("~/Desktop"+"/"+docName+".png");             

            docSou.exportFile(ExportFormat.PNG_FORMAT, file); 

            mycheck2();

            exit();

        }

        else{

            var docName =docFin.name.replace(/\.[^\.]+$/, '_final');

            set_png_export_options(); 

            var file = new File("~/Desktop"+"/"+docName+".png"); 

            docFin.exportFile(ExportFormat.PNG_FORMAT, file); 

            mycheck3();

            exit();

        }

    }

function mycheck2(){

    var docName =docFin.name.replace(/\.[^\.]+$/, '_final');

    var file = new File("~/Desktop"+"/"+docName+".png"); 

    docFin.exportFile(ExportFormat.PNG_FORMAT, file); 

    }

function mycheck3(){

    var docName =docSou.name.replace(/\.[^\.]+$/, '_source');

    var file = new File("~/Desktop"+"/"+docName+".png");             

    docSou.exportFile(ExportFormat.PNG_FORMAT, file); 

    }

 

function set_png_export_options() { 

    with(app.pngExportPreferences) { 

        antiAlias = true; 

        embedColorProfile = true; 

        exportResolution =  1600; 

        exportingSpread = true; 

        PNGColorSpace = PNGColorSpaceEnum.RGB; 

        PNGExportRange = PNGExportRangeEnum.EXPORT_ALL; 

        PNGQuality = PNGQualityEnum.MAXIMUM; 

        simulateOverprint = false; 

        transparentBackground = false; 

        useDocumentBleeds = true; 

    } 

  

But it always show the first document as _source.

Could you please suggest where I am missing.

Regards,

K

This topic has been closed for replies.

1 reply

tpk1982
tpk1982Author
Legend
June 21, 2017

Hi,

Any suggestion please, I know I am very close to the solution, but not able to find out that!!

Thanks,

K

vinothr
Inspiring
June 21, 2017

I am not sure what you are trying to achieve.

But I am wondering why you are exporting twice.

In the function mycheck1:

Inside IF you export to file with "_source" name.

Also you call mycheck2() which exports to file with "_final" name.

Same in the else block also.

So, essentially you seem to overwrite the file.

Please check if you intend to do so.

I believe with some traces you should be able to figure out.

tpk1982
tpk1982Author
Legend
June 21, 2017

Hi,

Thanks for your reply. If you see the first code, I am taking two indesign file. One is source and another one is final file. So I am exporting twice. So i not overriding.

Thanks,

K