Newsgroup: it.comp.grafica
Titolo: Software per imposizione

Ciao a tutti
dovrei comperare un programma per l' imposizione dei PDF non mi serve niente 
di complesso e costoso.
Qualcosa di simile a inbooklet (ID) cosa mi consigliate?
Grazie 1000 a tutti.
Ciao DimAnto 

Il 19/11/2007, NoSpam...@Libero.it ha detto :

Se sai usare gli script di InDesign puoi provare questo che ti allego.
Salvalo con testo .JS (cs) o .JSX (cs2) dentro InDesign/Presets/Scripts,
sia PC che OSX.
Impone documenti PDF, ha le funzioni di base, riempi formato, opuscolo
2up o 4 up, barre colore, crocini e doppi tagli.
Ciaoo
// ****************************************INIZIO*********************************************
// variabili base imposizione
var InizioLavoro = 11.5;
var LastraH = 350;
var LastraW = 500;
//conversione pt<>mm
var mm2pt = 2.834647;
var pt2mm = 0.352778;
//dimensione crocini e registri
var myCropMarkLength = 6;
var myCropMarkOffset = 2.5;
var myCropMarkWidth = 0.25;
var myRegMarkInnerRadius = 2;
var myRegMarkOuterRadius = 6;
var myRegMarkOffset = 2.5;
//se CS2 non mostra le finestre di dialogo:
//app.scriptingPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
//Select the file you want to place.
var myFile = File.openDialog("Seleziona il file PDF da posare","Documenti PDF (*.pdf):*.pdf");
if((myFile != "")&&(myFile != null)){
var myFileName = myFile.name;
//var myPunt = myFileName.indexOf(".");
//var myFileNameWE = myFileName.substring(0, myPunt);
//alert(myPunt+" "+myFileNameWE);
//Se ci sono documenti aperti faccio scegliere Doc e pagina iniziale
var myDocument, myPageObj;
if(app.documents.length != 0){
	myDocument, myNewDocument = myChooseDocument();
}
else{
	myDocument = app.documents.add();
	myNewDocument = true;
}
if(myNewDocument == false){
	myPageObj, myNewPage = myChoosePage(myDocument);
}
else{
	myPageObj = myDocument.pages.item(0);
}
//index della prima pagina per la posa
var myPageIdx = parseInt(myPageObj.name)-1;
//scelgo livello più basso e colore nero per barra colori
var myLivello1 = myDocument.layers.item(myDocument.layers.length-1).name;
var myBlack = myDocument.colors.item(0).name;
// salva preferenza misure
var myOldXUnits = app.activeDocument.viewPreferences.horizontalMeasurementUnits;
var myOldYUnits = app.activeDocument.viewPreferences.verticalMeasurementUnits;
//Set the measurement units to mm
app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;
//PasteboardPreferences.js
with(myDocument.pasteboardPreferences){
	//You can use either a number or a measurement string to set the space above/below.
	minimumSpaceAboveAndBelow = "500mm";
}
// se nuovo doc lo imposto
if(myNewDocument==true){
	with(myDocument.documentPreferences){
		pageHeight = LastraH;
		pageWidth = LastraW;
		pageOrientation = PageOrientation.landscape;
		pagesPerDocument = 1;
	}
	//The bleed and slug properties belong to the documentPreferences object.
	with(myDocument.documentPreferences){
		//Bleed
		documentBleedBottomOffset = "0mm";
		documentBleedTopOffset = "0mm";
		documentBleedInsideOrLeftOffset = "0mm";
		documentBleedOutsideOrRightOffset = "0mm";
		//Slug
		slugBottomOffset = "0mm";
		slugTopOffset = "0mm";
		slugInsideOrLeftOffset = "0mm";
		slugRightOrOutsideOffset = "0mm";
	}
	//Margini Master
	with(myDocument.masterSpreads.item(0).pages.item(0)){
		marginPreferences.top = 2;
		marginPreferences.left = 2;
		marginPreferences.bottom = 5;
		marginPreferences.right = 2;
	}
	with (myDocument.masterSpreads.item(0).pages.item(0).marginPreferences){
		columnCount = 2;
		//columnGutter can be a number or a measurement string.
		columnGutter = "0mm";
	}
}
//Get the Number Of PdfPages.
var pdfP = getNumberOfPdfPages(myFile);
var pdfPages = parseInt(pdfP);
//Provo ad aprire la prima pagina
app.pdfPlacePreferences.pageNumber = 1;
//provo se ce sta le abbondanza e password
myPass = false;
var myW,myH;
//Provo a posase 'Trim'
if (myTryPlacePdf(myFile, myPageObj, PDFCrop.cropTrim)==true){
	myLvW = myW;
	myLvH = myH;
	var NoAbbondanza = false;
}
else{
//Provo a posase 'Content'
	if (myTryPlacePdf(myFile, myPageObj, PDFCrop.cropContent)== true){
		myLvW = myW;
		myLvH = myH;
		var NoAbbondanza = true;
	}
	else{
		if (myTryPlacePdf(myFile, myPageObj, PDFCrop.cropMedia)== true){
			myLvW = myW;
			myLvH = myH;
			var NoAbbondanza = true;
		}
		else{
			alert("Il file è protetto da PASSWORD, o non è un file PDF!");
			myCleanUp();
			exit();
		}
	}
}
if (NoAbbondanza == false){
//Provo a posase 'Bleed'
	myAp = myTryPlacePdf(myFile, myPageObj, PDFCrop.cropBleed);
	myAbW = myW;
	myAbH = myH;
	//Controllo abbondanza farlocca: Bleed==Trim
	if((myAbH==myLvH)&&(myAbW==myLvW)){
		//salvo dim 'Media'
		myMdW = myAbW;
		myMdH = myAbH;
		myAp = myTryPlacePdf(myFile, myPageObj, PDFCrop.cropContent);
		myLvW = myW;
		myLvH = myH;
		var NoAbbondanza = true;
		// Metto abbond	FINTA
		myAbW = myLvW+3*2;
		myAbH = myLvH+3*2;
		var myAbFarloc = true;
		}
	else{
		var myAbFarloc = false;
		}
	}
else{
//Non c'è abbondanza, leggo 'Media'
	myAp = myTryPlacePdf(myFile, myPageObj, PDFCrop.cropMedia);
	myMdW = myW;
	myMdH = myH;
	// Metto abbond	FINTA
	myAbW = myLvW+3*2;
	myAbH = myLvH+3*2;
}
// Calcolo abbond
abVert = (myAbH-myLvH)/2;
abOriz = (myAbW-myLvW)/2;
//Finestra dialogo principale
var myDialog = app.dialogs.add({name:"Scegli preimpostazione Plancia  v0.33   <"+myFileName+">", canCancel:true});
with (myDialog){
	 //Add First 1st dialog column.
	with(dialogColumns.add()){
		with(dialogRows.add()){
			staticTexts.add({staticLabel:"Informazioni sul PDF da posare"});
		}
		with(borderPanels.add()){
			with (dialogColumns.add()){
				staticTexts.add({staticLabel:"Pagine:"});
				staticTexts.add({staticLabel:"Usa pagine da:",minWidth:0});
				staticTexts.add({staticLabel:" a:"});
			}
			with(dialogColumns.add()){
				staticTexts.add({staticLabel:((isNaN(pdfPages) == true)?"Bho?":""+parseInt(pdfP))});
				var PDFFirstPagesNumField = integerEditboxes.add({editValue:1,minWidth:40});
				var PDFLastPagesNumField = integerEditboxes.add({editValue:((isNaN(pdfPages) == true)?1:parseInt(pdfP)),minWidth:40});
			}
		}
		with(dialogRows.add()){
			with (borderPanels.add()){
				with (dialogColumns.add()){
					if (NoAbbondanza==true){
						staticTexts.add({staticLabel:"Dimensioni del contenuto:"});
					}
					else{
						staticTexts.add({staticLabel:"Dimensioni:"});
					}
					with (dialogRows.add()){
						staticTexts.add({staticLabel:""+Math.round(myLvW*1000)/1000+" mm  x"});
						staticTexts.add({staticLabel:"  "+Math.round(myLvH*1000)/1000+" mm"});
					}
				}
			}
			with (dialogRows.add()){
				with (borderPanels.add()){
					with (dialogColumns.add()){
						staticTexts.add({staticLabel:"Abbondanza:"});
						if (NoAbbondanza==true){
							staticTexts.add({staticLabel:" NON definita"});
							var myUsaMd = checkboxControls.add({staticLabel:"Usa dimensione pagina del PDF:", checkedState:true});
							with (dialogRows.add()){
								staticTexts.add({staticLabel:""+Math.round(myMdW*1000)/1000+" mm  x"});
								staticTexts.add({staticLabel:"  "+Math.round(myMdH*1000)/1000+" mm"});
							}
						}
						else{
							with (dialogRows.add()){
								staticTexts.add({staticLabel:"Vert = "+Math.round(abVert*1000)/1000+" mm"});
								staticTexts.add({staticLabel:"Oriz = "+Math.round(abOriz*1000)/1000+" mm"});
							}
						}
					}
				}
			}
		}
		with (borderPanels.add()){
			with (dialogColumns.add()){
				staticTexts.add({staticLabel:"Ridimensionamento                                     "});
				with (dialogRows.add()){
					var myLavoroCentrato = checkboxControls.add({staticLabel:"Centra nel:", checkedState:false});
					var LVoriz = measurementComboboxes.add({editValue:(210*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(1000*mm2pt), largeNudge:1, smallNudge:1, stringList:["50 mm","55 mm","148,5 mm","210 mm"], minWidth:80});
					var LVvert = measurementComboboxes.add({editValue:(297*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(1000*mm2pt), largeNudge:1, smallNudge:1, stringList:["80 mm","90 mm","210 mm","297 mm"], minWidth:80});
				}
				with (dialogRows.add()){
					var myAdattaCheckbox = checkboxControls.add({staticLabel:"Adatta", checkedState:false});
					var myPropCheckbox = checkboxControls.add({staticLabel:"Mantieni proporzioni", checkedState:true});
				}
			}
		}
	}
	with (dialogColumns.add()){
		with(dialogRows.add()){
			staticTexts.add({staticLabel:"Scegli il tipo di imposizione:"});
		}
		with (borderPanels.add()){
			with (dialogColumns.add()){
				with (dialogRows.add()){
					staticTexts.add({staticLabel:"Carta:"});
					if (myNewDocument == true){
						var ListaCarta = dropdowns.add({stringList:["35x50 cm", "32x44 cm", "23x33 cm", "50x23 cm", "45.7x30.5 cm", "44.0x30.5 cm"], minWidth:95, selectedIndex:0});
					}
					else{
						staticTexts.add({staticLabel:"Larg = "+myDocument.documentPreferences.pageWidth+" mm x"});
						staticTexts.add({staticLabel:"Altez = "+myDocument.documentPreferences.pageHeight+" mm"});
					}
				}
				with (dialogRows.add()){
					staticTexts.add({staticLabel:"Inizio lavoro:"});
					var InizioLavoroEB = measurementComboboxes.add({editValue:(11.5*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(1000*mm2pt), largeNudge:1, smallNudge:1, stringList:["0 mm","5 mm","10 mm","11,5 mm","15 mm","20 mm"], minWidth:80});
					var CentraPosCheckbox = checkboxControls.add({staticLabel:"Centra tutto", checkedState:false});
				}
			}
		}
		with (borderPanels.add()){
			with (dialogColumns.add()){
				staticTexts.add({staticLabel:"Tipo Imposizione:"});
				staticTexts.add({staticLabel:"Disposizione:"});
			}
			with (dialogColumns.add()){
				var TipoImpose = dropdowns.add({stringList:["1 copia", "2 copie uguali", "2 copie Quartini",  "2 copie Opuscolo", "4 copie uguali", "4 copie Opuscolo", "Riempi formato", "Manuale R&C", "Manuale R&C MP", "Manuale R&C MPR"], minWidth:100, selectedIndex:0});
				with (dialogRows.add()){
					var OrizzVert = dropdowns.add({stringList:["Orizzontale", "Verticale"], minWidth:135, selectedIndex:1});
				}
				with (borderPanels.add()){
					with (dialogColumns.add()){
						staticTexts.add({staticLabel:""});
						staticTexts.add({staticLabel:"Righe:"});
						staticTexts.add({staticLabel:"Colonne:"});
					}
					with (dialogColumns.add()){
						staticTexts.add({staticLabel:"Imp. Manuale"});
						var Righe = integerComboboxes.add({editValue:1, minimumValue:1, maximumValue:100, largeNudge:5, smallNudge:1, stringList:["1","2","3","4","5","6","7","8","9","10"]});
						var Colonne = integerComboboxes.add({editValue:1, minimumValue:1, maximumValue:100, largeNudge:5, smallNudge:1, stringList:["1","2","3","4","5","6","7","8","9","10"]});
					}
				}
			}
		}
		with (borderPanels.add()){
			with (dialogColumns.add()){
				var myBarraColoriCheckbox = checkboxControls.add({staticLabel:"Barra CMYK", checkedState:true});
				with (dialogRows.add()){
					var myCrociniCheckbox = checkboxControls.add({staticLabel:"Segni di taglio", checkedState:true});
					var myCrociniIntCheckbox = checkboxControls.add({staticLabel:"Interni", checkedState:false});
				}
				var myRegistriCheckbox = checkboxControls.add({staticLabel:"Segni di registro", checkedState:true});
				var myInfoCheckbox = checkboxControls.add({staticLabel:"Nome segnatura", checkedState:true});
			}
			with (dialogColumns.add()){
				staticTexts.add({staticLabel:""});
				staticTexts.add({staticLabel:"DT orizz:"});
				staticTexts.add({staticLabel:"DT vert:"});
			}
			with (dialogColumns.add()){
				staticTexts.add({staticLabel:"Doppio Taglio"});
				var DToriz = measurementComboboxes.add({editValue:(5*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(100*mm2pt), largeNudge:1, smallNudge:1, stringList:["0 mm","1 mm","2 mm","3 mm","4 mm","5 mm","6 mm","8 mm","10 mm","12 mm","15 mm"]});
				var DTvert = measurementComboboxes.add({editValue:(5*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(100*mm2pt), largeNudge:1, smallNudge:1, stringList:["0 mm","1 mm","2 mm","3 mm","4 mm","5 mm","6 mm","8 mm","10 mm","12 mm","15 mm"]});
			}
		}
	}
}
//show the dialog
if (myDialog.show() == true){
//uso trim box fasullo perche' lo ha scelto
if (NoAbbondanza==true){
	if (myUsaMd.checkedState == true){
		myLvW = myMdW;
		myLvH = myMdH;
		// Metto abbond	FINTA
		myAbW = myLvW+3*2;
		myAbH = myLvH+3*2;
		// Calcolo abbond
		abVert = (myAbH-myLvH)/2;
		abOriz = (myAbW-myLvW)/2;
	}
}
//provo la posa per ridim e centrare, impostando le dim scelte
if (myLavoroCentrato.checkedState==true){
	myPosa1up(myPageObj, 1, LastraW, LastraH, InizioLavoro);
	mBox.remove();
}
//Se nuovo doc imposto dimensioni scelte
if (myNewDocument==true){
	if (ListaCarta.selectedIndex==0){
		var LastraH = 350;
		var LastraW = 500;
	}
	if (ListaCarta.selectedIndex==1){
		var LastraH = 320;
		var LastraW = 440;
	}
	if (ListaCarta.selectedIndex==2){
		var LastraH = 230;
		var LastraW = 330;
	}
	if (ListaCarta.selectedIndex==3){
		var LastraH = 230;
		var LastraW = 500;
	}
	if (ListaCarta.selectedIndex==4){
		var LastraH = 457;
		var LastraW = 305;
	}
	if (ListaCarta.selectedIndex==5){
		var LastraH = 440;
		var LastraW = 305;
	}
	with(myDocument.documentPreferences){
		pageHeight = LastraH;
		pageWidth = LastraW;
	}
}
else{
// doc esistente, leggo dimensioni
	var LastraH = myDocument.documentPreferences.pageHeight;
	var LastraW = myDocument.documentPreferences.pageWidth;
}
//Margini Master
InizioLavoro = InizioLavoroEB.editValue*pt2mm;
with(myDocument.masterSpreads.item(0).pages.item(0)){
	marginPreferences.bottom = InizioLavoro;
}
//Prima e Ultima pagina da imporre
PDFFirstPagesNum = PDFFirstPagesNumField.editValue;
PDFLastPagesNum = PDFLastPagesNumField.editValue;
var myOrizzVert = OrizzVert.selectedIndex;
var myCrocInt = false;
//QUI IMPOSIZIONE QUI IMPOSIZIONE QUI IMPOSIZIONE QUI IMPOSIZIONE
// Ora so: dimLavoro, DimConAbb, se ce Abbondanza, come posare
switch (TipoImpose.selectedIndex){
	case 0:
		// 1 up
		var myQc = 0;
		for (myPdfPage = PDFFirstPagesNum; myPdfPage<=PDFLastPagesNum; myPdfPage++){
			myPosa1up(myPageObj, myPdfPage, LastraW, LastraH, InizioLavoro);
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
			}
			//se spuntato centro tutto
			if(CentraPosCheckbox.checkedState==true){
				myCentraOggetti(myPageObj,false,true);
			}
			//se serve aggiungo pagina
			if(((myDocument.pages.length-myPageIdx)==1)&&(myPdfPage<PDFLastPagesNum)){
				myPageObj = myDocument.pages.add();
			}
			myPageIdx++;
		}
	break;
	case 1:
		// 2 up
		for (myPdfPage = PDFFirstPagesNum; myPdfPage<=PDFLastPagesNum; myPdfPage++){
			if (((myOrizzVert == 1)&&(myLvW>myLvH)) || ((myOrizzVert == 0)&&(myLvW<myLvH))){
				//ruotato
				var myQc = 3*7*11;
				var mPos = LastraW - myLvH - DTvert.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				var myQc = 5*7*11;
				var mPos = LastraW + myLvH + DTvert.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
			}
			else{
				//non ruotato
				var myQc = 3*7*11;
				var mPos = LastraW - myLvW - DTvert.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				var myQc = 5*7*11;
				var mPos = LastraW + myLvW + DTvert.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
			}
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
			}
			//se spuntato centro tutto
			if(CentraPosCheckbox.checkedState==true){
				myCentraOggetti(myPageObj,false,true);
			}
			//se serve aggiungo pagina
			if(((myDocument.pages.length-myPageIdx)==1)&&(myPdfPage<PDFLastPagesNum)){
				myPageObj = myDocument.pages.add();
			}
			myPageIdx++;
		}
	break;
	case 2:
		// 2 up quartini
		var nOrigPages= PDFLastPagesNum-PDFFirstPagesNum+1;
		myBrk=false;
		var myQuartino = new Array(4);
		if(nOrigPages>=3){
			myQuartino = [3,0,1,2];
			myFine=4;
		}
		else{
			myQuartino = [0,1,0,1];
			myFine=2;
		}
		myQQ=0;
		while(myQQ<(nOrigPages/4)){
		 i=0;
			while (i<(myFine-1)){
				if(((nOrigPages-myQQ*4)!=2)||(nOrigPages % 4 ==0)){
					myPdfPage = PDFFirstPagesNum+myQuartino[i]+4*myQQ;
				}
				else{
					myPdfPage = PDFFirstPagesNum+4*myQQ;
				}
				if (((myOrizzVert == 1)&&(myLvW>myLvH)) || ((myOrizzVert == 0)&&(myLvW<myLvH))){
					//ruotato
					if(myPdfPage<=PDFLastPagesNum){
						var myQc = 3*7*11;
						var mPos = LastraW - myLvH - DTvert.editValue*pt2mm;
						myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
					}
					i++;
					if(((nOrigPages-myQQ*4)!=2)||(nOrigPages % 4 ==0)){
						myPdfPage = PDFFirstPagesNum+myQuartino[i]+4*myQQ;
					}
					else{
						myPdfPage = PDFFirstPagesNum+1+4*myQQ;
						myFine=2;
					}
					var mPos = LastraW + myLvH + DTvert.editValue*pt2mm;
					var myQc = 5*7*11;
					myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				}
				else{
					//non ruotato
					if(myPdfPage<=PDFLastPagesNum){
						var myQc = 3*7*11;
						var mPos = LastraW - myLvW - DTvert.editValue*pt2mm;
						myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
					}
					i++;
					if(((nOrigPages-myQQ*4)!=2)||(nOrigPages % 4 ==0)){
						myPdfPage = PDFFirstPagesNum+myQuartino[i]+4*myQQ;
					}
					else{
						myPdfPage = PDFFirstPagesNum+1+4*myQQ;
						myFine=2;
					}
					var mPos = LastraW + myLvW + DTvert.editValue*pt2mm;
					var myQc = 5*7*11;
					myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				}
				//se spuntato metto informazioni segnatura
				if(myInfoCheckbox.checkedState==true){
					myInfoSignature(myPageObj, myQQ*4+i+1, PDFFirstPagesNum, PDFLastPagesNum, myBrk);
				}
				i++;
				//se spuntato centro tutto
				if(CentraPosCheckbox.checkedState==true){
					myCentraOggetti(myPageObj,false,true);
				}
				//se serve aggiungo pagina
				if( ((myDocument.pages.length-myPageIdx)==1)&& ((i<(myFine-1)) || ((myQQ+1)<(nOrigPages/4))) ){
					myPageObj = myDocument.pages.add();
				}
				myPageIdx++;
			}
			myQQ++;
		}
	break;
	case 3:
		// 2 up opuscolo
		var nOrigPages= PDFLastPagesNum-PDFFirstPagesNum+1;
		if (nOrigPages % 4 != 0) {
			alert("Per fare un opuscolo, il numero di pagine DEVE essere multiplo di 4, pirla!");
			myCleanup();
			exit();
		}
		//Chiata a funzione per ordine pagine 'Opuscolo'
		var nPagesPerSpread = 2;	// we're only doing 2-up for now
		var nSpreads = parseInt(nOrigPages / nPagesPerSpread);
		var order = new Array(nSpreads);
		for (var i = 0; i < nSpreads; i++) {	// make 2-d array. 1st index is spread.
			order[i] = new Array(nPagesPerSpread);
		}
		var isFront = new Array(nSpreads);
		var sheetNum = new Array(nSpreads);
		computePageOrder(nOrigPages, order, isFront, sheetNum);
		myc=0;
		var morder =new Array(nOrigPages);
		for(var mys=0;mys<sheetNum.length;mys++){
			morder[myc++]=order[mys][0];
			morder[myc++]=order[mys][1];
		}
		// 2 up ragr ordine opuscolo
		myPdfPage = PDFFirstPagesNum;
		myBrk=false;
		myBookPg=1;
		while((myBookPg<=nOrigPages)&&(myBrk==false)){
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myBookPg, PDFFirstPagesNum, PDFLastPagesNum, myBrk);
			}
			if (((myOrizzVert == 1)&&(myLvW>myLvH)) || ((myOrizzVert == 0)&&(myLvW<myLvH))){
				//ruotato
				myPdfPage = PDFFirstPagesNum+morder[myBookPg-1];
				var myQc = 3*7*11;
				var mPos = LastraW - myLvH - DTvert.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
				myBrk=true;
				myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+morder[myBookPg-1];
				var myQc = 5*7*11;
				var mPos = LastraW + myLvH + DTvert.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
				myBrk=true;
				myBookPg--;
				}
			}
			else{
				//non ruotato
				myPdfPage = PDFFirstPagesNum+morder[myBookPg-1];
				var myQc = 3*7*11;
				var mPos = LastraW - myLvW - DTvert.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
				myBrk=true;
				myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+morder[myBookPg-1];
				var mPos = LastraW + myLvW + DTvert.editValue*pt2mm;
				var myQc = 5*7*11;
				myPosa1up(myPageObj, myPdfPage, mPos, LastraH, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
				myBrk=true;
				myBookPg--;
				}
			}
			//se spuntato centro tutto
			if(CentraPosCheckbox.checkedState==true){
				myCentraOggetti(myPageObj,false,true);
			}
			//se serve aggiungo pagina
			if(((myDocument.pages.length-myPageIdx)==1)&&(myPdfPage<=PDFLastPagesNum)&&(myBrk==false)){
				myPageObj = myDocument.pages.add();
			}
		myPageIdx++;
		}
	break;
	case 4:
		// 4 up
		for (myPdfPage = PDFFirstPagesNum; myPdfPage<=PDFLastPagesNum; myPdfPage++){
			if (((myOrizzVert == 1)&&(myLvW>myLvH)) || ((myOrizzVert == 0)&&(myLvW<myLvH))){
				//ruotato
				var myQc = 3*11;
				var mPosX = LastraW - myLvH - DTvert.editValue*pt2mm;
				var mPosY = LastraH;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				var myQc = 5*11;
				var mPosX = LastraW + myLvH + DTvert.editValue*pt2mm;
				var mPosY = LastraH;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				var myQc = 3*7;
				var mPosX = LastraW - myLvH - DTvert.editValue*pt2mm;
				var mPosY = LastraH - myLvW - DToriz.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				var myQc = 7*5;
				var mPosX = LastraW + myLvH + DTvert.editValue*pt2mm;
				var mPosY = LastraH - myLvW - DToriz.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
			}
			else{
				//non ruotato 3 5 7 11
				var myQc = 3*11;
				var mPosX = LastraW - myLvW - DTvert.editValue*pt2mm;
				var mPosY = LastraH;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				var myQc = 5*11;
				var mPosX = LastraW + myLvW + DTvert.editValue*pt2mm;
				var mPosY = LastraH;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				var myQc = 3*7;
				var mPosX = LastraW - myLvW - DTvert.editValue*pt2mm;
				var mPosY = LastraH - myLvH - DToriz.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				var myQc = 7*5;
				var mPosX = LastraW + myLvW + DTvert.editValue*pt2mm;
				var mPosY = LastraH - myLvH - DToriz.editValue*pt2mm;
				myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
			}
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
			}
			//se spuntato centro tutto
			if(CentraPosCheckbox.checkedState==true){
				myCentraOggetti(myPageObj,false,true);
			}
			//se serve aggiungo pagina
			if(((myDocument.pages.length-myPageIdx)==1)&&(myPdfPage<PDFLastPagesNum)){
				myPageObj = myDocument.pages.add();
			}
		myPageIdx++;
		}
	break;
	case 5:
		// 4 up upuscolo
		var nOrigPages= PDFLastPagesNum-PDFFirstPagesNum+1;
		if (nOrigPages % 4 != 0) {
			alert("Per fare un opuscolo, il numero di pagine DEVE essere multiplo di 4, pirla!");
			myCleanup();
			exit();
		}
		//Chiata a funzione per ordine pagine 'Opuscolo'
		var nPagesPerSpread = 2;	// we're only doing 2-up for now
		var nSpreads = parseInt(nOrigPages / nPagesPerSpread);
		var order = new Array(nSpreads);
		for (var i = 0; i < nSpreads; i++) {	// make 2-d array. 1st index is spread.
			order[i] = new Array(nPagesPerSpread);
		}
		var isFront = new Array(nSpreads);
		var sheetNum = new Array(nSpreads);
		computePageOrder(nOrigPages, order, isFront, sheetNum);
		myPdfPage = PDFFirstPagesNum;
		myBookPg=1;
		myBrk=false;
		i=0;
		mk=0;
		myBk=false;
	if (((myLvW<myLvH)&&(myOrizzVert == 1))||((myLvW>myLvH)&&(myOrizzVert == 0))){
		mybLvW = myLvW;
		mybLvH = myLvH;
		myBookR = false;
	}
	else{
		mybLvW = myLvH;
		mybLvH = myLvW;
		myBookR = true;
	}
		//se avanza un quartino lo metto per primo B&V
		if((nOrigPages % 4 ==0)&&(nOrigPages % 8 !=0)){
myQbev = true;
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myBookPg, PDFFirstPagesNum, PDFLastPagesNum, myBrk);
			}
			if (myOrizzVert == 0){
				//primo quartino opuscolo Orizzontale
				myPdfPage = PDFFirstPagesNum+order[i+0][0];
					var myQc = 3*11;
					var mPosX = LastraW - mybLvW - DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+order[i+1][1];
					var myQc = 3*7;
					var mPosX = LastraW - mybLvW - DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvH - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+order[i+1][0];
					var myQc = 7*5;
					var mPosX = LastraW + mybLvW + DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvH - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+order[i+0][1];
					var myQc = 5*11;
					var mPosX = LastraW + mybLvW + DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
			//quartino B&V di un opuscolo orizz quindi centro per "giropinza"
			myCentraOggetti(myPageObj,false,true);
			}
			else{
				//primo quartino opuscolo Verticale
				myPdfPage = PDFFirstPagesNum+order[i+1][0];
					var myQc = 3*11;
					var mPosX = LastraW - mybLvH - DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+order[i+1][1];
					var myQc = 3*7;
					var mPosX = LastraW - mybLvH - DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvW - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+order[i+0][0];
					var myQc = 7*5;
					var mPosX = LastraW + mybLvH + DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvW - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				myPdfPage = PDFFirstPagesNum+order[i+0][1];
					var myQc = 5*11;
					var mPosX = LastraW + mybLvH + DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
			}
		if((myDocument.pages.length-myPageIdx)==1){
			myPageObj = myDocument.pages.add();
		}
		myPageIdx++;
			i=2;
			myBookPg=5;
			mk=1;
		}
myQbev = false;
	//qui poso il resto delle pagine
	if(nOrigPages>4){
		myBrk=false;
		myBk=false;
		for(var k=0; k<(sheetNum.length/2-mk);k++){
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myBookPg, PDFFirstPagesNum, PDFLastPagesNum, myBrk);
			}
			//false==BIANCA  true==VOLTA
			myBk = (i % 2)==1;
			if (myOrizzVert == 0){
				//opuscolo Orizzontale
				if(myBk){
//					myPdfPage = PDFFirstPagesNum+order[i+0][0];
					myPdfPage = PDFFirstPagesNum+order[i+0][0];
				}
				else{
//					myPdfPage = PDFFirstPagesNum+order[i+0][0];
					myPdfPage = PDFFirstPagesNum+order[i+0][0];
				}
					var myQc = 3*11;
					var mPosX = LastraW - mybLvW - DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				if(myBk){
//					myPdfPage = PDFFirstPagesNum+order[i+2][1];
					myPdfPage = PDFFirstPagesNum+order[i+2][0];
				}
				else{
//					myPdfPage = PDFFirstPagesNum+order[i+2][1];
					myPdfPage = PDFFirstPagesNum+order[i+2][0];
				}
					var myQc = 3*7;
					var mPosX = LastraW - mybLvW - DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvH - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				if(myBk){
//					myPdfPage = PDFFirstPagesNum+order[i+2][0];
					myPdfPage = PDFFirstPagesNum+order[i+2][1];
				}
				else{
//					myPdfPage = PDFFirstPagesNum+order[i+2][0];
					myPdfPage = PDFFirstPagesNum+order[i+2][1];
				}
					var myQc = 7*5;
					var mPosX = LastraW + mybLvW + DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvH - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				if(myBk){
//					myPdfPage = PDFFirstPagesNum+order[i+0][1];
					myPdfPage = PDFFirstPagesNum+order[i+0][1];
				}
				else{
//					myPdfPage = PDFFirstPagesNum+order[i+0][1];
					myPdfPage = PDFFirstPagesNum+order[i+0][1];
				}
					var myQc = 5*11;
					var mPosX = LastraW + mybLvW + DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
			}
			else{
				//opuscolo Verticale
				if(myBk){
					myPdfPage = PDFFirstPagesNum+order[i+0][0];
				}
				else{
					myPdfPage = PDFFirstPagesNum+order[i+2][1];
				}
					var myQc = 3*11;
					var mPosX = LastraW - mybLvH - DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				if(myBk){
					myPdfPage = PDFFirstPagesNum+order[i+0][1];
				}
				else{
					myPdfPage = PDFFirstPagesNum+order[i+2][0];
				}
					var myQc = 3*7;
					var mPosX = LastraW - mybLvH - DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvW - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				if(myBk){
					myPdfPage = PDFFirstPagesNum+order[i+2][1];
				}
				else{
					myPdfPage = PDFFirstPagesNum+order[i+0][0];
				}
					var myQc = 7*5;
					var mPosX = LastraW + mybLvH + DTvert.editValue*pt2mm;
					var mPosY = LastraH - mybLvW - DToriz.editValue*pt2mm;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
				if(myBk){
					myPdfPage = PDFFirstPagesNum+order[i+2][0];
				}
				else{
					myPdfPage = PDFFirstPagesNum+order[i+0][1];
				}
					var myQc = 5*11;
					var mPosX = LastraW + mybLvH + DTvert.editValue*pt2mm;
					var mPosY = LastraH;
					myPosa1up(myPageObj, myPdfPage, mPosX, mPosY, InizioLavoro);
				myBookPg++;
				if(myBookPg>nOrigPages){
					myBrk=true;
					myBookPg--;
				}
			}
			//se spuntato centro tutto
			if(CentraPosCheckbox.checkedState==true){
				myCentraOggetti(myPageObj,false,true);
			}
			//se serve aggiungo pagina
			if(((myDocument.pages.length-myPageIdx)==1)&&(myBrk==false)){
				myPageObj = myDocument.pages.add();
			}
			//prossime 4 pagine
			if(myBk){
				i=i+3;
			}
			else{
				i=i+1;
			}
		myPageIdx++;
		}
	}
	break;
	case 6:
		// riempi formato
		mnx1 = parseInt(LastraW/myLvW);
		mny1 = parseInt(LastraH/myLvH);
		mnx2 = parseInt(LastraW/myLvH);
		mny2 = parseInt(LastraH/myLvW);
		//trovo migliore riempimento
		myingx1 = mnx1*myLvW+DTvert.editValue*pt2mm*(mnx1-1);
		while (myingx1>LastraW-6){
			mnx1--;
			myingx1 = mnx1*myLvW+DTvert.editValue*pt2mm*(mnx1-1);
		}
		myingy1 = mny1*myLvH+DToriz.editValue*pt2mm*(mny1-1);
		while (myingy1>LastraH-4-InizioLavoro){
			mny1--;
			myingy1 = mny1*myLvH+DToriz.editValue*pt2mm*(mny1-1);
		}
		myingx2 = mnx2*myLvH+DTvert.editValue*pt2mm*(mnx2-1);
		while (myingx2>LastraW-6){
			mnx2--;
			myingx2 = mnx2*myLvW+DTvert.editValue*pt2mm*(mnx2-1);
		}
		myingy2 = mny2*myLvW+DToriz.editValue*pt2mm*(mny2-1);
		while (myingy2>LastraH-4-InizioLavoro){
			mny2--;
			myingy2 = mny2*myLvH+DToriz.editValue*pt2mm*(mny2-1);
		}
	//se riempim oriz o vert e' uguale poso in base alla scelta del dialog
	if (mnx1*mny1==mnx2*mny2){
		if(((myOrizzVert == 0)&&(myLvW>myLvH))||((myOrizzVert == 1)&&(myLvW<myLvH))){
			mynx = mnx1;
			myny = mny1;
			ruot=false;
		}
		else{
			mynx = mnx2;
			myny = mny2;
			ruot=true;
		}
	}
	else{
		//scelgo riempimento con piu' copie
		if (mnx1*mny1>mnx2*mny2){
			mynx = mnx1;
			myny = mny1;
			ruot=false;
		}
		else{
			mynx = mnx2;
			myny = mny2;
			ruot=true;
		}
		//scelgo e forzo orizz o vert in base a migliore riemp
		if (myLvW>myLvH && ruot){
			myOrizzVert = 1;
		}
		if(myLvW<myLvH && ruot){
			myOrizzVert = 0;
		}
		if (myLvW>myLvH && (ruot==false)){
			myOrizzVert = 0;
		}
		if(myLvW<myLvH && (ruot==false)){
			myOrizzVert = 1;
		}
	}
	for (myPdfPage = PDFFirstPagesNum; myPdfPage<=PDFLastPagesNum; myPdfPage++){
		for(my=0; my<myny; my++){
			for(mx=0; mx<mynx; mx++){
				myQc = 1;
				if (mx==0){myQc = myQc*5};
				if (my==0){myQc = myQc*11};
				if (mx==mynx-1){myQc = myQc*3};
				if (my==myny-1){myQc = myQc*7};
				if(ruot==false){
					rfx = LastraW-myLvW*mx*2-(DTvert.editValue*pt2mm*2)*mx;
					rfy = LastraH-myLvH*my-(DToriz.editValue*pt2mm)*my;
					myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
				}
				else{
					rfx = LastraW-myLvH*mx*2-(DTvert.editValue*pt2mm*2)*mx;
					rfy = LastraH-myLvW*my-(DToriz.editValue*pt2mm)*my;
					myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
				}
			}
		}
		myCentraOggetti(myPageObj,true,false);
		//se spuntato metto informazioni segnatura
		if(myInfoCheckbox.checkedState==true){
			myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
		}
		//se spuntato centro tutto
		if(CentraPosCheckbox.checkedState==true){
			myCentraOggetti(myPageObj,true,true);
		}
		//se serve aggiungo pagina
		if(((myDocument.pages.length-myPageIdx)==1)&&(myPdfPage<PDFLastPagesNum)){
			myPageObj = myDocument.pages.add();
		}
		myPageIdx++;
	}
	break;
	case 7:
		// Manuale
		mynx = Colonne.editValue;
		myny = Righe.editValue;
		//ruoto come scelta dialog
		if(((myOrizzVert == 0)&&(myLvW>myLvH))||((myOrizzVert == 1)&&(myLvW<myLvH))){
			ruot=false;
		}
		else{
			ruot=true;
		}
	for (myPdfPage = PDFFirstPagesNum; myPdfPage<=PDFLastPagesNum; myPdfPage++){
		for(my=0; my<myny; my++){
			for(mx=0; mx<mynx; mx++){
				myQc = 1;
				if (mx==0){myQc = myQc*5};
				if (my==0){myQc = myQc*11};
				if (mx==mynx-1){myQc = myQc*3};
				if (my==myny-1){myQc = myQc*7};
				if(ruot==false){
					rfx = LastraW-myLvW*mx*2-(DTvert.editValue*pt2mm*2)*mx;
					rfy = LastraH-myLvH*my-(DToriz.editValue*pt2mm)*my;
					myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
				}
				else{
					rfx = LastraW-myLvH*mx*2-(DTvert.editValue*pt2mm*2)*mx;
					rfy = LastraH-myLvW*my-(DToriz.editValue*pt2mm)*my;
					myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
				}
			}
		}
		myCentraOggetti(myPageObj,true,false);
		//se spuntato metto informazioni segnatura
		if(myInfoCheckbox.checkedState==true){
			myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
		}
		//se spuntato centro tutto
		if(CentraPosCheckbox.checkedState==true){
			myCentraOggetti(myPageObj,true,true);
		}
		//se serve aggiungo pagina
		if(((myDocument.pages.length-myPageIdx)==1)&&(myPdfPage<PDFLastPagesNum)){
			myPageObj = myDocument.pages.add();
		}
		myPageIdx++;
	}
	break;
	case 8:
		// Manuale MP
		mynx = Colonne.editValue;
		myny = Righe.editValue;
		//ruoto come scelta dialog
		if(((myOrizzVert == 0)&&(myLvW>myLvH))||((myOrizzVert == 1)&&(myLvW<myLvH))){
			ruot=false;
		}
		else{
			ruot=true;
		}
	//for (myPdfPage = PDFFirstPagesNum; myPdfPage<=PDFLastPagesNum; myPdfPage++){
	myPdfPage = PDFFirstPagesNum;
	myBrk=true;
	while(myBrk==true){
		for(my=0; my<myny; my++){
			for(mx=0; mx<mynx; mx++){
				myQc = 1;
				if (mx==0){myQc = myQc*5};
				if (my==0){myQc = myQc*11};
				if (mx==mynx-1){myQc = myQc*3};
				if (my==myny-1){myQc = myQc*7};
				if(ruot==false){
					rfx = LastraW-myLvW*mx*2-(DTvert.editValue*pt2mm*2)*mx;
					rfy = LastraH-myLvH*my-(DToriz.editValue*pt2mm)*my;
					myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
				}
				else{
					rfx = LastraW-myLvH*mx*2-(DTvert.editValue*pt2mm*2)*mx;
					rfy = LastraH-myLvW*my-(DToriz.editValue*pt2mm)*my;
					myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
				}
				myPdfPage++;
				if(myPdfPage>PDFLastPagesNum){
					myPdfPage = PDFFirstPagesNum;
					myBrk=false;
				}
			}
		}
		myCentraOggetti(myPageObj,true,false);
		//se spuntato metto informazioni segnatura
		if(myInfoCheckbox.checkedState==true){
			myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
		}
		//se spuntato centro tutto
		if(CentraPosCheckbox.checkedState==true){
			myCentraOggetti(myPageObj,true,true);
		}
		//se serve aggiungo pagina
		if(((myDocument.pages.length-myPageIdx)==1)&&(myBrk==true)){
			myPageObj = myDocument.pages.add();
		}
		myPageIdx++;
	}
	break;
	case 9:
		// Manuale MP FR
		//Select the file you want to place rear.
		var myFile2 = File.openDialog("Seleziona il file PDF per il retro","Documenti PDF (*.pdf):*.pdf");
		myFRfile = myFile;
		mynx = Colonne.editValue;
		myny = Righe.editValue;
		//ruoto come scelta dialog
		if(((myOrizzVert == 0)&&(myLvW>myLvH))||((myOrizzVert == 1)&&(myLvW<myLvH))){
			ruot=false;
		}
		else{
			ruot=true;
		}
		//for (myPdfPage = PDFFirstPagesNum; myPdfPage<=PDFLastPagesNum; myPdfPage++){
		myPdfPage = PDFFirstPagesNum;
		myBrk=true;
		while(myBrk==true){
			for(my=0; my<myny; my++){
				for(mx=0; mx<mynx; mx++){
					myQc = 1;
					if (mx==0){myQc = myQc*5};
					if (my==0){myQc = myQc*11};
					if (mx==mynx-1){myQc = myQc*3};
					if (my==myny-1){myQc = myQc*7};
					if(ruot==false){
						rfx = LastraW-myLvW*mx*2-(DTvert.editValue*pt2mm*2)*mx;
						rfy = LastraH-myLvH*my-(DToriz.editValue*pt2mm)*my;
						myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
					}
					else{
						rfx = LastraW-myLvH*mx*2-(DTvert.editValue*pt2mm*2)*mx;
						rfy = LastraH-myLvW*my-(DToriz.editValue*pt2mm)*my;
						myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
					}
					myPdfPage++;
					if(myPdfPage>PDFLastPagesNum){
						myPdfPage = PDFFirstPagesNum;
						myBrk=false;
					}
				}
			}
			myCentraOggetti(myPageObj,true,false);
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
			}
			//se spuntato centro tutto
			if(CentraPosCheckbox.checkedState==true){
				myCentraOggetti(myPageObj,true,true);
			}
			//retro
			//se serve aggiungo pagina
			if((myDocument.pages.length-myPageIdx)==1){
				myPageObj = myDocument.pages.add();
			}
			myPageIdx++;
			myFile = myFile2;
			myPdfPageFR = myPdfPage;
			myPdfPage = 1;
			for(my=0; my<myny; my++){
				for(mx=0; mx<mynx; mx++){
					myQc = 1;
					if (mx==0){myQc = myQc*5};
					if (my==0){myQc = myQc*11};
					if (mx==mynx-1){myQc = myQc*3};
					if (my==myny-1){myQc = myQc*7};
					if(ruot==false){
						rfx = LastraW-myLvW*mx*2-(DTvert.editValue*pt2mm*2)*mx;
						rfy = LastraH-myLvH*my-(DToriz.editValue*pt2mm)*my;
						myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
					}
					else{
						rfx = LastraW-myLvH*mx*2-(DTvert.editValue*pt2mm*2)*mx;
						rfy = LastraH-myLvW*my-(DToriz.editValue*pt2mm)*my;
						myPosa1up(myPageObj, myPdfPage, rfx, rfy, InizioLavoro);
					}
					myPdfPage++;
					if(myPdfPage>PDFLastPagesNum){
						myPdfPage = PDFFirstPagesNum;
						myBrk=false;
					}
				}
			}
			myFile = myFRfile;
			myPdfPage = myPdfPageFR;
			myCentraOggetti(myPageObj,true,false);
			//se spuntato metto informazioni segnatura
			if(myInfoCheckbox.checkedState==true){
				myInfoSignature(myPageObj, myPdfPage, PDFFirstPagesNum, PDFLastPagesNum);
			}
			//se spuntato centro tutto
			if(CentraPosCheckbox.checkedState==true){
				myCentraOggetti(myPageObj,true,true);
			}
			//se serve aggiungo pagina
			if(((myDocument.pages.length-myPageIdx)==1)&&(myBrk==true)){
				myPageObj = myDocument.pages.add();
			}
			myPageIdx++;
		}
	break;
}
//se spuntato disegno barra colori
if(myBarraColoriCheckbox.checkedState==true){
	myDrawBarraB(myPageObj);
	//scrivo nomi colori CMYK + ev P
	myDrawColorNames();
}
//Reset measurement units to their original values.
app.activeDocument.viewPreferences.horizontalMeasurementUnits = myOldXUnits;
app.activeDocument.viewPreferences.verticalMeasurementUnits = myOldYUnits;
//zoom al 50%
app.activeWindow.zoomPercentage = 50;
alert("Io il mio lavoro l'ho fatto.\n Tu fai il tuo: CONTROLLA BENE!!");
}
else{
myCleanup();
myDialog.destroy();
}
}
else{
	alert("Riprovaci, puoi farcela!");
}
exit();
// ****************************************FINE*********************************************
function myCleanup(){
//Reset measurement units to their original values.
app.activeDocument.viewPreferences.horizontalMeasurementUnits = myOldXUnits;
app.activeDocument.viewPreferences.verticalMeasurementUnits = myOldYUnits;
//chiudo documento se l'avevo aperto io
	if (myNewDocument == true){
		app.activeDocument.close(SaveOptions.no);
	}
	else{
		//cancello pagina se l'avevo creata io e poi "cancel"
		if (myNewPage == true){
			myPageObj.remove();
		}
	}
}
function getNumberOfPdfPages(pdfFile){
//pdfFile.resolve();
// x sicurezza chiudo F
pdfFile.close();
try{
// provo a cercare '/N ' x num pagine
pdfFile.encoding = "BINARY";
	pdfFile.open("r", "", "");
	oneLine = pdfFile.readln();
		while ((pdfFile.eof==false)&&(oneLine.indexOf("/N ")< 0)&&(pdfFile.tell()<512)) {
			oneLine = pdfFile.readln();
			slashN = oneLine.indexOf("/N ");
			nextSlash = oneLine.indexOf("/" , slashN+1);
			if (nextSlash<0){
				pdfP = oneLine.substring(slashN+3);
			}
			else{
				pdfP = oneLine.substring(slashN+3 , nextSlash);
			}
		}
		if((isNaN(pdfP) == true)||(oneLine.indexOf("/N ")< 0)){
		// se non trovo '/N ', cerco '/Count' all'inixio x num pagine
			pdfFile.seek(0);
			while ((pdfFile.eof==false)&&(pdfFile.tell()<1024)&&(oneLine.indexOf("/Count")< 0)){
			oneLine = pdfFile.readln();
			slashN = oneLine.indexOf("/Count");
				if (slashN!=-1){
				pdfP = oneLine.substring(slashN+7);
				}
			}
			if(oneLine.indexOf("/Count")< 0){
			// se non trovo '/Count' all'inixio, provo alla finr del file x num pagine
				pdfFile.seek(pdfFile.lenght-8192);
				while (pdfFile.eof==false){
				oneLine = pdfFile.readln();
				slashN = oneLine.indexOf("/Count");
					if (slashN!=-1){
						nextSlash = oneLine.indexOf("/" , slashN+1);
						if (nextSlash<0){
							pdfP = oneLine.substring(slashN+7);
						}
						else{
							pdfP = oneLine.substring(slashN+7 , nextSlash);
						}
					}
				}
			}
			else{
				nextSlash = oneLine.indexOf("/" , slashN+1);
				if (nextSlash<0){
					pdfP = oneLine.substring(slashN+7);
				}
				else{
					pdfP = oneLine.substring(slashN+7 , nextSlash);
				}
			}
		}
	}
catch (myError){
		alert("Non riesco a leggere il numero di pagine del PDF!!");
		pdfP = "0";
}
pdfFile.close();
return(pdfP);
}
function computePageOrder(nPages,
  /*out*/ order, /*out*/ isFront, /*out*/ sheetNum)
{
	//var order = new Array(nPages);
	var nPagesPerSpread = 2;	// we're just doing 2-up currently
	var nSpreads = nPages / nPagesPerSpread;
	var i, j, sp;
	var front, back;
	// standard booklet order (saddle stitch)
	for (i = 0, j = nPages - 1, front = 0, back = 1; back < nSpreads; ) {
		order[front][0] = j--;
		order[front][1] = i++;
		isFront[front] = true;
		sheetNum[front] = front/2;
		order[back][0] = i++;
		order[back][1] = j--;
		isFront[back] = false;
		sheetNum[back] = sheetNum[front];
		front += 2;
		back += 2;
	}
	//return order;
}
function myDrawPrintersMarks(myPageObj, myObject){
	var myBounds, myX1, myY1, myX2, myY2, myObject;
	var myOldRulerOrigin = myDocument.viewPreferences.rulerOrigin;
	myDocument.viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin;
	//Create a layer to hold the printers marks (if it does not already exist).
	var myLayer = myDocument.layers.item("IndicatoriStampa");
	try{
		myLayerName = myLayer.name;
	}
	catch (myError){
		var myLayer = myDocument.layers.add({name:"IndicatoriStampa"});
	}
	//Get references to the Registration color and the None swatch.
	var myRegistrationColor = myDocument.colors.item("Registration");
	var myNoneSwatch = myDocument.swatches.item("None");
	myBounds = myObject.visibleBounds;
	if (myCrociniCheckbox.checkedState == true){
		myDrawCropMarks (myPageObj, myBounds[1], myBounds[0], myBounds[3], myBounds[2], myRegistrationColor, myNoneSwatch, myLayer);
	}
	if ((myRegistriCheckbox.checkedState == true)&&(myCrocInt==false)){
		myDrawRegMarks (myPageObj, myBounds[1], myBounds[0], myBounds[3], myBounds[2], myRegistrationColor, myNoneSwatch, myLayer);
	}
	myDocument.viewPreferences.rulerOrigin = myOldRulerOrigin;
}
function myDrawCropMarks (myPageObj, myX1, myY1, myX2, myY2, myRegistrationColor, myNoneSwatch, myLayer){
if ((myQc % 3)==0){
	//Sinistra crop mark pair.
	myDrawLine(myPageObj, [myY1, myX1-myCropMarkOffset, myY1, myX1-(myCropMarkOffset + myCropMarkLength)], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myDrawLine(myPageObj, [myY2, myX1-myCropMarkOffset, myY2, myX1-(myCropMarkOffset+myCropMarkLength)], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
if ((myQc % 5)==0){
	//Destra crop mark pair.
	myDrawLine(myPageObj, [myY1, myX2+myCropMarkOffset, myY1, myX2+myCropMarkOffset+myCropMarkLength], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myDrawLine(myPageObj, [myY2, myX2+myCropMarkOffset, myY2, myX2+myCropMarkOffset+myCropMarkLength], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
if ((myQc % 7)==0){
	//Sopra crop mark pair.
	myDrawLine(myPageObj, [myY1-myCropMarkOffset, myX2, myY1-(myCropMarkOffset+myCropMarkLength), myX2], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myDrawLine(myPageObj, [myY1-myCropMarkOffset, myX1, myY1-(myCropMarkOffset+myCropMarkLength), myX1], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
if ((myQc % 11)==0){
	//Sotto crop mark pair.
	myDrawLine(myPageObj, [myY2+myCropMarkOffset, myX1, myY2+myCropMarkOffset+myCropMarkLength, myX1], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myDrawLine(myPageObj, [myY2+myCropMarkOffset, myX2, myY2+myCropMarkOffset+myCropMarkLength, myX2], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
}
function myDrawRegMarks (myPageObj, myX1, myY1, myX2, myY2, myRegistrationColor, myNoneSwatch, myLayer){
	var myBounds
	var myXCenter = myX1 + ((myX2 - myX1)/2);
	var myYCenter = myY1 + ((myY2 - myY1)/2);
	var myTargetCenter = myRegMarkOffset+(myRegMarkOuterRadius)-3;
if ((myQc % 7)==0){
	//Top registration target.
	myBounds = [myY1-(myTargetCenter+myRegMarkInnerRadius), myXCenter-myRegMarkInnerRadius, (myY1-myTargetCenter)+myRegMarkInnerRadius, myXCenter + myRegMarkInnerRadius];
	myDrawTarget(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myY1-(myTargetCenter+myRegMarkOuterRadius)+3, myXCenter, (myY1-myTargetCenter)+myRegMarkOuterRadius-3, myXCenter]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myY1-myTargetCenter, myXCenter-myRegMarkOuterRadius, myY1-myTargetCenter, myXCenter+myRegMarkOuterRadius]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
if ((myQc % 3)==0){
	//Left registration target.
	myBounds = [myYCenter-myRegMarkInnerRadius, myX1-(myTargetCenter+myRegMarkInnerRadius), myYCenter+myRegMarkInnerRadius, (myX1 - myTargetCenter) + myRegMarkInnerRadius];
	myDrawTarget(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myYCenter, myX1-(myTargetCenter+myRegMarkOuterRadius)+3, myYCenter, myX1 -myRegMarkOffset]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myYCenter-myRegMarkOuterRadius, myX1-myTargetCenter, myYCenter+myRegMarkOuterRadius, myX1-myTargetCenter]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
if ((myQc % 11)==0){
	//Bottom registration target.
	myBounds = [myY2+(myTargetCenter-myRegMarkInnerRadius), myXCenter-myRegMarkInnerRadius, myY2+ myTargetCenter+myRegMarkInnerRadius, myXCenter + myRegMarkInnerRadius];
	myDrawTarget(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myY2+myRegMarkOffset, myXCenter, myY2+myTargetCenter+myRegMarkOuterRadius-3, myXCenter]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myY2+myTargetCenter, myXCenter-myRegMarkOuterRadius, myY2 + myTargetCenter, myXCenter+myRegMarkOuterRadius]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
if ((myQc % 5)==0){
	//Right registration target.
	myBounds = [myYCenter-myRegMarkInnerRadius, myX2+(myTargetCenter-myRegMarkInnerRadius), myYCenter+myRegMarkInnerRadius, myX2 + myTargetCenter + myRegMarkInnerRadius];
	myDrawTarget(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myYCenter, myX2+myRegMarkOffset, myYCenter, myX2+myTargetCenter+myRegMarkOuterRadius-3]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
	myBounds = [myYCenter-myRegMarkOuterRadius, myX2+myTargetCenter, myYCenter+myRegMarkOuterRadius, myX2+myTargetCenter]
	myDrawLine(myPageObj, myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}
}
function myDrawLine(myPageObj, myBounds, myStrokeWeight, myRegistrationColor, myNoneSwatch, myLayer){
	myPageObj.graphicLines.add(myLayer, undefined, undefined,{strokeWeight:myStrokeWeight, fillColor:myNoneSwatch, strokeColor:myRegistrationColor, geometricBounds:myBounds});
}
function myDrawTarget(myPageObj, myBounds, myStrokeWeight, myRegistrationColor, myNoneSwatch, myLayer){
	myPageObj.ovals.add(myLayer, undefined, undefined, {strokeWeight:myStrokeWeight, fillColor:myNoneSwatch, strokeColor:myRegistrationColor, geometricBounds:myBounds});
}
function myChooseDocument(){
    var myDocumentNames = new Array;
    myDocumentNames.push("Nuovo Documento");
    //Get the names of the documents
    for(var myDocumentCounter = 0;myDocumentCounter < app.documents.length; myDocumentCounter++){
        myDocumentNames.push(app.documents.item(myDocumentCounter).name);
    }
    var myChooseDocumentDialog = app.dialogs.add({name:"Scegli un Documento", canCancel:false});
    with(myChooseDocumentDialog.dialogColumns.add()){
        with(dialogRows.add()){
            with(dialogColumns.add()){
                staticTexts.add({staticLabel:"Posa PDF su:"});
            }
            with(dialogColumns.add()){
                var myChooseDocumentDropdown = dropdowns.add({stringList:myDocumentNames, selectedIndex:0});
            }
        }
    }
	myChooseDocumentDialog.show();
    if(myChooseDocumentDropdown.selectedIndex == 0){
        myDocument = app.documents.add();
        myNewDocument = true;
    }
    else{
    	myDocument = app.documents.item(myChooseDocumentDropdown.selectedIndex-1);
        myNewDocument = false;
    }
    myChooseDocumentDialog.destroy();
    return myDocument, myNewDocument;
}
function myChoosePage(myDocument){
    var myPageNames = new Array;
    myPageNames.push("Nuova Pagina");
    //Get the names of the pages in the document
    for(var myCounter = 0; myCounter < myDocument.pages.length;myCounter++){
        myPageNames.push(myDocument.pages.item(myCounter).name);
    }
    var myChoosePageDialog = app.dialogs.add({name:"Scegli una Pagina", canCancel:false});
    with(myChoosePageDialog.dialogColumns.add()){
        with(dialogRows.add()){
            with(dialogColumns.add()){
                staticTexts.add({staticLabel:"Posa PDF su:"});
            }
            with(dialogColumns.add()){
                var myChoosePageDropdown = dropdowns.add({stringList:myPageNames, selectedIndex:0});
            }
        }
    }
    myChoosePageDialog.show();
	if(myChoosePageDropdown.selectedIndex == 0){
        myPageObj = myDocument.pages.add();
    	myNewPage = true;
    }
    else{
	    myPageObj = myDocument.pages.item(myChoosePageDropdown.selectedIndex-1);
     	myNewPage = false;
   }
    myChoosePageDialog.destroy();
    return myPageObj, myNewPage;
}
function myCentraOggetti(myPageObj, centraX, centraY){
// Barra Colore
var myCentraItems = new Array;
//var myLayerItems = new Array;
var mySindex = parseInt(myPageObj.name)-1;
var myFirsObj = true;
//Calcolo ingombro toale
for (var myEnum = 0; myEnum<myDocument.spreads[mySindex].pageItems.length; myEnum++){
	myBounds = myDocument.spreads[mySindex].pageItems[myEnum].geometricBounds;
	//Set up some initial bounding box values.
	if (myDocument.spreads[mySindex].pageItems[myEnum].label!="nobj"){
		myCentraItems.push(myDocument.spreads[mySindex].pageItems[myEnum]);
		if (myFirsObj==true){
			myX1 = myBounds[1];
			myY1 = myBounds[0];
			myX2 = myBounds[3];
			myY2 = myBounds[2];
			myFirsObj = false;
		}
		else{
			if (myBounds[0] < myY1){
				myY1 = myBounds[0];
			}
			if (myBounds[1] < myX1){
				myX1 = myBounds[1];
			}
			if (myBounds[2] > myY2){
				myY2 = myBounds[2];
			}
			if (myBounds[3] > myX2){
				myX2 = myBounds[3];
			}
		}
	}
}
//raggruppo per centrare
	var myGroup = myPageObj.groups.add(myCentraItems);
	if (centraX&&centraY){
		myGroup.move([LastraW/2-(myX2-myX1)/2, LastraH/2-(myY2-myY1)/2], undefined);
	}
	else{
		if (centraX){
			myGroup.move([LastraW/2-(myX2-myX1)/2, myY1], undefined);
		}
		if (centraY){
			myGroup.move([myX1, LastraH/2-(myY2-myY1)/2], undefined);
		}
	}
//sgruppo
	myGroup.ungroup();
//riassegno il layer ad ogni oggetto
	for (var myEnum = 0; myEnum<myPageObj.pageItems.length; myEnum++){
		if (myPageObj.pageItems[myEnum].label == "pag"){
			myPageObj.pageItems[myEnum].itemLayer = myDocument.layers.item(myLivello1);
		}
	}
}
function myDrawColorNames(){
//quadratini con nome separazioni "C M Y K" + ev "P XXX"
var myMasterPage = myDocument.masterSpreads.item(0).pages.item(0);
var myColnames = new Array;
	for (var myEnum = 0; myEnum<app.activeDocument.swatches.length; myEnum++){
		myPname = app.activeDocument.swatches.item(myEnum).name;
		if (myPname.indexOf("PANTONE")!=-1){
			myColnames.push(app.activeDocument.swatches.item(myEnum).name);
		}
	}
	var myQuad = myMasterPage.textFrames.add();
	myQuad.label = "nobj";
	myQuad.geometricBounds = [LastraH-6,LastraW-100,LastraH-2,LastraW-96];
	myQuad.contents = "C";
	myQuad.paragraphs.item(0).appliedFont = "Arial";
	myQuad.paragraphs.item(0).fontStyle = "Regular";
	myQuad.paragraphs.item(0).justification = Justification.centerAlign;
	myQuad.paragraphs.item(0).pointSize = 6;
	myQuad.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
	myQuad.paragraphs.item(0).fillColor = app.activeDocument.swatches.item("C=100 M=0 Y=0 K=0");
	var myQuad = myMasterPage.textFrames.add();
	myQuad.label = "nobj";
	myQuad.geometricBounds = [LastraH-6,LastraW-96,LastraH-2,LastraW-92];
	myQuad.contents = "M";
	myQuad.paragraphs.item(0).appliedFont = "Arial";
	myQuad.paragraphs.item(0).fontStyle = "Regular";
	myQuad.paragraphs.item(0).justification = Justification.centerAlign;
	myQuad.paragraphs.item(0).pointSize = 6;
	myQuad.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
	myQuad.paragraphs.item(0).fillColor = app.activeDocument.swatches.item("C=0 M=100 Y=0 K=0");
	var myQuad = myMasterPage.textFrames.add();
	myQuad.label = "nobj";
	myQuad.geometricBounds = [LastraH-6,LastraW-92,LastraH-2,LastraW-88];
	myQuad.contents = "Y";
	myQuad.paragraphs.item(0).appliedFont = "Arial";
	myQuad.paragraphs.item(0).fontStyle = "Regular";
	myQuad.paragraphs.item(0).justification = Justification.centerAlign;
	myQuad.paragraphs.item(0).pointSize = 6;
	myQuad.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
	myQuad.paragraphs.item(0).fillColor = app.activeDocument.swatches.item("C=0 M=0 Y=100 K=0");
	var myQuad = myMasterPage.textFrames.add();
	myQuad.label = "nobj";
	myQuad.geometricBounds = [LastraH-6,LastraW-88,LastraH-2,LastraW-84];
	myQuad.contents = "K";
	myQuad.paragraphs.item(0).appliedFont = "Arial";
	myQuad.paragraphs.item(0).fontStyle = "Regular";
	myQuad.paragraphs.item(0).justification = Justification.centerAlign;
	myQuad.paragraphs.item(0).pointSize = 6;
	myQuad.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
	myQuad.paragraphs.item(0).fillColor = app.activeDocument.swatches.item(myBlack);
	for (var myEnum = 0; myEnum<myColnames.length; myEnum++){
		var myQuad = myMasterPage.textFrames.add();
		myQuad.label = "nobj";
		myQuad.geometricBounds = [LastraH-6,LastraW-(80-20*myEnum),LastraH-2,LastraW-(60-20*myEnum)];
		myQuad.contents = "P "+myColnames[myEnum].substring(8);
		myQuad.paragraphs.item(0).appliedFont = "Arial";
		myQuad.paragraphs.item(0).fontStyle = "Regular";
		myQuad.paragraphs.item(0).justification = Justification.centerAlign;
		myQuad.paragraphs.item(0).pointSize = 6;
		myQuad.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
		myQuad.paragraphs.item(0).fillColor = app.activeDocument.swatches.item(myColnames[myEnum]);
	}
}
function myDrawBarraB(myPageObj){
// Barra Colore
var myMasterPage = myDocument.masterSpreads.item(0).pages.item(0);
var myBarraItems = new Array;
//Calcolo ingombro toale escludendo info segnatura > label "nobj"
for (var myEnum = 0; myEnum<myPageObj.pageItems.length; myEnum++){
	myBounds = myPageObj.pageItems[myEnum].geometricBounds;
	//Set up some initial bounding box values.
	if (myPageObj.pageItems[myEnum].label!="nobj"){
		if (myEnum==0){
			myX1 = myBounds[1];
			myY1 = myBounds[0];
			myX2 = myBounds[3];
			myY2 = myBounds[2];
		}
		else{
			if (myBounds[0] < myY1){
				myY1 = myBounds[0];
			}
			if (myBounds[1] < myX1){
				myX1 = myBounds[1];
			}
			if (myBounds[2] > myY2){
				myY2 = myBounds[2];
			}
			if (myBounds[3] > myX2){
				myX2 = myBounds[3];
			}
		}
	}
}
	// contatore x barraCol
	var myCounter = 0;
	var myLung = myX2-myX1-8;
	mybX1= myX1;
	mybY1= myY1;
	while (myCounter<myLung){
		myCounter = myBarretta(myMasterPage, "C=100 M=0 Y=0 K=0", myCounter, myBarraItems, "C", myLung);
		myCounter = myBarretta(myMasterPage, "C=0 M=100 Y=0 K=0", myCounter, myBarraItems, "M", myLung);
		myCounter = myBarretta(myMasterPage, "C=0 M=0 Y=100 K=0", myCounter, myBarraItems, "Y", myLung);
		myCounter = myBarretta(myMasterPage, myBlack, myCounter, myBarraItems, "K", myLung);
	}
	//Create a layer to hold the printers marks (if it does not already exist).
	var myLayer = myDocument.layers.item("IndicatoriStampa");
	try{
		myLayerName = myLayer.name;
	}
	catch (myError){
		var myLayer = myDocument.layers.add({name:"IndicatoriStampa"});
	}
   	var myGroup = myMasterPage.groups.add(myBarraItems);
	//Assign the group to a layer.
	myGroup.itemLayer = myDocument.layers.item("IndicatoriStampa");
	if (mybY1>6){
		myGroup.move([mybX1+3, mybY1-4], undefined);
	}
	else{
		myGroup.move([mybX1+3, 2], undefined);
	}
}
function myBarretta(myPageObj, myColor, myCounter, myBarraItems, myCol, myLung){
	for (var myTint=0;myTint<5;myTint++){
		if (myCounter>myLung){
			var breko = true;
			break;
		}
		var myQuad = myPageObj.textFrames.add();
	// 1032=x1y1x2y2
		myX1 = myCounter;
		myY1 = "0";
		myX2 = myCounter+4;
		myY2 = "4";
		myQuad.geometricBounds = [myY1,myX1,myY2,myX2];
		myQuad.fillColor = app.activeDocument.swatches.item(myColor);
		myQuad.fillTint = 100-myTint*20
		myBarraItems.push(myQuad);
		myCounter = myCounter + 4;
	}
	if (breko!=true){
		myQuad.contents = myCol;
		myQuad.paragraphs.item(0).appliedFont = "Arial";
		myQuad.paragraphs.item(0).justification = Justification.centerAlign;
		myQuad.paragraphs.item(0).pointSize = 6;
		myQuad.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
		myQuad.paragraphs.item(0).fillColor = app.activeDocument.swatches.item(myColor);
	}
 return myCounter;
}
//Arrotonda Float a millesimi
function myRoundF(myNumber){
	var myStr = (myNumber+0.00015)*1000+"";
	var myInt = parseInt(myStr);
	return myInt/1000;
}
// Posa 1up
function myPosa1up(myPageObj, myPdfPage, LastraW, LastraH, InizioLavoro){
//Seleziono pagina
app.pdfPlacePreferences.pageNumber = myPdfPage;
	if (NoAbbondanza == false){
		if (myAdattaCheckbox.checkedState==true){
		// Poso senza abbond x adatt
		app.pdfPlacePreferences.pdfCrop = PDFCrop.cropTrim;
		myPDFlvPage = myPageObj.place(File(myFile), [0,0]);
		}
		else{
		// Poso con abbond
		app.pdfPlacePreferences.pdfCrop = PDFCrop.cropBleed;
		myPDFlvPage = myPageObj.place(File(myFile), [0,0]);
		}
		//selezioni contenitore
	    mBox = myPDFlvPage.parent;
		mBox.itemLayer = myDocument.layers.item(myLivello1);
		}
	else{
		if(myAbFarloc==true){
			if (myUsaMd.checkedState==true){
				// Poso senza abbond
				app.pdfPlacePreferences.pdfCrop = PDFCrop.cropTrim;
			}
			else{
				// Poso senza abbond CONTENUTO
				app.pdfPlacePreferences.pdfCrop = PDFCrop.cropContent;
			}
		}
		else{
			if (myUsaMd.checkedState==true){
				// Poso senza abbond
				app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
			}
			else{
				// Poso senza abbond CONTENUTO
				app.pdfPlacePreferences.pdfCrop = PDFCrop.cropContent;
			}
		}
		myPDFlvPage = myPageObj.place(File(myFile), [0,0]);
		//selezioni contenitore
	    mBox = myPDFlvPage.parent;
		mBox.itemLayer = myDocument.layers.item(myLivello1);
		// Metto Abbondanza fittizia
		mBox.geometricBounds = [mBox.geometricBounds[0]-abOriz, mBox.geometricBounds[1]-abVert, mBox.geometricBounds[2]+abOriz, mBox.geometricBounds[3]+abVert];
		}
	//se spuntato centro e ev. adatto a dimesioni richieste
	if(myLavoroCentrato.checkedState==true){
		mBox.geometricBounds = [0,0, LVvert.editValue*pt2mm, LVoriz.editValue*pt2mm];
		myPDFctX1 = myPDFlvPage.geometricBounds[1];
		myPDFctY1 = myPDFlvPage.geometricBounds[0];
		myPDFctX2 = myPDFlvPage.geometricBounds[3];
		myPDFctY2 = myPDFlvPage.geometricBounds[2];
		myPDFctWidth = myPDFctX2 - myPDFctX1;
		myPDFctHeight = myPDFctY2 - myPDFctY1;
		if (myPDFctWidth>myPDFctHeight){
			myPDFlvPage.rotate(-90, AnchorPoint.centerAnchor, true, true);
		}
		if (myAdattaCheckbox.checkedState==true){
			if (myPropCheckbox.checkedState==true){
			mBox.fit(FitOptions.proportionally);
			}
			else{
			mBox.fit(FitOptions.contentToFrame);
			}
		}
		mBox.fit(FitOptions.centerContent);
		myLvH = LVvert.editValue*pt2mm;
		myLvW = LVoriz.editValue*pt2mm;
		myAbH = LVvert.editValue*pt2mm+2*abOriz;
		myAbW = LVoriz.editValue*pt2mm+2*abVert;
		//metto abondanza finta
		mBox.geometricBounds = [mBox.geometricBounds[0]-abOriz, mBox.geometricBounds[1]-abVert, mBox.geometricBounds[2]+abOriz, mBox.geometricBounds[3]+abVert];
	}
	//cancello e riposo perche addatt con abb def
	if ((NoAbbondanza == false)&&(myAdattaCheckbox.checkedState==true)){
		//salvo scala e rotaz box e cont
		sv = myPDFlvPage.absoluteVerticalScale;
		so = myPDFlvPage.absoluteHorizontalScale;
		ro = myPDFlvPage.absoluteRotationAngle;
		mBox.remove();
		// Poso con abbond
		app.pdfPlacePreferences.pdfCrop = PDFCrop.cropBleed;
		myPDFlvPage = myPageObj.place(File(myFile), [0,0]);
		//selezioni contenitore
	    mBox = myPDFlvPage.parent;
		mBox.itemLayer = myDocument.layers.item(myLivello1);
		mBox.geometricBounds = [0,0, LVvert.editValue*pt2mm, LVoriz.editValue*pt2mm];
		//rimetto scala e rotaz box e cont
		myPDFlvPage.absoluteVerticalScale = sv;
		myPDFlvPage.absoluteHorizontalScale = so;
		myPDFlvPage.absoluteRotationAngle = ro;
		myLvH = LVvert.editValue*pt2mm;
		myLvW = LVoriz.editValue*pt2mm;
		myAbH = LVvert.editValue*pt2mm+2*abOriz;
		myAbW = LVoriz.editValue*pt2mm+2*abVert;
		mBox.fit(FitOptions.centerContent);
		//metto abondanza finta
		mBox.geometricBounds = [mBox.geometricBounds[0]-abOriz, mBox.geometricBounds[1]-abVert, mBox.geometricBounds[2]+abOriz, mBox.geometricBounds[3]+abVert];
	}
	if (TipoImpose.selectedIndex!=5){
		// Ruoto perche (orizz ma scelta vert) oppure (vert ma scelta orizz)
		if (((myOrizzVert == 1)&&(myLvW>myLvH)) || ((myOrizzVert == 0)&&(myLvW<myLvH))){
		   mBox.rotate(90, AnchorPoint.centerAnchor, true, true);
			// Posiziono a pinza al centro
			myLvX1 = LastraW/2-myAbH/2;
			myLvY1 = LastraH + abOriz - InizioLavoro;
			mBox.move([myLvX1, myLvY1], undefined);
		}
		else{
			// Posiziono a pinza al centro
			myLvX1 = LastraW/2-myAbW/2;
			myLvY1 = LastraH - ((myAbH - abOriz)+ InizioLavoro);
			mBox.move([myLvX1, myLvY1], undefined);
		}
	}
	else{
		// Ruoto perche (orizz ma scelta vert) oppure (vert ma scelta orizz)
		if (myLvW<myLvH){
		   mBox.rotate(90, AnchorPoint.centerAnchor, true, true);
			// Posiziono a pinza al centro
			myLvX1 = LastraW/2-myAbH/2;
			myLvY1 = LastraH + abOriz - InizioLavoro;
			mBox.move([myLvX1, myLvY1], undefined);
		}
		else{
			// Posiziono a pinza al centro
			myLvX1 = LastraW/2-myAbW/2;
			myLvY1 = LastraH - ((myAbH - abOriz)+ InizioLavoro);
			mBox.move([myLvX1, myLvY1], undefined);
		}
	}
	//metto label x spostamento layer
	mBox.label = "pag";
	// Ritaglio a lavoro
	mBox.geometricBounds = [mBox.geometricBounds[0]+abOriz, mBox.geometricBounds[1]+abVert, mBox.geometricBounds[2]-abOriz, mBox.geometricBounds[3]-abVert];
	//Metto i Crocini, non nel Doppio Taglio
	myOldQc = myQc;
	if((DTvert.editValue*pt2mm/2-1)>myCropMarkLength){
		myQc = myQc*5*3;
	}
	if((DToriz.editValue*pt2mm/2-1)>myCropMarkLength){
		myQc = myQc*7*11;
	}
	myDrawPrintersMarks(myPageObj, mBox);
	myQc = myOldQc;
	//se spuntato metto i crocini interni
//	if((myCrociniIntCheckbox.checkedState==true) && (myQc==1)){
	if(myCrociniIntCheckbox.checkedState==true){
		myCropMarkLength = 1.5;
		myCropMarkOffset = 2;
		myOldQc = myQc;
		myCrocInt = true;
		myQc = 3*5*7*11/myOldQc;
		myDrawPrintersMarks(myPageObj, mBox);
		myCrocInt = false;
		myQc = myOldQc;
		myCropMarkLength = 6;
		myCropMarkOffset = 2.5;
	}
	// Rotazioni pagine per tipo imposizione
	switch (TipoImpose.selectedIndex){
		case 0:
		// 1 up
		break;
		case 1:
		// 2 up
		break;
		case 2:
		// 2 up quartini
		if (myQc == 5*7*11){
			if (((myOrizzVert == 1)&&(myLvW>myLvH)) || ((myOrizzVert == 0)&&(myLvW<myLvH))){
				myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
			}
		}
		break;
		case 3:
		// 2 up opuscolo
		if (myQc == 3*7*11){
			if (((myOrizzVert == 1)&&(myLvW>myLvH)) || ((myOrizzVert == 0)&&(myLvW<myLvH))){
				myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
			}
		}
		break;
		case 4:
		// 4 up
		break;
		case 5:
		// 4 up opuscolo
		if (myOrizzVert == 0){
//oriz
			if (myBookR == true){
//ruotato
				if (myBk==false){
//bianca
					switch (myQc){
						case (3*11):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
						case (3*7):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
						case (5*11):
						break;
						case (7*5):
						break;
					}
				}
				else{
//volta
					switch (myQc){
						case (3*11):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
						case (3*7):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
						case (5*11):
						break;
						case (7*5):
						break;
					}
				}
			}
			else{
//non ruotato
				if (myBk==false){
//bianca
					switch (myQc){
						case (3*11):
						break;
						case (3*7):
							if(myQbev){
								myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
							}
							else{
							}
						break;
						case (5*11):
						break;
						case (7*5):
							if(myQbev){
								myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
							}
							else{
							}
						break;
					}
				}
				else{
//volta
					switch (myQc){
						case (3*11):
						break;
						case (3*7):
						break;
						case (5*11):
						break;
						case (7*5):
						break;
					}
				}
			}
		}
		else{
//vert
			if (myBookR == true){
//ruotato
				if (myBk==false){
//bianca
					switch (myQc){
						case (3*11):
						break;
						case (3*7):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
						case (5*11):
						break;
						case (7*5):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
					}
				}
				else{
//volta
					switch (myQc){
						case (3*11):
						break;
						case (3*7):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
						case (5*11):
						break;
						case (7*5):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
					}
				}
			}
			else{
//non ruotato
				if (myBk==false){
//bianca
					switch (myQc){
						case (3*11):
							if(myQbev){
							}
							else{
								myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
							}
						break;
						case (3*7):
							if(myQbev){
							}
							else{
								myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
							}
						break;
						case (5*11):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
						case (7*5):
							myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
						break;
					}
				}
				else{
//volta
					switch (myQc){
						case (3*11):
						break;
						case (3*7):
						break;
						case (5*11):
						break;
						case (7*5):
						break;
					}
				}
			}
		}
		break;
		case 6:
		// riempi
		break;
		case 7:
		// manuale
		case 8:
		// manuale MP
		case 9:
		// manuale MPFR
		break;
	}
// Rimetto Abbondanza
var mB = new Array(3);
mB = [0, 0, 0, 0];
//abb 4 lati DT
	if (myQc == 1){
		if((DTvert.editValue*pt2mm/2)>=abVert){
		  mB = [mB[0], -abVert, mB[2], +abVert];
		}
		else{
		  mB = [mB[0], -DTvert.editValue*pt2mm/2, mB[2], DTvert.editValue*pt2mm/2];
		}
		if((DToriz.editValue*pt2mm/2)>=abOriz){
		  mB = [-abOriz, mB[1], abOriz, mB[3]];
		}
		else{
		  mB = [-DToriz.editValue*pt2mm/2, mB[1], DToriz.editValue*pt2mm/2, mB[3]];
		}
	}
//abb sotto croc
	if (myQc % 11==0){
		if((DToriz.editValue*pt2mm/2)>=abOriz){
		  mB = [-abOriz, mB[1], abOriz, mB[3]];
		}
		else{
		  mB = [-DToriz.editValue*pt2mm/2, mB[1], abOriz, mB[3]];
		}
	}
//abb sopra croc
	if (myQc % 7==0){
		if((DToriz.editValue*pt2mm/2)>=abOriz){
		  mB = [-abOriz, mB[1], abOriz, mB[3]];
		}
		else{
		  mB = [-abOriz, mB[1], DToriz.editValue*pt2mm/2, mB[3]];
		}
	}
//abb sx e dx DT
	if ((myQc == 11)||(myQc == 7)||(myQc == 7*11)){
		if((DTvert.editValue*pt2mm/2)>=abVert){
		  mB = [mB[0], -abVert, mB[2], abVert];
		}
		else{
		  mB = [mB[0], -DTvert.editValue*pt2mm/2, mB[2], DTvert.editValue*pt2mm/2];
		}
	}
//abb sx croc
	if (myQc % 3==0){
		if((DTvert.editValue*pt2mm/2)>=abVert){
		  mB = [mB[0], -abVert, mB[2], abVert];
		}
		else{
		  mB = [mB[0], -abVert, mB[2], DTvert.editValue*pt2mm/2];
		}
	}
//abb dx croc
	if (myQc % 5==0){
		if((DTvert.editValue*pt2mm/2)>=abVert){
		  mB = [mB[0], -abVert, mB[2], abVert];
		}
		else{
		  mB = [mB[0], -DTvert.editValue*pt2mm/2, mB[2], abVert];
		}
	}
//abb sopra e sotto DT
	if ((myQc == 3)||(myQc == 5)||(myQc == 5*3)){
		if((DToriz.editValue*pt2mm/2)>=abOriz){
		  mB = [-abOriz, mB[1], abOriz, mB[3]];
		}
		else{
		  mB = [-DToriz.editValue*pt2mm/2, mB[1], DToriz.editValue*pt2mm/2, mB[3]];
		}
	}
//abb 2 lati + 2 lati croc
	if (myQc == 7*11){
		  mB = [-abOriz, mB[1], abOriz, mB[3]];
	}
	if (myQc == 5*3){
		  mB = [mB[0], -abVert, mB[2], abVert];
	}
//abb 4 lati croc
	if ((myQc == 3*5*7*11)||(myQc == 0)){
		  mB = [-abOriz, -abVert, abOriz, +abVert];
	}
//abb 3 lati croc
	if ((myQc == 3*7*11)||(myQc == 5*7*11)){
		  mB = [mB[0], mB[1], abOriz, mB[3]];
	}
	mBox.geometricBounds = [
		mBox.geometricBounds[0]+mB[0],
		mBox.geometricBounds[1]+mB[1],
		mBox.geometricBounds[2]+mB[2],
		mBox.geometricBounds[3]+mB[3]
	];
}
function myTryPlacePdf(myFile, myPageObj, myCrop){
try{
	app.pdfPlacePreferences.pdfCrop = myCrop;
	myPdf = myPageObj.place(File(myFile), [0,0]);
	myPdfX1 = myPdf.geometricBounds[1];
	myPdfY1 = myPdf.geometricBounds[0];
	myPdfX2 = myPdf.geometricBounds[3];
	myPdfY2 = myPdf.geometricBounds[2];
	myW = myPdfX2 - myPdfX1;
	myH = myPdfY2 - myPdfY1;
	mBox = myPdf.parent;
	mBox.remove();
	myOk = true;
	}
catch (myError){
	myOk = false;
	}
return myOk;
}
function myInfoSignature(myPageObj, myPageNr, PDFFirstPagesNum, PDFLastPagesNum, myBrk){
var myRegistrationColor = myDocument.colors.item("Registration");
var myNoneSwatch = myDocument.swatches.item("None");
	//Create a layer to hold the printers marks (if it does not already exist).
	var myLayer = myDocument.layers.item("IndicatoriStampa");
	try{
		myLayerName = myLayer.name;
	}
	catch (myError){
		var myLayer = myDocument.layers.add({name:"IndicatoriStampa"});
	}
	var myQuad = myPageObj.textFrames.add();
	myQuad.label = "nobj";
	myX1 = ""+(LastraW/2-100);
	myY1 = ""+(LastraH-6);
	myX2 = ""+(LastraW/2+40);
	myY2 = ""+(LastraH-2);
	myQuad.geometricBounds = [myY1,myX1,myY2,myX2];
	myPages = PDFLastPagesNum-PDFFirstPagesNum+1;
switch (TipoImpose.selectedIndex){
	case 0:
	// 1 up
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+"SEGNATURA < "+(myPageNr-PDFFirstPagesNum+1)+" > DI < "+(PDFLastPagesNum-PDFFirstPagesNum+1)+" >";
	break;
	case 1:
	// 2 up
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+"SEGNATURA < "+(myPageNr-PDFFirstPagesNum+1)+" > DI < "+(PDFLastPagesNum-PDFFirstPagesNum+1)+" >";
	break;
	case 2:
	// 2 up quartini
	if( ((myPages % 2)!=0) || ((myPages % 4)==0) || ( ((myPages % 2)==0) && (myPageNr<(myPages-1)) ) ){
		myQuad.contents =
		"LAVORO: < "+myFileName+" >   "+
		"SEGNATURA < "+
		(parseInt((myPageNr-PDFFirstPagesNum)/4)+1)+
		" > DI < "+(parseInt(myPages/4)+((myPages==3)? 1: 0))+" >   "+((parseInt((myPageNr-PDFFirstPagesNum)/2+1)%2==1)? "BIANCA" :"VOLTA");
	}
	else{
		myQuad.contents =
		"LAVORO: < "+myFileName+" >   "+
		"SEGNATURA < "+
		(parseInt((myPageNr-PDFFirstPagesNum)/4)+1)+
		" > DI < "+(parseInt(myPages/4)+1)+" >   BIANCA & VOLTA";
	}
	break;
	case 3:
	// 2 up opuscolo
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+
	"SEGNATURA < "+
	(parseInt((myPageNr-PDFFirstPagesNum)/4)+1)+
	" > DI < "+(parseInt(myPages/4))+" >   "+((parseInt((myPageNr-PDFFirstPagesNum)/2+1)%2==1)? "BIANCA" :"VOLTA");
	break;
	case 4:
	// 4 up
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+"SEGNATURA < "+(myPageNr-PDFFirstPagesNum+1)+" > DI < "+(PDFLastPagesNum-PDFFirstPagesNum+1)+" >";
	break;
	case 5:
	// 4 up opuscolo
	if((nOrigPages % 4 ==0)&&(nOrigPages % 8 !=0)&&(myPageNr==1)){
	myQuad.contents = "LAVORO: < "+myFileName+
	" >   "+"SEGNATURA < "+myPageNr+
	" > DI < "+(parseInt(myPages/4))+" >   BIANCA & VOLTA";
	}
	else{
	qbv = ((nOrigPages % 4 ==0)&&(nOrigPages % 8 !=0))? 2:0;
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+
	"SEGNATURA < "+
	(parseInt((myPageNr-PDFFirstPagesNum)/8)+1+qbv/2)+
	" > DI < "+(parseInt(myPages/8+qbv))+" >   "+((parseInt((myPageNr)/4+qbv/2)%2==0)? "BIANCA" :"VOLTA");
	}
	break;
	case 6:
	// riempi formato
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+"SEGNATURA < "+(myPageNr-PDFFirstPagesNum+1)+" > DI < "+(PDFLastPagesNum-PDFFirstPagesNum+1)+" >";
	break;
	case 7:
	// manuale
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+"SEGNATURA < "+(myPageNr-PDFFirstPagesNum+1)+" > DI < "+(PDFLastPagesNum-PDFFirstPagesNum+1)+" >";
	break;
	case 8:
	// manuale MP
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+"SEGNATURA < "+(myPageNr-PDFFirstPagesNum+1)+" > DI < "+(PDFLastPagesNum-PDFFirstPagesNum+1)+" >";
	break;
	case 9:
	// manuale MPFR
	myQuad.contents =
	"LAVORO: < "+myFileName+" >   "+"SEGNATURA < "+(myPageNr-PDFFirstPagesNum+1)+" > DI < "+(PDFLastPagesNum-PDFFirstPagesNum+1)+" >";
	break;
}
myQuad.paragraphs.item(0).appliedFont = "Arial";
myQuad.paragraphs.item(0).justification = Justification.leftAlign;
myQuad.paragraphs.item(0).pointSize = 8;
myQuad.textFramePreferences.verticalJustification = VerticalJustification.centerAlign;
myQuad.paragraphs.item(0).fillColor = myRegistrationColor;
myQuad.itemLayer = myDocument.layers.item("IndicatoriStampa");
}
-- 
Ancora oggi il viandante che passa per quel luogo,
attraverso il bagliore rosso delle finestre, vede innumerevoli spettri
che si torcono, spasimando, al ritmo di una musica dissonante.
E come un'orrenda marea, esce all'infinito dalla pallida soglia
un'agghiacciante folla che ride, ma non sorride mai più.

 ha scritto nel messaggio 
news:mn.9c227d7b7...@hotmail.com...


Ti ringrazio ma non riesco ad usarlo.
Ho fatto come da te detto, mi apre il file PDF e poi lo chiude senza nessuna 
finestra di dialogo e nessun effetto.
Grazie Ciao DimAnto 

NoSpam...@Libero.it ha detto questo martedì :

Che versione di InDesign usi? Lo lanci dalla palette "Scripts" di 
InDesign vero?
Ciao


 ha scritto nel messaggio 
news:mn.9c227d7b7...@hotmail.com...


CS2 Si palette Scripts
Ciao DimAnto 

Aggiungo, nella CS2 funziona mentre nella CS3 mi rende questo errore:
javascript Errore!
Codice errore: 24
Stringa errore: myCleanUp non è una funzione
Riga: 279
Sorgente: myCleanUp();
Saluti @ndrea
<NoSpam...@Libero.it> ha scritto nel messaggio 
news:8zi0j.177512$U01.1...@twister1.libero.it...



Purtroppo non ho CS3 per provare :-/


Provato su un altro computer FUNZIONA
MAGNIFICO Grazie 1000
Ciao DimAnto 

 Saluti @ndrea
Grazie! E' utile se hai bene in mente cosa vuoi ottenere, non ha
grandi automatismi.
Per es. se devi usare un formato carta che non c'è nella lista, crea
il doc delle dimensioni che ti servono prima di lanciare lo script, si
accorgerà che c'è il doc e ti chiede se vuoi usarlo.
Con un po' di cautela puoi editare lo script per preimpostarlo come
meglio credi.
Dove lavoravo lo usano tuttora per fare imposizioni per offset 35x50 e
per digitale 305x457.
Ciao!


Se non ti funziona su un CS2 c'è una linea dello script da abilitare,
succede se alcuni script disabilitano le finestre di dialogo e si
dimenticano di riabilitarle:
da così:
//se CS2 non mostra le finestre di dialogo:
//app.scriptingPreferences.userInteractionLevel =
UserInteractionLevels.interactWithAll;
a così:
//se CS2 non mostra le finestre di dialogo:
app.scriptingPreferences.userInteractionLevel =
UserInteractionLevels.interactWithAll;
col Notepad.
Ciao