function OnInit(initData) { initData.name = "PDF pages"; initData.desc = "Column to display the number of pages in PDF files"; initData.version = "1.0"; initData.copyright = "(c) 2025 DASOTA"; initData.default_enable = true; } function OnAddColumns(addColData) { var col = addColData.AddColumn(); col.name = "PDFpages"; col.label = "PDF pages"; col.justify = "right"; col.autorefresh = true; col.type = "number"; col.method = "OnGet"; } function OnGet(getData) { var item = getData.item; var ext = item.ext ? item.ext.toLowerCase() : ""; if (ext !== ".pdf") { getData.value = ""; return; } var shell = new ActiveXObject("WScript.Shell"); var pdfinfoPath = "C:\\Poppler\\Library\\bin\\pdfinfo.exe"; // Path to the pdfinfo.exe file try { var exec = shell.Exec('"' + pdfinfoPath + '" "' + item.realpath + '"'); var pages = ""; while (!exec.StdOut.AtEndOfStream) { var line = exec.StdOut.ReadLine(); if (line.match(/^Pages:\s*(\d+)/i)) { pages = RegExp.$1; break; } } getData.value = pages; } catch (e) { getData.value = ""; } }