批量导出所有文本框架时如何排除MasterPage项目 [英] How to EXCLUDE MasterPage items when bulk exporting all text Frames

查看:54
本文介绍了批量导出所有文本框架时如何排除MasterPage项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从文件中导出所有文本框架时,脚本会看到母版页中的文本框架并弄乱了计算结果,并在最后给出了错误,因为这些框架已锁定且无法导出。

When I'm exporting all text frames from a file, the script sees the textframes in the masterpage and messes up the calculation and gives an error at the end because those frames are locked and can't be exported.

var myDoc = app.activeDocument;
var myFolder = myDoc.filePath;
var myImage = myDoc.textFrames;

var JPEGFolder = new Folder(myFolder+"/"+app.activeDocument.name+"_"+"JPEG");
if (!JPEGFolder.exists)
        JPEGFolder.create();  

var PromFolder = new Folder(myFolder+"/"+app.activeDocument.name+"_"+"Promethean");
if (!PromFolder.exists)
PromFolder.create();

var ToplamSoru = 0 ;

for (var i=0; myImage.length>i; i++)
    {
            app.select(myImage[i]);
            ToplamSoru = ToplamSoru +1;
    }

var Cevapli = (ToplamSoru/2-4);
alert(Cevapli);

app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum;
app.jpegExportPreferences.exportResolution = 150;

for (var p=0; p < myDoc.pages.length; p++)
{
        for (var i=0; myImage.length>i; i++)
            {
                if ( i <= Cevapli -1){
                    if( i < 9)
                        {
                        app.select(myImage[i]);
                        var SoruNo  = myImage[i].contents.substring(1,2);
                        app.selection[0].exportFile(ExportFormat.JPG, File(JPEGFolder+"/"+SoruNo+".JPEG"), false);
                        }
                    else
                        {
                        app.select(myImage[i]);
                        var SoruNo  = myImage[i].contents.substring(1,3);
                        app.selection[0].exportFile(ExportFormat.JPG, File(JPEGFolder+"/"+SoruNo+".JPEG"), false);
                        }
                    }
                else{
                    //alert(Cevapli);
                    if( i < 9 + Cevapli+1) 
                        {
                        app.select(myImage[i]);
                        var SoruNo  = myImage[i].contents.substring(1,2);
                        app.selection[0].exportFile(ExportFormat.JPG, File(PromFolder+"/"+SoruNo+".JPEG"), false);
                        }
                    else
                        {
                        app.select(myImage[i]);
                        var SoruNo  = myImage[i].contents.substring(1,3);
                        app.selection[0].exportFile(ExportFormat.JPG, File(PromFolder+"/"+SoruNo+".JPEG"), false);
                        }
                    }

            }
        }
alert ("Done")

基本上,当我运行代码时,一切正常,并按需要导出,但是当母版页中的文本框数量超过固定数目时,它将被搞砸。再来一次。

Basically, when i run the code, everything is OK and exported as wanted, but when there are more than the fixed number of text frames in the masterpage, it will be screwed up once again.

var Cevapli = (ToplamSoru/2-4);

在这里我减小变量的值,因为有2个母版页带有4个不同的锁定文本框架。

Is where i decrease the value of the variable because there are 2 master pages with 4 different locked text frames.

我实际上如何使代码完全排除母版页中的项目?

How can i actually make the code exlude the items in the masterpages altogether?

以下工作代码:

var myDoc = app.activeDocument;
var myFolder = myDoc.filePath;
var TotalQuestions = 0 ;
var JPEGFolder = new Folder(myFolder+"/"+app.activeDocument.name+"_"+"JPEG");
var PromFolder = new Folder(myFolder+"/"+app.activeDocument.name+"_"+"Promethean");
var TotalPages = 0;
var Extension = prompt("Başına ne koyalım?","fen-");

if (!JPEGFolder.exists)
JPEGFolder.create();  

if (!PromFolder.exists)
PromFolder.create();

for (i=0; i< app.documents[0].pages.length; i++)
{
      TotalPages = TotalPages+1;
      for (ii=0; ii< app.documents[0].pages[i].textFrames.length; ii++)
      {
              app.select(app.documents[0].pages[i].textFrames[ii]);
              TotalQuestions = TotalQuestions +1;
        }
}
//alert(ToplamSoru);
var Cevapli = TotalPages/2;
//alert(Cevapli);

app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum;
app.jpegExportPreferences.exportResolution = 72;
var result = confirm ("Devam?", false,"EU Thingie");

    if(result ==true){
        for (i=0; i < app.documents[0].pages.length; i++){
            // CEVAPLI //
            if(i < Cevapli){
            //alert(i+" "+ii+" IF");
                for (ii=0; ii < app.documents[0].pages[i].textFrames.length; ii++){
                var QID  = app.documents[0].pages[i].textFrames[ii].contents.substring(1,3);
                    if( QID < 10){
                        app.select(app.documents[0].pages[i].textFrames[ii]);
                        var Less  = app.documents[0].pages[i].textFrames[ii].contents.substring(1,2);
                        app.selection[0].exportFile(ExportFormat.JPG, File(PromFolder+"/"+Extension+Less+".JPEG"), false);
                    }
                    else{
                        app.select(app.documents[0].pages[i].textFrames[ii]);
                        var More  = app.documents[0].pages[i].textFrames[ii].contents.substring(1,3);
                        app.selection[0].exportFile(ExportFormat.JPG, File(PromFolder+"/"+Extension+More+".JPEG"), false)                        
                    }    
                }
            }
                // CEVAPSIZ //
            else{
                //alert(i+" "+ii+" ELSE");
                for (ii=0; ii < app.documents[0].pages[i].textFrames.length; ii++){
                    var QID  = app.documents[0].pages[i].textFrames[ii].contents.substring(1,3);
                    if( QID < 10){
                        app.select(app.documents[0].pages[i].textFrames[ii]);
                        var Less  = app.documents[0].pages[i].textFrames[ii].contents.substring(1,2);
                        app.selection[0].exportFile(ExportFormat.JPG, File(JPEGFolder+"/"+Extension+Less+".JPEG"), false);
                    }
                    else{
                        app.select(app.documents[0].pages[i].textFrames[ii]);
                        var More  = app.documents[0].pages[i].textFrames[ii].contents.substring(1,3);
                        app.selection[0].exportFile(ExportFormat.JPG, File(JPEGFolder+"/"+Extension+More+".JPEG"), false)   

                    }

                }
            }
        }
    }
//alert ("Done")


推荐答案

这将循环遍历页面以及每个页面上的每个textFrame。来自母版页的文本框架将被忽略。

This will loop through the pages and every textFrame on each page. The text frames from Master Pages will be ignored.

for (i=0; i< app.documents[0].pages.length; i++){

      for (ii=0; ii< app.documents[0].pages[i].textFrames.length; ii++){

              $.writeln(app.documents[0].pages[i].textFrames[ii].contents);
          }

    }

这篇关于批量导出所有文本框架时如何排除MasterPage项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