Newsgroup: it.comp.grafica
Titolo: Re: PDF e imposition

 più utili oltre Acrobat e PitStop?
io uso acrobat con pitstop, e i due di quite, boxoftricks e imposing, 
risolvono praticamente tutte le esigenze.
Per esigenze particolari consulta comunque 
www.pdfstore.com
 o 
www.planetpdf.com
ci sono sempre le demo, di solito a scadenza; ho avuto l'esigenza di 
realizzare dei sedicesimi fatti con due ottavi uno dentro l'altro e l'ho 
risolta con un plugin di cui ora mi sfugge il nome. Non è molto corretto: 
l'ho usato, adesso è scaduto ma io ho finito il lavoro (erano una mezza 
dozzina di libri). Se quel lavoro continua lo comprerò :-)
ciao
rodolfo 

 più utili oltre Acrobat e PitStop?
io dico Preps 

 size e aggiungendo i crocini di taglio suoi della misura scelta?
lo è
ciao
rodolfo 

 più utili oltre Acrobat e PitStop?
Di norma l'indigo ha un software proprietario di gestione dell'imposizione.
Bye
-- 
psss.: Se vuoi scrivermi in privato,
togli Sir. e cita il messaggio ; ]

 cose del genere.
Capito.. domanda, è vero che il software non legge l'abbondanza quindi
stampa sempre al vivo (rif. a indigo)??


 più utili oltre Acrobat e PitStop?
C'è un plug-in per Acrobat dal costo contenuto e molto flessibile:
QuiteImposing.
Io per le mie esigenze lavorative di stampa offset (macchina 35x50,
CTP Presstek) mi sono creato un JavaScript che impone documeti pdf con
la possibilità di mettere barre colore, registri, nome segnatura con
varie preimpostazioni: "2 copie uguali", "Opuscolo", "Riempi formato",
Pinza lavoro, doppio taglio, centratura, ridimensionamento ecc...
Lo uso con soddisfazione anche per le imposizioni della macchina
digitale (Ocè).
Il vantaggio rispetto a QuiteImposing è quello di avere come risultato
un file InDesing, sul quale eventualmente intervenire, o semplicemente
aggiornare i collegamenti con un nuovo pdf o lo stesso
corretto/modificato mantenendo l'imposizione inalterata.
Se pensi ti possa essere utile posso postarlo (sono circa 2500 linee di
codice) da salvare un file di testo con estensione ".js" (CS) o "jsx"
(CS2), anzi lo allego ora...  :)
Va messo nella cartella "InDesign CS\Presets\Scripts"
Con l'occasione saluto tutto il ng, mi scuso per la scarsa
partecipazione, ma nel nuovo posto di lavoro ho meno tempo libero e
scarico i msg e leggo/posto offline qunado posso.
Cerco di compensare con la lunghezza: 2600 righe!!!
Ciao  ;-)
--
// ****************************************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 la finestre di dialogo attivare queta linea:
//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.29   <"+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:""+myRoundF(myLvW)+" mm  x"});
					staticTexts.add({staticLabel:"  "+myRoundF(myLvH)+" 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:""+myRoundF(myMdW)+" mm  x"});
							staticTexts.add({staticLabel:"  "+myRoundF(myMdH)+" mm"});
						}
					}
					else{
						with (dialogRows.add()){
							staticTexts.add({staticLabel:"Vert = "+myRoundF(abVert)+" mm"});
							staticTexts.add({staticLabel:"Oriz = "+myRoundF(abOriz)+" 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:["50mm","55mm","148,5mm","210mm"], minWidth:80});
				var LVvert = measurementComboboxes.add({editValue:(297*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(1000*mm2pt), largeNudge:1, smallNudge:1, stringList:["80mm","90mm","210mm","297mm"], 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){
//			with (dialogColumns.add()){
			var ListaCarta = dropdowns.add({stringList:["35x50cm", "32x44cm", "23x33cm", "50x23cm", "45.7x30.5cm", "44.0x30.5cm"], 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:"});
//			with (dialogColumns.add()){
				var InizioLavoroEB = measurementComboboxes.add({editValue:(11.5*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(1000*mm2pt), largeNudge:1, smallNudge:1, stringList:["0mm","5mm","10mm","11,5mm","15mm","20mm"], minWidth:80});
//			}
//			with (dialogColumns.add()){
				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"], 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:["0mm","1mm","2mm","3mm","4mm","5mm","6mm","8mm","10mm","12mm","15mm"]});
				var DTvert = measurementComboboxes.add({editValue:(5*mm2pt), editUnits:MeasurementUnits.millimeters, minimumValue:0, maximumValue:(100*mm2pt), largeNudge:1, smallNudge:1, stringList:["0mm","1mm","2mm","3mm","4mm","5mm","6mm","8mm","10mm","12mm","15mm"]});
			}
		}
	}
}
//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;
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)){
		//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][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--;
			}
			myPdfPage = PDFFirstPagesNum+order[i+1][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--;
			}
			myPdfPage = PDFFirstPagesNum+order[i+0][1];
				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][0];
				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;
	}
//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];
			}
			else{
				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];
			}
			else{
				myPdfPage = PDFFirstPagesNum+order[i+2][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--;
			}
			if(myBk){
				myPdfPage = PDFFirstPagesNum+order[i+2][0];
			}
			else{
				myPdfPage = PDFFirstPagesNum+order[i+2][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--;
			}
			if(myBk){
				myPdfPage = PDFFirstPagesNum+order[i+0][1];
			}
			else{
				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][1];
			}
			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][0];
			}
			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][1];
			}
				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][0];
			}
				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,false,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);
			}
		}
	}
	//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;
}
//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.
//	myLayerItems.push(myDocument.spreads[mySindex].pageItems[myEnum].itemLayer);
	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){
		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++){
//		myPageObj.pageItems[myEnum].itemLayer = myLayerItems[myEnum];
//	}
	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 = "Bold";
	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 = "Bold";
	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 = "Bold";
	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 = "Bold";
	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 = "Bold";
		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 (myQc == 3*11){
		if (myOrizzVert == 1){
		myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
		}
		if (myBookR == true){
		myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
		}
	}
	if (myQc == 3*7){
		myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
	}
	if (myQc == 5*7){
		if (myOrizzVert == 0){
		myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
		}
		if (myBookR == true){
		myPDFlvPage.rotate(180, AnchorPoint.centerAnchor, true, true);
		}
	}
	break;
	case 6:
	// riempi
	break;
	case 7:
	// manuale
	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;
}
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");
}
-- 
Non so cosa voglio, ma so come ottenerlo.
http://www.youtube.com/watch?v=LB-HWJRg4-I

 gli serviva qualche dritta per velocizzare un po' il workflow.
