A versatile command line tool to convert between Office formats and PDF.
- Convert Office documents to PDF (DOCX, PPTX, XLSX, etc.)
- Convert PDF back to Office formats (DOCX, PPTX)
- Batch conversion support
- Cross-platform (macOS, Linux)
brew install shar-mayank/tools/convert2pdfOr, if the formula is in homebrew-core:
brew install convert2pdf-
Clone the repository:
git clone https://github.com/shar-mayank/convert2pdf.git
-
Make the script executable:
chmod +x convert2pdf
-
Install dependencies:
./convert2pdf --setup
-
Move to a directory in your PATH (optional, for global access):
sudo mv convert2pdf /usr/local/bin/
- LibreOffice - Used for document format conversions
- Python 3 - For PDF to Office format conversions
- Python packages (installed automatically with
--setup):- pdf2docx - For PDF to DOCX conversion
- PyPDF2 - For PDF to PPTX conversion
- python-pptx - For PDF to PPTX conversion
Convert an Office document to PDF:
convert2pdf document.docxSpecify output filename:
convert2pdf presentation.pptx output.pdfConvert PDF to Office format:
convert2pdf document.pdf
# You'll be prompted to choose DOCX or PPTX output formatConvert all DOCX files in current directory to PDF:
convert2pdf --batch "*.docx"Convert files in one directory and save to another:
convert2pdf --batch "reports/*.pptx" pdfs/Options:
-h, --help Show help message
-v, --version Show version information
--setup Install required dependencies
--batch Process multiple files matching the input pattern
- To PDF: .doc, .docx, .ppt, .pptx, .xls, .xlsx, .odt, .odp, .ods
- From PDF: Convert to .docx or .pptx
-
Convert Word document to PDF:
convert2pdf document.docx
-
Convert PowerPoint presentation to PDF with custom name:
convert2pdf presentation.pptx slides.pdf
-
Convert PDF to Word document:
convert2pdf report.pdf report.docx
-
Convert all Excel files in a directory to PDF:
convert2pdf --batch "financials/*.xlsx" pdf_reports/
- PDF to Office conversions preserve text content but may not perfectly maintain all formatting and layout
- Images in PDFs may not be preserved when converting to Office formats
This tool includes shell completion for:
- Bash: Command options and file completion
- Zsh: Command options and file completion
When installed via Homebrew, completion scripts are automatically installed.
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.