Skip to content

Commit

Permalink
Merge pull request #17 from hinagiku-dev/parsePDF
Browse files Browse the repository at this point in the history
fix: replace \n in pdf
  • Loading branch information
TakalaWang authored Nov 27, 2024
2 parents 2086f92 + 01d4fd1 commit 730e3ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/server/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ export async function pdf2Text(filePath: string): Promise<string> {
const dataBuffer = fs.readFileSync(filePath);
const data = await pdf(dataBuffer);

const text = data.text;
// remove space line
data.text = text.replace(/^\s*\n+/gm, '\n');

return data.text;
}

0 comments on commit 730e3ac

Please sign in to comment.