Capito.. noi ci lavoriamo ma appunto si diceva di questa limitazione..


Ciao a tutti,
mi inserisco nella discussione perchè ho un problema: lavoro da poco
con le stampe digitali e mi piacerebbe fare bella figura con i
"padroni" come posso stampare su A3 dei fogli A4 che provengono da una
stampa unione word-excel mantenendoli in un ordine tale che tagliano
gli A3 nel mezzo e sovrapponendo i 2 plichi ottenuti riesca a mantenere
l'ordine iniziale?
Tanks.
Larsenio ha scritto:


 l'ordine iniziale?
Non saprei proprio dirtelo :)
Word Excel li trascuro.. :)


 Ciao  ;-)
Ti ringrazio immensamente per quello che hai fatto. mi è di un utilita
infinita, grazie mille.

 l'ordine iniziale?
Per fare quello che chiedi basta usare qualsiasi sofware (lo permettono 
anche molti driver di stampa) che crei il classico "Booklet" (opuscolo 
pinzato, saddle sticked).
Cioè come ti suggeriva Lutrin il primo foglio deve avere:
 - fronte = Ultima pagina,  Prima pagina
 - retro  = Seconda pagina, Penultima pagina
 - eccetera...
Una volta stampati li taglia a metà (dove andrebbe la piega e la 
pinzatura) e "chiudi" l'opuscolo, capovolgendo le pagine di destra (la 
risma che parte da [n-pag : 2 +1] all'ultima) e sovrapponendo la risma 
con la prima pagina.
E' più dificile da spiegare che da fare, riassumendo: stampi come fosse 
un opuscolo pinzato, tagli a metà, capovolgi, sovrapponi.
Ciao!


come dici tu è più difficile da spiegare che a fare... appena ho un
minuto leggo bene bene provo subito.
grazie per adesso
Borgir ha scritto:


ma così non ottengo necessariamente una stampa fronte retro?
Borgir ha scritto:


 infinita, grazie mille.
L'ho fatto a tempo perso, per non fare l'imposizione a mano. Dove 
lavoro ora hanno comperato il CPT senza uno straccio di prgramma per 
farlo e mi hanno piazzato alla "preparazione delle lastre".
Se vuoi te lo puoi personalizzare abbastanza facilamente, almeno per i 
formati e le impostazioni predefinite.
Puoi farlo con qualsiasi editor di testo, ma ti consiglio "Extend 
Script Toolkit" liberamente scaricabile dal sito Adobe. Ti colora il 
codice e facilita moltissimo la lettuta e la comprensione.
Se trovi qualche bug, sicuramente ce ne sono, fammelo sapere.
A proposito, qualcuno sa quali sono e quanto costano i software 
dedicati (Preps?)? Da una veloce ricerca i pochi che avevo trovato mi 
sembravano molto alti per una coop come la nostra.
Ciao!


 sembravano molto alti per una coop come la nostra.
Uhmm... un cpt che fa le lastre, forse intendevi dire CTP..
Comunque uno straccio di flusso di lavoro dovresti averlo imho.. Preps il
prezzo è altino, ma soldoni li vale tutti.. ci dovrebbe essere il sito.


 Bye
concordo e sottoscrivo: un risparmio di tempo altissimo, soprattutto su 
lavori di molte pagine, ma anche per l' "imposizione" di schede ecc.