kindly help this code, I have 97 Pages, and it saved to page range wise
// JavaScript for Adobe InDesign
// Get the active InDesign document
var myDocument = app.activeDocument;
// Specify the path to your CSV file
var csvFilePath = "C:\\Users\\Yaser\\Desktop\\file_name.txt";
// Read the content of the CSV file
var csvFile = new File(csvFilePath);
csvFile.open("r");
var csvContent = csvFile.read();
csvFile.close();
// Split the CSV content into rows
var csvRows = csvContent.split("\n");
// Loop through rows in the CSV
for (var i = 1; i < csvRows.length; i++) { // Assuming the header is in the first row
var columns = csvRows[i].split(",");
var pageRangeStart = columns[0];
var pageRangeEnd = columns[1];
var fileName = columns[2];
// Create a text frame on the first page
var myTextFrame = myDocument.pages[0].textFrames.add({
geometricBounds: [50, 50, 200, 200] // [top, left, bottom, right]
});
// Add text to the active document
myTextFrame.contents = "Page Range: " + pageRangeStart + "-" + pageRangeEnd + "\nFile Name: " + fileName;
// Export PDF for the specified page range
exportPDF(fileName, [pageRangeStart, pageRangeEnd]);
// Remove the text frame if needed
// myTextFrame.remove();
}
// Function to export PDF with specified page range
function exportPDF(pdfPath, pageRange) {
// Set the export options
//exportOptions.pageRange = pageRange.join(",");
preset = app.pdfExportPresets.itemByName("[Press Quality]");
// Export the document to PDF
myDocument.exportFile(ExportFormat.PDF_TYPE, new File(pdfPath), false, preset);
}
