{"id":48887545,"url":"https://github.com/tsoodo/gitbook2pdf","last_synced_at":"2026-04-16T05:35:20.113Z","repository":{"id":293387276,"uuid":"983874189","full_name":"tsoodo/gitbook2pdf","owner":"tsoodo","description":"A fast and reliable TypeScript library for converting GitBook documentation into PDF format using just a GitBook URL.","archived":false,"fork":false,"pushed_at":"2025-06-17T02:06:07.000Z","size":690,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T03:20:00.850Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/tsoodo.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-05-15T03:48:43.000Z","updated_at":"2025-06-17T02:06:10.000Z","dependencies_parsed_at":"2025-05-15T05:29:28.302Z","dependency_job_id":null,"html_url":"https://github.com/tsoodo/gitbook2pdf","commit_stats":null,"previous_names":["ianeblack/gitbook2pdf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tsoodo/gitbook2pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsoodo%2Fgitbook2pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsoodo%2Fgitbook2pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsoodo%2Fgitbook2pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsoodo%2Fgitbook2pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsoodo","download_url":"https://codeload.github.com/tsoodo/gitbook2pdf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsoodo%2Fgitbook2pdf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31872671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-04-16T05:35:20.030Z","updated_at":"2026-04-16T05:35:20.106Z","avatar_url":"https://github.com/tsoodo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![wakatime](https://wakatime.com/badge/user/018bb5b7-2775-467e-80b5-4a754a579895/project/23b16f72-f0f5-46d5-81fd-6460898e1c33.svg)](https://wakatime.com/badge/user/018bb5b7-2775-467e-80b5-4a754a579895/project/23b16f72-f0f5-46d5-81fd-6460898e1c33)\n\n![gitbook2pdf gradient image](./img.png)\n\n[![Bun](https://img.shields.io/badge/Bun-000?logo=bun\u0026logoColor=fff)](https://bun.sh)\n[![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript\u0026logoColor=fff)](https://www.typescriptlang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\n# 📚➡️📄 gitbook2pdf \n\n\u003e High-performance GitBook to PDF converter with parallel processing, resume capability, merge option, and smart filtering! ⚡\n## ⚡ Quick Start\n\n### Install 📥\n```bash\ngit clone https://github.com/tsoodo/gitbook2pdf ./gb2pdf\ncd gb2pdf \nbun install\n```\n\n### Convert GitBook to PDF 🎯\n```bash\n# Interactive mode\nbun pdf\n\n# Direct conversion\nbun pdf --url https://careers.gitbook.com/\n# Generate single merged PDF\nbun pdf --url https://careers.gitbook.com/ --merge\n```\n\n## 🚀 Features\n\n- **⚡ Lightning Fast**: Parallel processing with configurable concurrency\n- **🔄 Resume Support**: Continue interrupted conversions\n- **📄 Merge Option**: Combine all pages into single PDF\n- **🎯 Smart Filtering**: Include/exclude patterns with regex support\n- **⌨️ Interactive Controls**: Control conversion while running (q/r/o)\n- **📊 Progress Tracking**: Real-time progress with detailed statistics\n- **🎨 Quality Options**: Multiple quality presets (low/medium/high)\n- **📐 Format Support**: A4, A3, and Letter formats\n- **🗂️ Auto Organization**: Categorizes PDFs into folders\n- **🔧 Robust Error Handling**: Retry logic with exponential backoff\n- **📱 Element Hiding**: Removes navigation for clean PDFs\n- **📈 Performance Monitoring**: Tracks conversion speed and file sizes\n\n## 🛠️ Requirements\n\n- [Bun](https://bun.sh) (latest version recommended)\n\n## 💡 Usage\n\n### Merge Mode Prompt\n\nIf you don't specify the `--merge` flag, the converter will ask you:\n\n```\n📄 PDF Output Options:\n1. Individual PDFs (organized by category)\n2. Single merged PDF (all content in one file)\n\nWould you like to create a single merged PDF? (y/N):\n```\n\n### Basic Usage\n\nWhile the conversion is running, you can use these keyboard shortcuts:\n\n- **`q`** - Quit gracefully (saves progress)\n- **`r`** - Restart conversion from beginning  \n- **`o`** - Open output folder in file manager\n- **`Ctrl+C`** - Force quit\n\n```bash\n# Interactive mode with prompts\nbun pdf\n\n# Direct URL conversion\nbun pdf --url https://careers.gitbook.com/\n# Specify output directory\nbun pdf -u https://careers.gitbook.com/ -o ./my-pdfs\n```\n\n### Advanced Options\n\n```bash\n# High-performance conversion\nbun pdf \\\n  --url https://careers.gitbook.com/ \\\n  --concurrency 8 \\\n  --quality high \\\n  --format A3\n\n# Resume previous conversion\nbun pdf --url https://careers.gitbook.com/ --resume\n\n# Generate merged PDF\nbun pdf --url https://careers.gitbook.com --merge --quality high\n\n# Selective conversion with filters\nbun pdf \\\n  --url https://careers.gitbook.com \\\n  --include \".*/api/.*\" \\\n  --exclude \".*/internal/.*\" \\\n  --exclude \".*/deprecated/.*\"\n\n# Custom configuration\nbun pdf \\\n  --url https://github.com/tsoodo/gitbook2pdf \\\n  --concurrency 6 \\\n  --delay 500 \\\n  --retries 5 \\\n  --timeout 45000 \\\n  --no-hide-elements\n```\n\n## 🔧 CLI Options\n\n| Option | Short | Default | Description |\n|--------|-------|---------|-------------|\n| `--url` | `-u` | - | GitBook URL (required) |\n| `--output` | `-o` | `./pdfs` | Output directory |\n| `--concurrency` | `-c` | `4` | Concurrent PDF processes |\n| `--retries` | `-r` | `3` | Retry attempts for failed pages |\n| `--delay` | `-d` | `1000` | Delay between requests (ms) |\n| `--hide-elements` | - | `true` | Hide navigation elements |\n| `--format` | - | `A4` | PDF format (A4/A3/Letter) |\n| `--quality` | - | `medium` | PDF quality (low/medium/high) |\n| `--resume` | - | `false` | Resume previous conversion |\n| `--include` | - | `[]` | Include URL patterns (regex) |\n| `--exclude` | - | `[]` | Exclude URL patterns (regex) |\n| `--timeout` | - | `30000` | Request timeout (ms) |\n| `--merge` | - | `false` | Merge all pages into single PDF |\n| `--help` | `-h` | - | Show help message |\n\n## 📂 Output Structure\n\n### Individual PDFs\n```\npdfs/\n├── 📁 getting-started/\n│   ├── 001_installation.pdf\n│   └── 002_quick-start.pdf\n├── 📁 api/\n│   ├── 003_authentication.pdf\n│   ├── 004_endpoints.pdf\n│   └── 005_examples.pdf\n├── 📁 guides/\n│   └── 006_advanced-usage.pdf\n└── .progress.json          # Resume data\n```\n\n### Merged PDF\n```\npdfs/\n├── merged-gitbook.pdf      # Single merged PDF\n└── .progress.json          # Resume data\n```\n\n## 🎯 Use Cases\n\n### Documentation Teams\n```bash\n# Convert entire documentation site\nbun pdf --url https://careers.gitbook.com --concurrency 8 --quality high\n```\n\n### API Documentation\n```bash\n# Convert only API docs\nbun pdf --url https://docs.snyk.io/snyk-api --include \".*/snyk-api/.*\" --format A3\n```\n\n### Merged Documentation\n```bash\n# Create single PDF for easy sharing\nbun pdf --url https://docs.zenml.io/ --merge --quality high\n```\n\n### Offline Reading\n```bash\n# Quick conversion for offline reading\nbun pdf --url https://developer.thunderbird.net/ --quality medium\n```\n\n### CI/CD Integration\n```bash\n# Automated PDF generation in CI\nbun pdf --url $DOCS_URL --output ./dist/pdfs --no-hide-elements\n```\n\n## 🚀 Performance\n\n### Benchmarks\n- **Speed**: 3-8x faster than sequential processing\n- **Memory**: Optimized for large documentation sites\n- **Concurrency**: Handles 50+ pages efficiently\n- **Resume**: Zero data loss on interruption\n\n### Optimization Tips\n1. **Increase concurrency** for powerful machines: `--concurrency 10`\n2. **Use low quality** for drafts: `--quality low`\n3. **Filter unnecessary pages** with `--exclude`\n4. **Enable resume** for large sites: `--resume`\n5. **Use merge** for single document: `--merge`\n\n## 🔍 Filtering Examples\n\n### Include specific sections\n```bash\n--include \".*/guides/.*\" --include \".*/api/.*\"\n```\n\n### Exclude admin/internal pages\n```bash\n--exclude \".*/admin/.*\" --exclude \".*/internal/.*\"\n```\n\n### Complex filtering\n```bash\n--include \".*/v2/.*\" --exclude \".*/v2/deprecated/.*\"\n```\n\n## 🛠️ Dependencies\n\n- **puppeteer** - Headless Chrome for PDF generation\n- **xml2js** - XML sitemap parsing\n- **Bun APIs** - File I/O, HTTP, and process management\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n**Timeout Errors**\n```bash\n# Increase timeout for slow pages\nbun pdf --url https://docs.example.com --timeout 60000\n```\n\n**Memory Issues**\n```bash\n# Reduce concurrency for limited memory\nbun pdf --url https://docs.example.com --concurrency 2\n```\n\n**Failed Pages**\n```bash\n# Increase retries for unstable connections\nbun pdf --url https://docs.example.com --retries 5\n```\n\n**Resume Conversion**\n```bash\n# Continue where you left off\nbun pdf --url https://docs.example.com --resume\n```\n\n### Debug Mode\n\nFor troubleshooting, failed pages generate error screenshots:\n```\npdfs/category/001_page_error.png\n```\n\n## 📊 Statistics\n\nAfter conversion, gb2pdf shows detailed statistics:\n- ✅ Successful conversions\n- ❌ Failed attempts  \n- 📁 Total file size\n- ⏱️ Processing time\n- 📊 Average metrics\n\n## 🔐 Privacy \u0026 Security\n\n- No data sent to external services\n- All processing happens locally\n- No storage of GitBook credentials\n- Respects robots.txt and rate limits\n\n## 📝 License\n\nMIT License © 2025 Ian Irizarry\n\n## 🙏 Acknowledgments\n\n- Built with ❤️ using [Bun](https://bun.sh)\n- Powered by [Puppeteer](https://pptr.dev)\n- Inspired by the need for offline documentation\n\n---\n\n\u003cdiv align=\"center\"\u003e\n  \u003cstrong\u003e⭐ Star this repo if you find it useful! ⭐\u003c/strong\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/tsoodo/gitbook2pdf/issues\"\u003eReport Bug\u003c/a\u003e • \n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsoodo%2Fgitbook2pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsoodo%2Fgitbook2pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsoodo%2Fgitbook2pdf/lists"}