From 1a61aff87c4138e65d1be882ed6c349afa5f278a Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Mon, 8 Sep 2025 15:07:37 -0300 Subject: [PATCH 01/15] Add: advanced mode --- aux-funcitons.ts | 17 +++++++ index.ts | 117 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 aux-funcitons.ts diff --git a/aux-funcitons.ts b/aux-funcitons.ts new file mode 100644 index 0000000..a016c4a --- /dev/null +++ b/aux-funcitons.ts @@ -0,0 +1,17 @@ +const calculateStartLine = (controlPosX: {[key: string]: number}): number => { + let vectorKeys = Object.keys(controlPosX); + let moreUsualValue: {key:string, value: number} = {key:'', value: 0}; + + vectorKeys.forEach(key => { + if(controlPosX[key] > moreUsualValue.value){ + moreUsualValue = { + key, + value: controlPosX[key] as number + } + } + }) + + return (Number(moreUsualValue.key)+2) +} + +export default calculateStartLine; \ No newline at end of file diff --git a/index.ts b/index.ts index 095fd9e..ce04a0e 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,5 @@ import { pdfjs } from "react-pdf"; +import calculateStartLine from "./aux-funcitons"; // Path to the pdf.worker.js file pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.mjs`; @@ -42,4 +43,118 @@ const pdfToText = async (file: File | Blob | MediaSource): Promise => { return extractedText; }; -export default pdfToText; +/** + * Extracts text content from a PDF file like the original PDF. + * @param {File | Blob | MediaSource} file - The PDF file to extract text from. + * @returns {Promise} A promise that resolves with the extracted text content. + */ +const pdfToTextLikePDF = async (file: File | Blob | MediaSource): Promise => { + // Create a blob URL for the PDF file + const blobUrl = URL.createObjectURL(file); + + // Load the PDF file + const loadingTask = pdfjs.getDocument(blobUrl); + + let extractedText = ""; + try { + const pdf = await loadingTask.promise; + const numPages = pdf.numPages; + + let lastPage = 1 + + let sizeFontProm = 10; + let totalSize = 0; + let totalTokens = 0; + + let controlPosX: {[key: string]: number} = {} + + //Scan the first few pages to sample the beginning of a line of text + for (let pageNumber = 1; pageNumber <= numPages && pageNumber <= 5; pageNumber++) { + const page = await pdf.getPage(pageNumber); + const textContent = await page.getTextContent(); + + textContent.items.map((item) => { + if("transform" in item){ + if(item.height > 3 && item.str){ + totalSize = totalSize + item.height; + totalTokens++ + } + + const name: string =( ((item.transform[4]).toString()).split ('.'))[0] + controlPosX[name] = (controlPosX[name] || 0) + 1 + } + }) + } + sizeFontProm = totalSize/totalTokens; + + const startLine = calculateStartLine(controlPosX); + + // Iterate through each page and extract text + for (let pageNumber = 1; pageNumber <= numPages; pageNumber++) { + const page = await pdf.getPage(pageNumber); + const textContent = await page.getTextContent(); + + let lastToken = '' + let lastLastPositionY = 0 + let lastPositionY = 0 + + const pageText = textContent.items + .map((item, index) => { + if("str" in item){ + lastToken = '' + + lastLastPositionY = lastPositionY + lastPositionY = item.transform[5] + + //Is end of Page? + if(lastPage < pageNumber && pageNumber !== 1){ + lastToken = '\n', + lastPage++ + } + + //Is end of line + if(index > 1 && (lastLastPositionY-(sizeFontProm*1.6) > item.transform[5] )){ + lastToken = '\n' + } + + //Is new Line + if(lastLastPositionY-(sizeFontProm*1) > item.transform[5] + && item.transform[4] > startLine){ + lastToken = '\n' + } + + //Is a foot of page + if((index > 0 && lastLastPositionY < item.transform[5] )){ + lastToken = '\n' + } + + //Is a jump + if(lastPositionY === 0){ + lastToken = '\n' + } + return lastToken + item.str + }}) + .join(''); + extractedText += pageText; + } + } catch (error) { + throw new Error(`Failed to extract text from PDF: ${error}`); + } finally { + // Clean up the blob URL + URL.revokeObjectURL(blobUrl); + + // Free memory from loading task + loadingTask.destroy(); + } + return extractedText; +}; + +const selectModeToExtract = async (file: File | Blob | MediaSource, mode: 'simple' | 'advanced'): Promise => { + if (mode === 'simple') { + return pdfToText(file); + } else { + return pdfToTextLikePDF(file); + } +} + +export default selectModeToExtract; From 18b5e19a19c22d071db4eabd2187e26a1c38c6f8 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Fri, 21 Nov 2025 17:51:51 -0300 Subject: [PATCH 02/15] add: Detect linespacing --- index.ts | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/index.ts b/index.ts index ce04a0e..c564583 100644 --- a/index.ts +++ b/index.ts @@ -44,11 +44,12 @@ const pdfToText = async (file: File | Blob | MediaSource): Promise => { }; /** - * Extracts text content from a PDF file like the original PDF. + * Extracts text content from a PDF file. * @param {File | Blob | MediaSource} file - The PDF file to extract text from. + * @param lineSpacing - is space inter line an line standart * @returns {Promise} A promise that resolves with the extracted text content. */ -const pdfToTextLikePDF = async (file: File | Blob | MediaSource): Promise => { +const pdfToTextLikePDF = async (file: File | Blob | MediaSource, lineSpacing: number = 1): Promise => { // Create a blob URL for the PDF file const blobUrl = URL.createObjectURL(file); @@ -60,36 +61,34 @@ const pdfToTextLikePDF = async (file: File | Blob | MediaSource): Promise { - if("transform" in item){ + if("height" in item){ if(item.height > 3 && item.str){ - totalSize = totalSize + item.height; + totalFontSize = totalFontSize + item.height; totalTokens++ } - const name: string =( ((item.transform[4]).toString()).split ('.'))[0] + const name: string =(((item.transform[4]).toString()).split ('.'))[0] controlPosX[name] = (controlPosX[name] || 0) + 1 } }) } - sizeFontProm = totalSize/totalTokens; + sizeFontProm = totalFontSize/totalTokens; const startLine = calculateStartLine(controlPosX); - - // Iterate through each page and extract text + for (let pageNumber = 1; pageNumber <= numPages; pageNumber++) { const page = await pdf.getPage(pageNumber); const textContent = await page.getTextContent(); @@ -106,6 +105,10 @@ const pdfToTextLikePDF = async (file: File | Blob | MediaSource): Promise= 790){ + lastToken = '\n' + } //Is end of Page? if(lastPage < pageNumber && pageNumber !== 1){ lastToken = '\n', @@ -113,13 +116,14 @@ const pdfToTextLikePDF = async (file: File | Blob | MediaSource): Promise 1 && (lastLastPositionY-(sizeFontProm*1.6) > item.transform[5] )){ + if(index > 1 && (lastLastPositionY-(sizeFontProm*1.6*lineSpacing) > item.transform[5])){ lastToken = '\n' } - //Is new Line - if(lastLastPositionY-(sizeFontProm*1) > item.transform[5] - && item.transform[4] > startLine){ + //Is new parrafo + if(lastLastPositionY-(sizeFontProm*lineSpacing) > item.transform[5] + && item.transform[4] > startLine + ){ lastToken = '\n' } @@ -132,7 +136,8 @@ const pdfToTextLikePDF = async (file: File | Blob | MediaSource): Promise => { +const selectModeToExtract = async (file: File | Blob | MediaSource, mode: 'simple' | 'advanced', lineSpacing): Promise => { if (mode === 'simple') { return pdfToText(file); } else { - return pdfToTextLikePDF(file); + return pdfToTextLikePDF(file,lineSpacing); } } From 20462a66c9d5533ce1341fdade8e5c4a4bb8d879 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Fri, 21 Nov 2025 18:03:11 -0300 Subject: [PATCH 03/15] update data for NPM --- .github/workflows/npm-publish.yml | 67 ------------------------------- LICENSE | 2 +- README.md | 59 +++++++++++++++++---------- index.ts | 2 +- package.json | 9 +++-- 5 files changed, 44 insertions(+), 95 deletions(-) delete mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index 6b0b23a..0000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Publish NPM package - -on: - push: - branches: - - main - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: '20' - registry-url: 'https://registry.npmjs.org' - - - name: Install dependencies - run: npm install - - - name: Check the version - id: check - run: | - CURRENT_VERSION=$(jq -r .version package.json) - echo "Current version: $CURRENT_VERSION" - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") - echo "Latest tag: $LATEST_TAG" - - LATEST_VERSION=${LATEST_TAG#v} - - if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; - then - echo "Version changed" - echo "version_changed=true" >> $GITHUB_OUTPUT - echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - else - echo "Version not changed" - echo "version_changed=false" >> $GITHUB_OUTPUT - fi - - - name: Build - run: npm run build - if: steps.check.outputs.version_changed == 'true' - - - name: Publish - if: steps.check.outputs.version_changed == 'true' - run: npm publish --access public --no-git-checks - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} - - - name: Tag release - if: steps.check.outputs.version_changed == 'true' - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git tag -a "v${{ steps.check.outputs.new_version }}" -m "v${{ steps.check.outputs.new_version }}" - git push origin "v${{ steps.check.outputs.new_version }}" - - - - - - \ No newline at end of file diff --git a/LICENSE b/LICENSE index 6a97962..23b44a3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Utkarsh Pancholi +Copyright (c) 2025 Javier Bagatoli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 953748e..87d0e20 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ -# react-pdftotext +# react-pdftotext-advanced -Light-weight memory-safe client library for extracting plain text from pdf files. +This is a library based on "react-pdftotext" that aims to format text for readability without requiring extensive coding. + +This version separates paragraph and page endings, taking into account expected spacing and page breaks. ## Installing Using npm: ```js -npm install react-pdftotext +npm install react-pdftotext-advanced ``` ## Example @@ -22,35 +24,48 @@ Now add a input tag with type="file" to take file input. Import the pdf2text function from package -```js -import pdfToText from "react-pdftotext"; +```ts +//simple mode +//input Base text +//Good morning everyone. +// +//How are you all? +// +//I hope you're well. +import pdfToText from "react-pdftotext-advanced"; function extractText(event) { const file = event.target.files[0]; - pdfToText(file) + selectModeToExtract(file, 'simple') .then((text) => console.log(text)) .catch((error) => console.error("Failed to extract text from pdf")); } +//output Base text +// Good morning everyone.How are you all?I hope you're well. ``` -**Remote PDF File Input** - -For Pdf files stored at remote locations - -```js -import pdfToText from 'react-pdftotext' - -const pdf_url = "REMOTE_PDF_URL" +```ts +//Advanced mode +//input text +//Good morning everyone. +// +//How are you all? +// +//I hope you're well. +import pdfToText from "react-pdftotext-advanced"; -function extractText() { - const file = await fetch(pdf_url) - .then(res => res.blob()) - .catch(error => console.error(error)) - - pdfToText(file) - .then(text => console.log(text)) - .catch(error => console.error("Failed to extract text from pdf")) +function extractText(event) { + const file = event.target.files[0]; + selectModeToExtract(file, 'simple') + .then((text) => console.log(text)) + .catch((error) => console.error("Failed to extract text from pdf")); } +//output text +//Good morning everyone. +// +//How are you all? +// +//I hope you're well. ``` ## Contributing diff --git a/index.ts b/index.ts index c564583..210c70d 100644 --- a/index.ts +++ b/index.ts @@ -154,7 +154,7 @@ const pdfToTextLikePDF = async (file: File | Blob | MediaSource, lineSpacing: nu return extractedText; }; -const selectModeToExtract = async (file: File | Blob | MediaSource, mode: 'simple' | 'advanced', lineSpacing): Promise => { +const selectModeToExtract = async (file: File | Blob | MediaSource, mode: 'simple' | 'advanced', lineSpacing: number = 1): Promise => { if (mode === 'simple') { return pdfToText(file); } else { diff --git a/package.json b/package.json index 31eb6b4..7b94bf7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-pdftotext", + "name": "react-pdftotext-advanced", "version": "1.3.4", "description": "A simple light weight react package to extract plain text from a pdf file.", "main": "dist/index.js", @@ -12,7 +12,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/Utkarsh212/react-pdftotext.git" + "url": "https://github.com/JavierBagatoli/react-pdftotext-advanced.git" }, "keywords": [ "react-pdf", @@ -22,9 +22,10 @@ "react", "pdf2text", "pdfjs", - "pdf-to-text" + "pdf-to-text", + "typescript" ], - "author": "Utkarsh Pancholi", + "author": "Javier Bagatoli", "license": "MIT", "dependencies": { "pdfjs-dist": "^4.6.82", From 8c23a011e31de502b8a32dfdbf106b4b7c292ab1 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Fri, 21 Nov 2025 18:17:35 -0300 Subject: [PATCH 04/15] fix: url --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7b94bf7..6376f60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-pdftotext-advanced", - "version": "1.3.4", + "version": "1.3.5", "description": "A simple light weight react package to extract plain text from a pdf file.", "main": "dist/index.js", "module": "dist/index.js", @@ -12,7 +12,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/JavierBagatoli/react-pdftotext-advanced.git" + "url": "https://github.com/JavierBagatoli/react-pdftotext.git" }, "keywords": [ "react-pdf", From 3e52bb125feea76e71ac357dedaa41273659457c Mon Sep 17 00:00:00 2001 From: Javier Bagatoli <73254517+JavierBagatoli@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:14:08 -0300 Subject: [PATCH 05/15] update for vite --- package.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6376f60..3567647 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,16 @@ { "name": "react-pdftotext-advanced", - "version": "1.3.5", + "version": "1.3.6", "description": "A simple light weight react package to extract plain text from a pdf file.", - "main": "dist/index.js", - "module": "dist/index.js", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" + } + } "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "tsc", @@ -35,3 +41,5 @@ "typescript": "^5.4.5" } } + + From 6881ba52e98f70de8a6024fd8d866367a3165267 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 11:34:23 -0300 Subject: [PATCH 06/15] update readme --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3567647..b161836 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "import": "./dist/index.mjs", "require": "./dist/index.cjs" } - } + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "tsc", From 5ccd0aa074371c8a6c9a894a61b83678bca87640 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 11:51:19 -0300 Subject: [PATCH 07/15] update data --- README.md | 8 ++++---- package-lock.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 87d0e20..60047bc 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Import the pdf2text function from package ```ts //simple mode -//input Base text +//input text //Good morning everyone. // //How are you all? @@ -40,7 +40,7 @@ function extractText(event) { .then((text) => console.log(text)) .catch((error) => console.error("Failed to extract text from pdf")); } -//output Base text +//output // Good morning everyone.How are you all?I hope you're well. ``` @@ -56,11 +56,11 @@ import pdfToText from "react-pdftotext-advanced"; function extractText(event) { const file = event.target.files[0]; - selectModeToExtract(file, 'simple') + selectModeToExtract(file, 'advanced') .then((text) => console.log(text)) .catch((error) => console.error("Failed to extract text from pdf")); } -//output text +//output //Good morning everyone. // //How are you all? diff --git a/package-lock.json b/package-lock.json index 40b68ea..90bb525 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-pdftotext", - "version": "1.3.4", + "version": "1.3.6", "lockfileVersion": 3, "requires": true, "packages": { From 8e1f22ab6a7e4254741671139d8f15d1bb37e23a Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 15:44:34 -0300 Subject: [PATCH 08/15] . --- pnpm-lock.yaml | 579 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 579 insertions(+) create mode 100644 pnpm-lock.yaml diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..d1e3a9e --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,579 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + pdfjs-dist: + specifier: ^4.6.82 + version: 4.10.38 + react-pdf: + specifier: ^9.1.1 + version: 9.2.1(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + devDependencies: + typescript: + specifier: ^5.4.5 + version: 5.9.3 + +packages: + + '@napi-rs/canvas-android-arm64@0.1.100': + resolution: {integrity: sha512-hjhCKhntPv9+t4ckHymdx0phYNcVW+GKQR6Lzw2zE+pOVjOplSmtx9nNNknTjbEDLcuLZqA1y8ufKg1XfgftzQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [android] + + '@napi-rs/canvas-darwin-arm64@0.1.100': + resolution: {integrity: sha512-2PcswRaC7Ly645DGt88///zuFDhJxJYdKAs1uU3mfk1atYkXufgcgLfBpk6Tm12nCQBaNt1wpybuPZ4qOhTo8A==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + + '@napi-rs/canvas-darwin-x64@0.1.100': + resolution: {integrity: sha512-ePNZtj7pNIva/siZMg+HmbeozkIjqUIYdoymH8HaA3qK7LfzFN4WMBM8G6HQ9ZC+H3+Dnn5pqtiXpgLykaPOhw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + + '@napi-rs/canvas-linux-arm-gnueabihf@0.1.100': + resolution: {integrity: sha512-d5cDB48oWFGU8/XPhUOFAlySgb/VAu7D+s8fi55K1Pcfg8aPplHWqMgibhVLU8ky7Pyg/fuiVLz4Nf3JrSTuUA==} + engines: {node: '>= 10'} + cpu: [arm] + os: [linux] + + '@napi-rs/canvas-linux-arm64-gnu@0.1.100': + resolution: {integrity: sha512-rDxgxRu69RvDlX/bh9o22DxLsGr8EqsNgotL9+RwQE1S0b0cqeatqsw6aW45mukm0B42DIAaAacKaYQ8cqS1nw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@napi-rs/canvas-linux-arm64-musl@0.1.100': + resolution: {integrity: sha512-K3mDW66N+xT2/V439u1alFANiBUjdEx2gLiNYnCmUsva5jZMxWTjafBYwTzYK+EMFMHrUoabuU+T1BIP5CgbYQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@napi-rs/canvas-linux-riscv64-gnu@0.1.100': + resolution: {integrity: sha512-mooqUBTIsccZpnoQC4NgrC1v6C1vof39etLNMnBwCY+p0gajWJvAHLGQ6g/gGyS5YrpDW+GefSN4+Cvcr08UWw==} + engines: {node: '>= 10'} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@napi-rs/canvas-linux-x64-gnu@0.1.100': + resolution: {integrity: sha512-1eCvkDCazm7FFhsT7DfGOdSaHgZVK3bt/dSBl5EWHOWmnz+I7j8tPseJqqD81NF+MH21jKUK4wQSDjN0mdhnTg==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@napi-rs/canvas-linux-x64-musl@0.1.100': + resolution: {integrity: sha512-20arT6lnI19S68qNlii73TSEDbECNgzMz2EpldC1V3mZFuRkeujXkcebRk0LRJe9SEUAooYiLokfMViY8IX7yA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@napi-rs/canvas-win32-arm64-msvc@0.1.100': + resolution: {integrity: sha512-DZFFT1wIAg37LJw37yhMRFfjATd3vTQzjZ1Yki8u2vhO6Hi5VE6BVaGQ1aaDu7xb4iMErz+9EOwjpS7xcxFeBw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + + '@napi-rs/canvas-win32-x64-msvc@0.1.100': + resolution: {integrity: sha512-MyT1j3mHC2+Lu4pBi9mKyMJhtP6U7k7EldY7sj/uS5gJA65gTXt8MefJQXLJo5d/vZbuWmfxzkEUNc/urV3pHA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + + '@napi-rs/canvas@0.1.100': + resolution: {integrity: sha512-xglYA6q3XO5P3BNJYxVZ1IV7DLVjp1Py6nwag88YntrS+3vKHyYcMqXVS4ZztJmwz2uGvz1FWhI/4LgbR5uQDA==} + engines: {node: '>= 10'} + + base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + + bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + + buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + + canvas@3.2.3: + resolution: {integrity: sha512-PzE5nJZPz72YUAfo8oTp0u3fqqY7IzlTubneAihqDYAUcBk7ryeCmBbdJBEdaH0bptSOe2VT2Zwcb3UaFyaSWw==} + engines: {node: ^18.12.0 || >= 20.9.0} + + chownr@1.1.4: + resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + + clsx@2.1.1: + resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} + engines: {node: '>=6'} + + decompress-response@6.0.0: + resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} + engines: {node: '>=10'} + + deep-extend@0.6.0: + resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} + engines: {node: '>=4.0.0'} + + dequal@2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + end-of-stream@1.4.5: + resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} + + expand-template@2.0.3: + resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} + engines: {node: '>=6'} + + fs-constants@1.0.0: + resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + + github-from-package@0.0.0: + resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} + + ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + + inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + + ini@1.3.8: + resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} + + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + + make-cancellable-promise@1.3.2: + resolution: {integrity: sha512-GCXh3bq/WuMbS+Ky4JBPW1hYTOU+znU+Q5m9Pu+pI8EoUqIHk9+tviOKC6/qhHh8C4/As3tzJ69IF32kdz85ww==} + + make-event-props@1.6.2: + resolution: {integrity: sha512-iDwf7mA03WPiR8QxvcVHmVWEPfMY1RZXerDVNCRYW7dUr2ppH3J58Rwb39/WG39yTZdRSxr3x+2v22tvI0VEvA==} + + merge-refs@1.3.0: + resolution: {integrity: sha512-nqXPXbso+1dcKDpPCXvwZyJILz+vSLqGGOnDrYHQYE+B8n9JTCekVLC65AfCpR4ggVyA/45Y0iR9LDyS2iI+zA==} + peerDependencies: + '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + + mimic-response@3.1.0: + resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} + engines: {node: '>=10'} + + minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + mkdirp-classic@0.5.3: + resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + + napi-build-utils@2.0.0: + resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==} + + node-abi@3.94.0: + resolution: {integrity: sha512-W5ZNO5KRPB5TkYmGVD9F6YqhsglXJzE6etpbmT+f6EQElhiX/UTG551cnsRGvLG3fyZEg9HwaDmNmj5nwJ4z9g==} + engines: {node: '>=10'} + + node-addon-api@7.1.1: + resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + + path2d@0.2.2: + resolution: {integrity: sha512-+vnG6S4dYcYxZd+CZxzXCNKdELYZSKfohrk98yajCo1PtRoDgCTrrwOvK1GT0UoAdVszagDVllQc0U1vaX4NUQ==} + engines: {node: '>=6'} + + pdfjs-dist@4.10.38: + resolution: {integrity: sha512-/Y3fcFrXEAsMjJXeL9J8+ZG9U01LbuWaYypvDW2ycW1jL269L3js3DVBjDJ0Up9Np1uqDXsDrRihHANhZOlwdQ==} + engines: {node: '>=20'} + + pdfjs-dist@4.8.69: + resolution: {integrity: sha512-IHZsA4T7YElCKNNXtiLgqScw4zPd3pG9do8UrznC757gMd7UPeHSL2qwNNMJo4r79fl8oj1Xx+1nh2YkzdMpLQ==} + engines: {node: '>=18'} + + prebuild-install@7.1.3: + resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==} + engines: {node: '>=10'} + deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available. + hasBin: true + + pump@3.0.4: + resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==} + + rc@1.2.8: + resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} + hasBin: true + + react-dom@19.2.8: + resolution: {integrity: sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==} + peerDependencies: + react: ^19.2.8 + + react-pdf@9.2.1: + resolution: {integrity: sha512-AJt0lAIkItWEZRA5d/mO+Om4nPCuTiQ0saA+qItO967DTjmGjnhmF+Bi2tL286mOTfBlF5CyLzJ35KTMaDoH+A==} + peerDependencies: + '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + + react@19.2.8: + resolution: {integrity: sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==} + engines: {node: '>=0.10.0'} + + readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} + engines: {node: '>= 6'} + + safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + + scheduler@0.27.0: + resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==} + + semver@7.8.5: + resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} + engines: {node: '>=10'} + hasBin: true + + simple-concat@1.0.1: + resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} + + simple-get@4.0.1: + resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} + + string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + + strip-json-comments@2.0.1: + resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} + engines: {node: '>=0.10.0'} + + tar-fs@2.1.5: + resolution: {integrity: sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==} + + tar-stream@2.2.0: + resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} + engines: {node: '>=6'} + + tiny-invariant@1.3.3: + resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==} + + tunnel-agent@0.6.0: + resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} + + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} + hasBin: true + + util-deprecate@1.0.2: + resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + + warning@4.0.3: + resolution: {integrity: sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + +snapshots: + + '@napi-rs/canvas-android-arm64@0.1.100': + optional: true + + '@napi-rs/canvas-darwin-arm64@0.1.100': + optional: true + + '@napi-rs/canvas-darwin-x64@0.1.100': + optional: true + + '@napi-rs/canvas-linux-arm-gnueabihf@0.1.100': + optional: true + + '@napi-rs/canvas-linux-arm64-gnu@0.1.100': + optional: true + + '@napi-rs/canvas-linux-arm64-musl@0.1.100': + optional: true + + '@napi-rs/canvas-linux-riscv64-gnu@0.1.100': + optional: true + + '@napi-rs/canvas-linux-x64-gnu@0.1.100': + optional: true + + '@napi-rs/canvas-linux-x64-musl@0.1.100': + optional: true + + '@napi-rs/canvas-win32-arm64-msvc@0.1.100': + optional: true + + '@napi-rs/canvas-win32-x64-msvc@0.1.100': + optional: true + + '@napi-rs/canvas@0.1.100': + optionalDependencies: + '@napi-rs/canvas-android-arm64': 0.1.100 + '@napi-rs/canvas-darwin-arm64': 0.1.100 + '@napi-rs/canvas-darwin-x64': 0.1.100 + '@napi-rs/canvas-linux-arm-gnueabihf': 0.1.100 + '@napi-rs/canvas-linux-arm64-gnu': 0.1.100 + '@napi-rs/canvas-linux-arm64-musl': 0.1.100 + '@napi-rs/canvas-linux-riscv64-gnu': 0.1.100 + '@napi-rs/canvas-linux-x64-gnu': 0.1.100 + '@napi-rs/canvas-linux-x64-musl': 0.1.100 + '@napi-rs/canvas-win32-arm64-msvc': 0.1.100 + '@napi-rs/canvas-win32-x64-msvc': 0.1.100 + optional: true + + base64-js@1.5.1: + optional: true + + bl@4.1.0: + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + optional: true + + buffer@5.7.1: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + optional: true + + canvas@3.2.3: + dependencies: + node-addon-api: 7.1.1 + prebuild-install: 7.1.3 + optional: true + + chownr@1.1.4: + optional: true + + clsx@2.1.1: {} + + decompress-response@6.0.0: + dependencies: + mimic-response: 3.1.0 + optional: true + + deep-extend@0.6.0: + optional: true + + dequal@2.0.3: {} + + detect-libc@2.1.2: + optional: true + + end-of-stream@1.4.5: + dependencies: + once: 1.4.0 + optional: true + + expand-template@2.0.3: + optional: true + + fs-constants@1.0.0: + optional: true + + github-from-package@0.0.0: + optional: true + + ieee754@1.2.1: + optional: true + + inherits@2.0.4: + optional: true + + ini@1.3.8: + optional: true + + js-tokens@4.0.0: {} + + loose-envify@1.4.0: + dependencies: + js-tokens: 4.0.0 + + make-cancellable-promise@1.3.2: {} + + make-event-props@1.6.2: {} + + merge-refs@1.3.0: {} + + mimic-response@3.1.0: + optional: true + + minimist@1.2.8: + optional: true + + mkdirp-classic@0.5.3: + optional: true + + napi-build-utils@2.0.0: + optional: true + + node-abi@3.94.0: + dependencies: + semver: 7.8.5 + optional: true + + node-addon-api@7.1.1: + optional: true + + once@1.4.0: + dependencies: + wrappy: 1.0.2 + optional: true + + path2d@0.2.2: + optional: true + + pdfjs-dist@4.10.38: + optionalDependencies: + '@napi-rs/canvas': 0.1.100 + + pdfjs-dist@4.8.69: + optionalDependencies: + canvas: 3.2.3 + path2d: 0.2.2 + + prebuild-install@7.1.3: + dependencies: + detect-libc: 2.1.2 + expand-template: 2.0.3 + github-from-package: 0.0.0 + minimist: 1.2.8 + mkdirp-classic: 0.5.3 + napi-build-utils: 2.0.0 + node-abi: 3.94.0 + pump: 3.0.4 + rc: 1.2.8 + simple-get: 4.0.1 + tar-fs: 2.1.5 + tunnel-agent: 0.6.0 + optional: true + + pump@3.0.4: + dependencies: + end-of-stream: 1.4.5 + once: 1.4.0 + optional: true + + rc@1.2.8: + dependencies: + deep-extend: 0.6.0 + ini: 1.3.8 + minimist: 1.2.8 + strip-json-comments: 2.0.1 + optional: true + + react-dom@19.2.8(react@19.2.8): + dependencies: + react: 19.2.8 + scheduler: 0.27.0 + + react-pdf@9.2.1(react-dom@19.2.8(react@19.2.8))(react@19.2.8): + dependencies: + clsx: 2.1.1 + dequal: 2.0.3 + make-cancellable-promise: 1.3.2 + make-event-props: 1.6.2 + merge-refs: 1.3.0 + pdfjs-dist: 4.8.69 + react: 19.2.8 + react-dom: 19.2.8(react@19.2.8) + tiny-invariant: 1.3.3 + warning: 4.0.3 + + react@19.2.8: {} + + readable-stream@3.6.2: + dependencies: + inherits: 2.0.4 + string_decoder: 1.3.0 + util-deprecate: 1.0.2 + optional: true + + safe-buffer@5.2.1: + optional: true + + scheduler@0.27.0: {} + + semver@7.8.5: + optional: true + + simple-concat@1.0.1: + optional: true + + simple-get@4.0.1: + dependencies: + decompress-response: 6.0.0 + once: 1.4.0 + simple-concat: 1.0.1 + optional: true + + string_decoder@1.3.0: + dependencies: + safe-buffer: 5.2.1 + optional: true + + strip-json-comments@2.0.1: + optional: true + + tar-fs@2.1.5: + dependencies: + chownr: 1.1.4 + mkdirp-classic: 0.5.3 + pump: 3.0.4 + tar-stream: 2.2.0 + optional: true + + tar-stream@2.2.0: + dependencies: + bl: 4.1.0 + end-of-stream: 1.4.5 + fs-constants: 1.0.0 + inherits: 2.0.4 + readable-stream: 3.6.2 + optional: true + + tiny-invariant@1.3.3: {} + + tunnel-agent@0.6.0: + dependencies: + safe-buffer: 5.2.1 + optional: true + + typescript@5.9.3: {} + + util-deprecate@1.0.2: + optional: true + + warning@4.0.3: + dependencies: + loose-envify: 1.4.0 + + wrappy@1.0.2: + optional: true From ef1d7dca38e0a81078e0e72f6ac1f489588a2bb3 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 15:46:00 -0300 Subject: [PATCH 09/15] update version --- .npmignore | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.npmignore b/.npmignore index 5510319..b7b695d 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,3 @@ -index.ts package-lock.json .gitignore tsconfig.json diff --git a/package.json b/package.json index b161836..ec6da3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-pdftotext-advanced", - "version": "1.3.6", + "version": "1.3.7", "description": "A simple light weight react package to extract plain text from a pdf file.", "main": "./dist/index.cjs", "module": "./dist/index.mjs", From e5b5de81fa9a5335298cab73446adc5f62aa402b Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 15:59:48 -0300 Subject: [PATCH 10/15] update: version --- .npmignore | 1 + package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.npmignore b/.npmignore index b7b695d..5510319 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ +index.ts package-lock.json .gitignore tsconfig.json diff --git a/package-lock.json b/package-lock.json index 90bb525..f1f9ea3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-pdftotext", - "version": "1.3.6", + "version": "1.3.8", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index ec6da3c..f0e2489 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-pdftotext-advanced", - "version": "1.3.7", + "version": "1.3.8", "description": "A simple light weight react package to extract plain text from a pdf file.", "main": "./dist/index.cjs", "module": "./dist/index.mjs", From 3e7762157a43df723436c0befdf46fcff24f2f0a Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 16:20:29 -0300 Subject: [PATCH 11/15] update --- package.json | 4 ++-- tsconfig.json | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f0e2489..a57962d 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "react-pdftotext-advanced", "version": "1.3.8", "description": "A simple light weight react package to extract plain text from a pdf file.", - "main": "./dist/index.cjs", - "module": "./dist/index.mjs", + "main": "./dist/index.js", + "module": "./dist/index.js", "types": "dist/index.d.ts", "exports": { ".": { diff --git a/tsconfig.json b/tsconfig.json index 6777d45..7e9c84c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,11 +6,12 @@ "outDir": "dist", "esModuleInterop": true, "isolatedModules": true, - "module": "NodeNext", "skipLibCheck": true, + "module": "ESNext", // GenerarĂ¡ "export default" en vez de "exports.default" + "moduleResolution": "Node", + "target": "ES2020" // This matches the TypeScript target used by react-pdf: // https://github.com/wojtekmaj/react-pdf/blob/main/packages/react-pdf/tsconfig.json - "target": "ES2015" } } \ No newline at end of file From 7fa9f09c1b38f350b83077f8896a7d1db19289d6 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 16:31:12 -0300 Subject: [PATCH 12/15] update: export --- package.json | 6 +++--- tsconfig.json | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index a57962d..1385146 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "version": "1.3.8", "description": "A simple light weight react package to extract plain text from a pdf file.", "main": "./dist/index.js", - "module": "./dist/index.js", "types": "dist/index.d.ts", + "type": "module", "exports": { ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" + "types": "./dist/index.d.ts", + "import": "./dist/index.js" } }, "scripts": { diff --git a/tsconfig.json b/tsconfig.json index 7e9c84c..ff3efd3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,16 +2,13 @@ "files": ["index.ts"], "compilerOptions": { "allowJs": true, - "declaration": true, "outDir": "dist", - "esModuleInterop": true, "isolatedModules": true, "skipLibCheck": true, - "module": "ESNext", // GenerarĂ¡ "export default" en vez de "exports.default" - "moduleResolution": "Node", - "target": "ES2020" - - // This matches the TypeScript target used by react-pdf: - // https://github.com/wojtekmaj/react-pdf/blob/main/packages/react-pdf/tsconfig.json - } + "target": "ES2020", + "module": "ESNext", + "declaration": true, + "esModuleInterop": true + }, + "include": ["src/**/*", "index.ts", "aux-funcitons.ts"] } \ No newline at end of file From 5e6705f654d5218ffdc0d4bab20aa59412c03c9b Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 16:31:33 -0300 Subject: [PATCH 13/15] update: version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f1f9ea3..a7b71b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-pdftotext", - "version": "1.3.8", + "version": "1.3.9", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 1385146..658df14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-pdftotext-advanced", - "version": "1.3.8", + "version": "1.3.9", "description": "A simple light weight react package to extract plain text from a pdf file.", "main": "./dist/index.js", "types": "dist/index.d.ts", From 9ef7b009b87539f841c339322c5688758c8e2462 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Thu, 23 Jul 2026 16:33:17 -0300 Subject: [PATCH 14/15] update: tsconfig --- tsconfig.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index ff3efd3..c658171 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,11 +4,12 @@ "allowJs": true, "outDir": "dist", "isolatedModules": true, - "skipLibCheck": true, "target": "ES2020", "module": "ESNext", "declaration": true, - "esModuleInterop": true + "esModuleInterop": true, + "moduleResolution": "Node", + "skipLibCheck": true, }, "include": ["src/**/*", "index.ts", "aux-funcitons.ts"] } \ No newline at end of file From fd94ea5845532864b23a4e9435c97f39e28e4831 Mon Sep 17 00:00:00 2001 From: Javier Bagatoli Date: Fri, 24 Jul 2026 00:36:25 -0300 Subject: [PATCH 15/15] update: readme --- README.md | 197 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 149 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 60047bc..4d1f54e 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,174 @@ # react-pdftotext-advanced -This is a library based on "react-pdftotext" that aims to format text for readability without requiring extensive coding. +A browser-based PDF text extraction library that preserves the original reading experience by reconstructing paragraphs and page breaks. -This version separates paragraph and page endings, taking into account expected spacing and page breaks. +Unlike the original `react-pdftotext`, which returns a continuous stream of text, **react-pdftotext-advanced** analyzes the extracted content to preserve paragraph separation and page spacing, producing text that is much closer to the original document. -## Installing +## Why? -Using npm: +Most browser PDF extraction libraries prioritize extracting text, not readability. -```js -npm install react-pdftotext-advanced +For example, a document like this: + +```text +Good morning everyone. + +How are you all? + +I hope you're well. ``` -## Example +may become: -**Local File Input** +```text +Good morning everyone.How are you all?I hope you're well. +``` -Now add a input tag with type="file" to take file input. +With **react-pdftotext-advanced**, the output becomes: -```html - +```text +Good morning everyone. + +How are you all? + +I hope you're well. ``` -Import the pdf2text function from package +This makes the extracted text much easier to: -```ts -//simple mode -//input text -//Good morning everyone. -// -//How are you all? -// -//I hope you're well. +- Read +- Display +- Process with AI models (LLMs) +- Index +- Summarize +- Search + +--- + +# Features + +- Preserves paragraph separation. +- Detects page endings. +- Produces human-readable output. +- Runs entirely in the browser. +- No backend required. +- Promise-based API. +- Easy integration with React applications. + +--- + +# Installation + +```bash +npm install react-pdftotext-advanced +``` + +--- + +# Basic Usage + +```tsx import pdfToText from "react-pdftotext-advanced"; function extractText(event) { - const file = event.target.files[0]; - selectModeToExtract(file, 'simple') - .then((text) => console.log(text)) - .catch((error) => console.error("Failed to extract text from pdf")); + const file = event.target.files[0]; + + pdfToText(file, "advanced") + .then((text) => console.log(text)) + .catch((error) => console.error(error)); } -//output -// Good morning everyone.How are you all?I hope you're well. ``` +```html + +``` + +--- + +# Extraction Modes + +## Simple + +Returns the text using the original extraction behavior. + ```ts -//Advanced mode -//input text -//Good morning everyone. -// -//How are you all? -// -//I hope you're well. -import pdfToText from "react-pdftotext-advanced"; +pdfToText(file, "simple"); +``` -function extractText(event) { - const file = event.target.files[0]; - selectModeToExtract(file, 'advanced') - .then((text) => console.log(text)) - .catch((error) => console.error("Failed to extract text from pdf")); -} -//output -//Good morning everyone. -// -//How are you all? -// -//I hope you're well. +Output + +```text +Good morning everyone.How are you all?I hope you're well. +``` + +--- + +## Advanced + +Reconstructs paragraph breaks and page spacing for improved readability. + +```ts +pdfToText(file, "advanced"); +``` + +Output + +```text +Good morning everyone. + +How are you all? + +I hope you're well. ``` -## Contributing +--- + +# Use Cases + +This library is particularly useful for: + +- Reading letters and documents +- AI preprocessing (LLMs) +- Retrieval-Augmented Generation (RAG) +- Search indexing +- Document summarization +- PDF viewers +- Educational platforms + +--- + +# How It Works + +After extracting the raw text from the PDF, the library analyzes spacing and page transitions to reconstruct the document's logical reading order. + +Instead of returning a continuous stream of text, it attempts to preserve the visual structure that a reader expects. + +--- + +# Browser Support + +Supports modern browsers that are compatible with PDF.js. + +--- + +# Credits + +This project is based on the excellent work of **react-pdftotext** and extends its functionality by improving the readability of the extracted text. + +--- + +# Contributing + +Contributions, bug reports and feature requests are always welcome. + +If you have ideas for improving text reconstruction or supporting additional document layouts, feel free to open an issue or submit a pull request. + +--- + +# License -This project welcomes contributions and suggestions. +MIT \ No newline at end of file