MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / decodePdfString

Function decodePdfString

src/pdf.js:128–138  ·  view source on GitHub ↗

* Decode PDF string escapes: \n, \r, \t, \\, \(, \), octal

(s)

Source from the content-addressed store, hash-verified

126 * Decode PDF string escapes: \n, \r, \t, \\, \(, \), octal
127 */
128function decodePdfString(s) {
129 return s.replace(/\\([nrtbf()\\]|\d{1,3})/g, (_, c) => {
130 if (c === 'n') return '\n';
131 if (c === 'r') return '\r';
132 if (c === 't') return '\t';
133 if (c === 'b') return '\b';
134 if (c === 'f') return '\f';
135 if (c === '(' || c === ')' || c === '\\') return c;
136 return String.fromCharCode(parseInt(c, 8));
137 });
138}
139
140/**
141 * Try to extract text from base64-encoded PDF.

Callers 1

extractTextOpsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected