{"id":24194382,"url":"https://github.com/wteja/pdf-converter","last_synced_at":"2026-06-07T03:31:40.388Z","repository":{"id":272039281,"uuid":"915339301","full_name":"wteja/pdf-converter","owner":"wteja","description":"PDF Converter Server made with Go \u0026 LibreOffice","archived":false,"fork":false,"pushed_at":"2025-01-11T16:07:17.000Z","size":1187,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-11T17:24:07.560Z","etag":null,"topics":["api","converter","converter-app","converters","excel","go","golang","libreoffice","pdf","powerpoint","webapp","word"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/wteja/pdf-converter","language":"Go","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/wteja.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}},"created_at":"2025-01-11T15:39:33.000Z","updated_at":"2025-01-11T17:17:27.000Z","dependencies_parsed_at":"2025-01-11T17:24:09.827Z","dependency_job_id":"528163e7-fa48-49e4-b3a7-4c92307f6de5","html_url":"https://github.com/wteja/pdf-converter","commit_stats":null,"previous_names":["wteja/pdf-converter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wteja%2Fpdf-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wteja%2Fpdf-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wteja%2Fpdf-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wteja%2Fpdf-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wteja","download_url":"https://codeload.github.com/wteja/pdf-converter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241622615,"owners_count":19992504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","converter","converter-app","converters","excel","go","golang","libreoffice","pdf","powerpoint","webapp","word"],"created_at":"2025-01-13T18:25:28.274Z","updated_at":"2025-12-01T14:04:58.905Z","avatar_url":"https://github.com/wteja.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Office to PDF Converter\n\nThis is a simple HTTP server application written in Go that converts uploaded office files into PDF files using LibreOffice in headless mode. The server listens on port `5000` and exposes a single endpoint for file conversion. It also includes automatic cleanup of temporary files older than one hour.\n\n## Features\n\n- Converts various office files to PDF format using LibreOffice.\n- Handles file uploads via HTTP POST requests.\n- Automatic cleanup of old files from the temporary directory after one hour.\n- Minimal and efficient implementation using Go.\n\n## Requirements\n\n- **Go**: Ensure Go is installed on your system ([Download Go](https://golang.org/dl/)).\n- **LibreOffice**: LibreOffice must be installed and accessible via the `soffice` command.\n\n## Supported File Formats\n\nThis application relies on LibreOffice for file conversion, so it supports any file format LibreOffice can handle. Below are the formats that can be converted to PDF:\n\n### Document Formats\n- `.doc`, `.docx` (Microsoft Word)\n- `.odt`, `.ott` (LibreOffice/OpenDocument Text)\n- `.rtf` (Rich Text Format)\n- `.txt` (Plain Text)\n\n### Spreadsheet Formats\n- `.xls`, `.xlsx` (Microsoft Excel)\n- `.ods`, `.ots` (LibreOffice/OpenDocument Spreadsheet)\n- `.csv` (Comma-Separated Values)\n\n### Presentation Formats\n- `.ppt`, `.pptx` (Microsoft PowerPoint)\n- `.odp`, `.otp` (LibreOffice/OpenDocument Presentation)\n\n### Other Formats\n- `.svg` (Scalable Vector Graphics)\n- `.html`, `.htm` (HTML Files)\n- `.xml` (XML Files)\n- `.pdf` (for PDF editing and re-exporting)\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone \u003crepository_url\u003e\n   cd \u003crepository_directory\u003e\n   ```\n\n2. Install dependencies:\n   This application does not have external dependencies, but ensure you have LibreOffice installed.\n\n3. Build the application:\n   ```bash\n   go build -o pdf-converter .\n   ```\n\n4. Run the application:\n   ```bash\n   ./pdf-converter\n   ```\n\nThe server will start listening on `http://localhost:5000`.\n\n## API Usage\n\n### **Endpoint: `/convert`**\n- **Method**: `POST`\n- **Field Name**: `file`\n- **File Type**: Any supported format (e.g., `.xlsx`, `.docx`).\n\n#### Request Example (Using `curl`):\n```bash\ncurl -X POST -F \"file=@example.xlsx\" http://localhost:5000/convert --output output.pdf\n```\n\n#### Response:\n- **Success**: Returns the converted PDF file as a response with the `Content-Type` set to `application/pdf`.\n- **Error**: Returns an appropriate HTTP status code and error message if the conversion fails.\n\n## Public Docker Image\n\nYou can use the publicly available Docker image for this application:\n\n```bash\ndocker pull wteja/pdf-converter\n```\n\nRun the container:\n\n```bash\ndocker run -p 5000:5000 wteja/pdf-converter\n```\n\n## Configuration\n\n- Temporary files are stored in the `./tmp` directory. Ensure the application has write access to this directory.\n- The application automatically removes files older than one hour from the `tmp` directory.\n\n## Code Overview\n\n### **Main Components**\n\n1. **File Upload and Conversion**:\n   - The `/convert` endpoint processes file uploads, saves them to the `tmp` directory, and invokes LibreOffice in headless mode to perform the conversion.\n\n2. **Temporary Directory Management**:\n   - All uploaded and converted files are stored in the `tmp` directory.\n   - A background goroutine periodically checks and deletes files older than one hour.\n\n3. **Error Handling**:\n   - Comprehensive error handling for file uploads, conversions, and temporary file management.\n\n### **Key Functions**\n- `handleConvert`: Handles the HTTP requests, manages file upload and conversion, and returns the resulting PDF.\n- `cleanupOldFiles`: Periodically deletes old files from the `tmp` directory.\n\n## Future Improvements\n\n- Support additional file formats (e.g., `.pptx`, `.odg`).\n- Add configurable cleanup duration and temporary directory path.\n- Implement better logging and monitoring.\n\n## License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for details.\n\n## Author\n\nDeveloped by [Weerayut Teja](https://github.com/wteja). Contributions and feedback are welcome!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwteja%2Fpdf-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwteja%2Fpdf-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwteja%2Fpdf-converter/lists"}