Entonces, el siguiente script es una versión modificada del script que encontré aquí . Su objetivo es:
A partir de ahora, lo único que he logrado que funcione es el elemento n. ° 1. Por alguna razón, este script no exportará sangrado sin importar lo que haga, aunque la propia documentación de InDesign sugiere que lo que tengo allí debería funcionar. Además, no he podido descifrar la forma correcta de manejar los elementos 3 y 4; Traté de modificar la función GetDate para manejar esto, pero no funcionó (como puede ver en las líneas comentadas).
Entonces, gurús de las secuencias de comandos de StackExchange, ¿qué estoy haciendo mal? Cualquier y toda ayuda será muy apreciada. ¡Gracias!
* Nota: en realidad, no necesito la fecha adjunta al nombre del archivo; Solo estaba usando la función GetDate como contenedor para el código de extracción de nombres, ya que la función ya estaba en el código.
var scriptName = "Export current page to PDF - 1.0";
Main();
//===================================== FUNCTIONS ======================================
function Main() {
if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
var doc = app.activeDocument;
if (app.activeWindow.constructor.name != "LayoutWindow") ErrorExit("Unable to get page number. Quit story editor.", true);
var page = app.activeWindow.activePage;
with (app.pdfExportPreferences){
pageRange = page.name;
viewPDF = true;
bleedBottom = app.activeDocument.documentPreferences.
documentBleedBottomOffset;
bleedTop = app.activeDocument.documentPreferences.documentBleedTopOffset;
bleedInside = app.activeDocument.documentPreferences.
documentBleedInsideOrLeftOffset;
bleedOutside = app.activeDocument.documentPreferences.
documentBleedOutsideOrRightOffset;
//If any bleed area is greater than zero, then export the bleed.
if(bleedBottom == 0 && bleedTop == 0 && bleedInside == 0 &&
bleedOutside == 0){
useDocumentBleedWithPDF = true;
}
else{
useDocumentBleedWithPDF = false;
}
}
var fileName = doc.name.replace(/\.indd$/, "") + "_" + GetDate() + ".pdf";
var file = new File("~/Desktop/" + fileName);
var myExportPreset = app.pdfExportPresets.item("[High Quality Print]");
alert (myExportPreset);
doc.exportFile(ExportFormat.pdfType, file, false, myExportPreset);
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
function GetDate() {
//var page = app.activeWindow.activePage;
//var nameFrame = page.textFrames.item(1).contents;
//var employeeName = nameFrame.substr(2)
var date = new Date();
if ((date.getYear() - 100) < 10) {
var year = "0" + new String((date.getYear() - 100));
}
else {
var year = new String((date.getYear() - 100));
}
var dateString = (date.getMonth() + 1) + "-" + date.getDate() + "-" + year + "_" + date.getHours() + "-" + date.getMinutes() + "-" + date.getSeconds();
return dateString;
}
Con respecto al sangrado, ya casi estás allí. Has invertido la lógica en la prueba de sangrado y no deberías usar el ajuste preestablecido, ya que ya estás configurando las preferencias en tu with
bloque pdfExportPreferences.
Tal vez si desea usar un ajuste preestablecido, entonces debería cargar el ajuste preestablecido antes del with
bloque, pero no lo he probado.
Entonces:
//If any bleed area is greater than zero, then export the bleed.
if(bleedBottom == 0 && bleedTop == 0 && bleedInside == 0 &&
bleedOutside == 0){
Debiera ser:
if(bleedBottom != 0 && bleedTop != 0 && bleedInside != 0 &&
bleedOutside != 0){
Y:
var myExportPreset = app.pdfExportPresets.item("[High Quality Print]");
alert (myExportPreset);
doc.exportFile(ExportFormat.pdfType, file, false, myExportPreset);
Debiera ser:
doc.exportFile(ExportFormat.pdfType, file, false);
Debe duplicar el ajuste preestablecido "[Impresión de alta calidad]" y realizar cualquier cambio ya que, a diferencia de la pageRange
preferencia, la configuración de sangrado será anulada por ExportPreset. Puedes colocar tu preset duplicado cuando hayas terminado:
var myExportPreset = app.pdfExportPresets.item("[High Quality Print]").duplicate();
myExportPreset.useDocumentBleedWithPDF = true;
doc.exportFile(ExportFormat.PDF_TYPE, myFile, false, myExportPreset );
myExportPreset.remove();
Yorik
ajw-arte
ajw-arte
Yorik
Bruno