{"id":28818408,"url":"https://github.com/josh-janse/pdf-to-markdown-extractor","last_synced_at":"2026-05-07T01:38:04.849Z","repository":{"id":299601260,"uuid":"1003551386","full_name":"josh-janse/pdf-to-markdown-extractor","owner":"josh-janse","description":"Convert PDF documents to clean markdown using Google's Gemini API.","archived":false,"fork":false,"pushed_at":"2025-06-17T11:08:25.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-17T11:29:04.062Z","etag":null,"topics":["ai","document-processing","gemini-api","markdown","nodejs","pdf","text-extraction","text-extraction-from-pdf"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/josh-janse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T10:12:52.000Z","updated_at":"2025-06-17T11:08:29.000Z","dependencies_parsed_at":"2025-06-17T11:31:23.756Z","dependency_job_id":"ab5db07b-134b-4b8e-8331-b3af11e30513","html_url":"https://github.com/josh-janse/pdf-to-markdown-extractor","commit_stats":null,"previous_names":["josh-janse/pdf-to-markdown-extractor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/josh-janse/pdf-to-markdown-extractor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-janse%2Fpdf-to-markdown-extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-janse%2Fpdf-to-markdown-extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-janse%2Fpdf-to-markdown-extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-janse%2Fpdf-to-markdown-extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josh-janse","download_url":"https://codeload.github.com/josh-janse/pdf-to-markdown-extractor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-janse%2Fpdf-to-markdown-extractor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32719573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T00:29:05.620Z","status":"ssl_error","status_checked_at":"2026-05-07T00:28:57.074Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","document-processing","gemini-api","markdown","nodejs","pdf","text-extraction","text-extraction-from-pdf"],"created_at":"2025-06-18T19:05:14.085Z","updated_at":"2026-05-07T01:38:04.842Z","avatar_url":"https://github.com/josh-janse.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PDF to Markdown Extractor\n\nA simple, powerful Node.js tool that converts PDF documents to clean, structured markdown using Google's Gemini 2.0 Flash API. Perfect for digitizing documents, creating documentation, or preparing content for further processing.\n\n## ✨ Features\n\n- 🚀 **Simple \u0026 Fast** - Convert PDFs to markdown in seconds\n- 📁 **Batch Processing** - Handle single files or entire folders\n- 🧠 **AI-Powered** - Uses Gemini 2.0 Flash for intelligent text extraction\n- 📊 **Structure Preservation** - Maintains headers, tables, and formatting\n- 💰 **Cost-Effective** - File uploads are free, minimal processing costs\n- 🔒 **Secure** - Files auto-delete after 48 hours\n- 📱 **Cross-Platform** - Works on macOS, Windows, and Linux\n\n## 🛠️ Quick Start\n\n### Prerequisites\n- Node.js 18 or higher\n- Google API key for Gemini\n\n### 1. Clone and Install\n\n```bash\n# Clone the repository\ngit clone https://github.com/josh-janse/pdf-to-markdown-extractor.git\ncd pdf-to-markdown-extractor\n\n# Install dependencies\nnpm install\n```\n\n### 2. Get Your Gemini API Key\n1. Visit [Google AI Studio](https://aistudio.google.com/)\n2. Sign in with your Google account\n3. Click \"Get API Key\" in the sidebar\n4. Create a new API key and copy it\n\n### 3. Configure Environment\n\n```bash\n# Copy the template and add your API key\ncp .env.template .env\n\n# Edit .env and add your API key\necho \"GOOGLE_API_KEY=your_actual_api_key_here\" \u003e .env\n```\n\n### 4. Test Installation\n\n```bash\n# Run the diagnostic to verify everything works\nnode diagnose.js\n```\n\nYou should see:\n```\n✅ All checks passed! The tool should work.\n```\n\n## 🚀 Usage\n\n### Single PDF File\n```bash\nnode extract.js document.pdf\n```\n\n### Multiple Files\n```bash\nnode extract.js file1.pdf file2.pdf file3.pdf\n```\n\n### Entire Folder\n```bash\n# Process all PDFs in a folder\nnode extract.js ./documents/\n\n# Process all PDFs in current directory\nnode extract.js ./\n```\n\n### Examples\n```bash\n# Convert a research paper\nnode extract.js research-paper.pdf\n\n# Process all invoices\nnode extract.js ./invoices/\n\n# Convert presentation slides\nnode extract.js presentation.pdf\n```\n\n## 🚀 Usage\n\n### Single PDF File\n```bash\nnode extract.js document.pdf\n```\n\n### Multiple Files\n```bash\nnode extract.js file1.pdf file2.pdf file3.pdf\n```\n\n### Entire Folder\n```bash\n# Process all PDFs in a folder\nnode extract.js ./documents/\n\n# Process all PDFs in current directory\nnode extract.js ./\n```\n\n### Examples\n```bash\n# Convert a research paper\nnode extract.js research-paper.pdf\n\n# Process all invoices\nnode extract.js ./invoices/\n\n# Convert presentation slides\nnode extract.js presentation.pdf\n```\n\n## 📂 Output\n\n- Markdown files are saved to `./output/` directory\n- Each PDF generates a corresponding `.md` file\n- Original document structure is preserved\n- Tables are converted to markdown format\n- Headers and formatting are maintained\n\n## 💰 Cost\n\n**Free Tier:** Free of charge for both input and output (with rate limits)\n\n**Paid Tier (per 1M tokens):**\n- Input: $0.10 (text/image/video)\n- Output: $0.40\n\n**Real-world costs for typical PDFs:**\n- Small document (5 pages): ~$0.002-0.005\n- Medium document (20 pages): ~$0.01-0.02  \n- Large document (100 pages): ~$0.05-0.10\n\n**Important:** Most users can use the free tier for testing and light usage. You only pay when you exceed the free tier rate limits.\n\n## 🔧 Configuration\n\n### Environment Variables\nCreate a `.env` file in your project root:\n\n```bash\nGOOGLE_API_KEY=your_gemini_api_key_here\n```\n\n### File Limits\n- Maximum file size: 2GB per PDF\n- Storage limit: 20GB total per project\n- Files automatically delete after 48 hours\n- Rate limiting: 2-second delay between files in batch mode\n\n## 📊 What It Extracts\n\n✅ **Text Content** - All readable text from PDFs  \n✅ **Headers \u0026 Structure** - Document hierarchy preserved  \n✅ **Tables** - Converted to markdown table format  \n✅ **Lists** - Bullet points and numbered lists  \n✅ **Formatting** - Bold and italic text where possible  \n✅ **Multi-column Layout** - Intelligent text flow handling  \n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n**\"GOOGLE_API_KEY not found\"**\n- Ensure `.env` file exists in project root\n- Check there are no spaces around the `=` sign\n- Verify your API key is correct\n\n**\"File not found\"**\n- Use full or relative paths to PDF files\n- Ensure files have `.pdf` extension\n- Check file permissions\n\n**\"API Error\"**\n- Verify your API key is active\n- Check internet connectivity\n- Ensure you haven't exceeded rate limits\n\n**\"No PDF files found\"**\n- Verify the folder contains PDF files\n- Check folder path is correct\n- Ensure PDF files have proper extensions\n\n### Getting Help\n\nRun the diagnostic script to troubleshoot issues:\n```bash\nnode diagnose.js\n```\n\nThis will check:\n- Node.js version compatibility\n- API key configuration\n- Network connectivity\n- Available API methods\n\nCommon issues and solutions:\n\n**\"GOOGLE_API_KEY not found\"**\n- Ensure `.env` file exists in project root\n- Check there are no spaces around the `=` sign\n- Verify your API key is correct\n\n**\"File not found\"**\n- Use full or relative paths to PDF files\n- Ensure files have `.pdf` extension\n- Check file permissions\n\n**\"API Error\"**\n- Verify your API key is active at [Google AI Studio](https://aistudio.google.com/)\n- Check internet connectivity\n- Ensure you haven't exceeded rate limits\n\n**\"No PDF files found\"**\n- Verify the folder contains PDF files\n- Check folder path is correct\n- Ensure PDF files have proper extensions\n\n## 🛠️ Development\n\n### Project Structure\n```\npdf-to-markdown-extractor/\n├── README.md          # This file\n├── extract.js         # Main extraction script\n├── diagnose.js        # Diagnostic utility\n├── package.json       # Dependencies and scripts\n├── package-lock.json  # Locked dependency versions\n├── .env.template      # Environment template\n├── .env              # Your API key (not in repo)\n├── .gitignore        # Git ignore rules\n└── output/           # Generated markdown files\n```\n\n### Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Commit your changes (`git commit -m 'Add amazing feature'`)\n5. Push to the branch (`git push origin feature/amazing-feature`)\n6. Open a Pull Request\n\n### Adding Features\n\nThe codebase is intentionally simple. Some ideas for enhancements:\n- Support for other document formats (DOCX, PPTX)\n- Custom output formatting options\n- Integration with other AI models\n- Web interface\n- Docker containerization\n\n## 📝 Example Output\n\n**Input:** `quarterly-report.pdf`  \n**Output:** `output/quarterly-report.md`\n\n```markdown\n# Q3 2024 Financial Report\n\n## Executive Summary\n\nOur company achieved strong growth in Q3 2024...\n\n| Metric | Q3 2024 | Q2 2024 | Change |\n|--------|---------|---------|--------|\n| Revenue | $2.1M | $1.8M | +16.7% |\n| Profit | $450K | $380K | +18.4% |\n\n## Key Achievements\n\n- Launched new product line\n- Expanded to 3 new markets\n- Improved customer satisfaction by 25%\n```\n\n## 🔒 Security \u0026 Privacy\n\n- API keys are stored locally in `.env` files\n- Files are uploaded securely to Google's servers\n- All uploaded files auto-delete after 48 hours\n- No data is stored permanently\n- API calls are encrypted in transit\n\n## 🤝 Contributing\n\nThis is a simple utility script. Feel free to:\n- Fork and modify for your needs\n- Add new features or improvements\n- Report issues or suggestions\n- Share your use cases\n\n### Development Setup\n\n```bash\n# Fork and clone your fork\ngit clone https://github.com/YOUR_USERNAME/pdf-to-markdown-extractor.git\ncd pdf-to-markdown-extractor\n\n# Install dependencies\nnpm install\n\n# Copy environment template\ncp .env.template .env\n# Add your API key to .env\n\n# Test your setup\nnode diagnose.js\n```\n\n## 📄 License\n\nMIT License - feel free to use for personal or commercial projects.\n\n## 🚀 Advanced Usage\n\n### Custom Output Directory\nModify the script to change the output directory:\n```javascript\n// Change this line in extract.js:\nawait fs.mkdir('./my-output', { recursive: true });\n```\n\n### Custom Prompts\nModify the extraction prompt for specific formatting:\n```javascript\n// Find this line in extract.js and customize:\n'Extract all text from this PDF and format it as clean markdown...'\n```\n\n### Integration\nUse as a module in larger projects:\n```javascript\nimport { extractPDF } from './extract.js';\nconst result = await extractPDF('document.pdf');\n```\n\n### Automation\n\nCreate npm scripts in `package.json`:\n```json\n{\n  \"scripts\": {\n    \"extract\": \"node extract.js\",\n    \"diagnose\": \"node diagnose.js\",\n    \"extract-docs\": \"node extract.js ./documents/\"\n  }\n}\n```\n\nThen use:\n```bash\nnpm run extract document.pdf\nnpm run diagnose\nnpm run extract-docs\n```\n\n---\n\n**Happy extracting! 📚➡️📝**\n\n⭐ **Star this repo** if you find it useful!  \n🐛 **Report issues** on the [GitHub Issues page](https://github.com/josh-janse/pdf-to-markdown-extractor/issues)  \n💡 **Suggest features** or contribute improvements\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosh-janse%2Fpdf-to-markdown-extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosh-janse%2Fpdf-to-markdown-extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosh-janse%2Fpdf-to-markdown-extractor/lists"}