MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getPDFPageCount

Function getPDFPageCount

src/utils/pdf.ts:119–135  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

117 * Returns `null` if pdfinfo is not available or if the page count cannot be determined.
118 */
119export async function getPDFPageCount(
120 filePath: string,
121): Promise<number | null> {
122 const { code, stdout } = await execFileNoThrow('pdfinfo', [filePath], {
123 timeout: 10_000,
124 useCwd: false,
125 })
126 if (code !== 0) {
127 return null
128 }
129 const match = /^Pages:\s+(\d+)/m.exec(stdout)
130 if (!match) {
131 return null
132 }
133 const count = parseInt(match[1]!, 10)
134 return isNaN(count) ? null : count
135}
136
137export type PDFExtractPagesResult = {
138 type: 'parts'

Callers 2

callInnerFunction · 0.85
tryGetPDFReferenceFunction · 0.85

Calls 1

execFileNoThrowFunction · 0.85

Tested by

no test coverage detected