|
| 1 | +# 🐧 Feature Request: Add Linux Support for PDF Joining |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project currently provides a simple and efficient PDF joining tool for **macOS only**, leveraging the native macOS PDF utility at `/System/Library/Automator/Combine PDF Pages.action/Contents/MacOS/join`. We're looking for community contributions to extend this functionality to **Linux systems** using stable, native Linux PDF processing tools. |
| 6 | + |
| 7 | +## Current State |
| 8 | + |
| 9 | +The tool currently: |
| 10 | +- ✅ Works seamlessly on macOS using built-in system utilities |
| 11 | +- ✅ Joins multiple PDF files with simple command-line interface |
| 12 | +- ✅ Supports custom output paths and automatic timestamped naming |
| 13 | +- ✅ Validates input files and creates output directories |
| 14 | +- ❌ **Linux support is missing** |
| 15 | + |
| 16 | +## What We Need |
| 17 | + |
| 18 | +We're seeking contributions to add Linux support while maintaining the same design principles: |
| 19 | + |
| 20 | +### 🎯 Goals |
| 21 | +1. **Use native/stable Linux tools** - Just like we use macOS's built-in utility, we want to leverage well-established Linux PDF tools |
| 22 | +2. **Maintain the same CLI interface** - The user experience should be identical across platforms |
| 23 | +3. **Cross-platform detection** - Automatically detect the OS and use the appropriate backend |
| 24 | +4. **No external dependencies** - Avoid requiring users to install additional libraries |
| 25 | + |
| 26 | +### 🛠️ Technical Implementation Ideas |
| 27 | + |
| 28 | +We need platform detection and multiple backend support. Here are some proven Linux PDF joining tools to consider: |
| 29 | + |
| 30 | +#### Option 1: `pdfunite` (from poppler-utils) |
| 31 | +```bash |
| 32 | +# Most Linux distributions include this by default |
| 33 | +pdfunite input1.pdf input2.pdf input3.pdf output.pdf |
| 34 | +``` |
| 35 | + |
| 36 | +#### Option 2: `ghostscript` (gs) |
| 37 | +```bash |
| 38 | +# Very stable, widely available |
| 39 | +gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf |
| 40 | +``` |
| 41 | + |
| 42 | +#### Option 3: `pdftk` |
| 43 | +```bash |
| 44 | +# Popular choice, though may need installation |
| 45 | +pdftk input1.pdf input2.pdf cat output output.pdf |
| 46 | +``` |
| 47 | + |
| 48 | +#### Option 4: `qpdf` |
| 49 | +```bash |
| 50 | +# Another stable option |
| 51 | +qpdf --empty --pages input1.pdf input2.pdf -- output.pdf |
| 52 | +``` |
| 53 | + |
| 54 | +### 📋 Implementation Checklist |
| 55 | + |
| 56 | +The ideal contribution should include: |
| 57 | + |
| 58 | +- [ ] **OS Detection Logic** - Use `runtime.GOOS` to detect the operating system |
| 59 | +- [ ] **Backend Selection** - Implement a strategy pattern for different PDF joining backends |
| 60 | +- [ ] **Linux Tool Detection** - Check which PDF tools are available on the system (priority order) |
| 61 | +- [ ] **Error Handling** - Graceful fallbacks and clear error messages if no suitable tool is found |
| 62 | +- [ ] **Tests** - Unit tests for the new functionality (mocked where appropriate) |
| 63 | +- [ ] **Documentation** - Update README with Linux requirements and installation instructions |
| 64 | +- [ ] **CI/CD** - Ensure GitHub Actions test on Linux environments |
| 65 | + |
| 66 | +### 🏗️ Suggested Code Structure |
| 67 | + |
| 68 | +```go |
| 69 | +type PDFJoiner interface { |
| 70 | + Join(inputFiles []string, outputPath string) error |
| 71 | + IsAvailable() bool |
| 72 | +} |
| 73 | + |
| 74 | +type MacOSJoiner struct{} |
| 75 | +type LinuxJoiner struct { |
| 76 | + backend string // "pdfunite", "gs", "pdftk", etc. |
| 77 | +} |
| 78 | + |
| 79 | +func NewPDFJoiner() PDFJoiner { |
| 80 | + switch runtime.GOOS { |
| 81 | + case "darwin": |
| 82 | + return &MacOSJoiner{} |
| 83 | + case "linux": |
| 84 | + return NewLinuxJoiner() |
| 85 | + default: |
| 86 | + return nil // unsupported OS |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +### 🐧 Linux Distribution Considerations |
| 92 | + |
| 93 | +The solution should work across major Linux distributions: |
| 94 | +- **Ubuntu/Debian** - `poppler-utils` (pdfunite) is usually available |
| 95 | +- **RHEL/CentOS/Fedora** - Similar package availability |
| 96 | +- **Arch Linux** - Most PDF tools available via pacman |
| 97 | +- **Alpine Linux** - Lightweight options preferred |
| 98 | + |
| 99 | +### 📚 Resources for Contributors |
| 100 | + |
| 101 | +- **Current macOS implementation**: [`main.go:53-77`](main.go#L53-L77) |
| 102 | +- **Command execution pattern**: Uses `exec.Command()` - maintain this approach |
| 103 | +- **Testing examples**: See [`main_test.go`](main_test.go) for testing patterns |
| 104 | +- **Error handling style**: Follow existing patterns in the codebase |
| 105 | + |
| 106 | +## How to Contribute |
| 107 | + |
| 108 | +1. **Fork the repository** |
| 109 | +2. **Create a feature branch**: `git checkout -b feature/linux-support` |
| 110 | +3. **Implement the changes** following the checklist above |
| 111 | +4. **Test thoroughly** on different Linux distributions if possible |
| 112 | +5. **Update documentation** (README.md, comments) |
| 113 | +6. **Submit a pull request** with: |
| 114 | + - Clear description of your implementation choice |
| 115 | + - Testing details (which distros/tools you tested) |
| 116 | + - Any limitations or known issues |
| 117 | + |
| 118 | +## Questions for Contributors |
| 119 | + |
| 120 | +- Which Linux PDF tool would you recommend as the primary choice? Why? |
| 121 | +- Should we implement a fallback chain (try pdfunite, then gs, then pdftk)? |
| 122 | +- Any experience with PDF joining tools on specific Linux distributions? |
| 123 | + |
| 124 | +## Recognition |
| 125 | + |
| 126 | +Contributors who successfully implement Linux support will be: |
| 127 | +- Added to the project's contributors list |
| 128 | +- Mentioned in release notes |
| 129 | +- Given co-maintainer consideration for ongoing development |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +**Let's make this tool truly cross-platform! 🚀** |
| 134 | + |
| 135 | +*This is a great opportunity for developers familiar with Linux systems and Go programming to contribute to an open-source project used by the community.* |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +### Labels |
| 140 | +`enhancement` `help wanted` `good first issue` `linux` `cross-platform` |
0 commit comments