{"id":13588977,"url":"https://github.com/yeokm1/docs-to-pdf-converter","last_synced_at":"2026-01-10T21:43:28.490Z","repository":{"id":12153040,"uuid":"14746796","full_name":"yeokm1/docs-to-pdf-converter","owner":"yeokm1","description":"A standalone Java library/command line tool that converts DOC, DOCX, PPT, PPTX and ODT documents to PDF files.","archived":true,"fork":false,"pushed_at":"2023-03-27T22:21:25.000Z","size":45491,"stargazers_count":593,"open_issues_count":22,"forks_count":244,"subscribers_count":42,"default_branch":"master","last_synced_at":"2024-11-06T08:43:25.480Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/yeokm1.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}},"created_at":"2013-11-27T12:46:40.000Z","updated_at":"2024-10-11T09:06:11.000Z","dependencies_parsed_at":"2022-07-15T14:47:49.129Z","dependency_job_id":"b9c5dfc5-7ef6-4876-a1d2-fa9ebfde4a9d","html_url":"https://github.com/yeokm1/docs-to-pdf-converter","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeokm1%2Fdocs-to-pdf-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeokm1%2Fdocs-to-pdf-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeokm1%2Fdocs-to-pdf-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeokm1%2Fdocs-to-pdf-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeokm1","download_url":"https://codeload.github.com/yeokm1/docs-to-pdf-converter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247796149,"owners_count":20997521,"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":[],"created_at":"2024-08-01T16:00:16.875Z","updated_at":"2026-01-10T21:43:28.437Z","avatar_url":"https://github.com/yeokm1.png","language":"Java","funding_links":[],"categories":["JAVA","文件操作"],"sub_categories":["文件转换"],"readme":"Docs to PDF Converter\n=====================\n\n**(I'm not maintaining this code as I neither have personal resources nor am I still using this project. I'll be happy to oblige if you have any pull requests or even if you wish to be a co-maintainer.)**\n\nA standalone Java library/command line tool that converts DOC, DOCX, PPT, PPTX and ODT documents to pdf files. (Requires JRE 7)\n\nThe v1.7 release has not been updated for about 2 years although it seems quite reliable for me. In response to an [issue request](https://github.com/yeokm1/docs-to-pdf-converter/issues/1) to update the libraries, I have done so with the new v1.8. I now use Maven to managed the libraries in the pom.xml file.\n\nI have not tested v1.8 much so if you face any issues, you can still use v1.7 in the Releases section.\n\n# Table of content\n\n  + [Why?](#why)\n  + [Command Line Usage](#command-line-usage)\n  + [Parameters](#parameters)\n  + [Library Usage](#library-usage)\n  + [Caveats and technical details](#caveats-and-technical-details)\n    - [DOC](#doc)\n    - [DOCX](#docx)\n    - [PPT and PPTX](#ppt-and-pptx)\n    - [ODT](#odt)\n  + [Main Libraries](#main-libraries)\n* [Compiling the code](#compiling-the-code)\n\n### Why?  \nI wanted a simple program that can convert Microsoft Office documents to PDF but without dependencies like LibreOffice or expensive proprietary solutions. Seeing as how code and libraries to convert each individual format is scattered around the web, I decided to combine all those solutions into one single program. Along the way, I decided to add ODT support as well since I encountered the code too.\n\n### Command Line Usage:  \n\n```\njava -jar doc-converter.jar -type \"type\" -input \"path\" -output \"path\" -verbose\njava -jar doc-converter.jar -input test.doc\njava -jar doc-converter.jar -i test.ppt -o ~\\output.pdf\njava -jar doc-converter.jar -i ~\\no-extension-file -o ~\\output.pdf -t docx\n```\n\n### Parameters:  \n```\n-inputPath (-i, -in, -input) \"path\" : specifies a path for the input file\n\n-outputPath (-o, -out, -output) \"path\" : specifies a path for the output PDF, use input file directory and name.pdf if not specified (Optional)\n\n-type (-t) [DOC | DOCX | PPT | PPTX | ODT] : Specifies doc converter. Leave blank to let program infer via file  extension (Optional)\n\n-verbose (-v) : To view intermediate processing messages. (Optional)\n```\n\n### Library Usage:  \n\n1. Drop the jar into your lib folder and add to build path.  \n2. Choose the converter of your choice, they are named DocToPDFConverter, DocxToPDFConverter, PptToPDFConverter, PptxToPDFConverter and OdtToPDFConverter.  \n3. Instantiate with 4 parameters  \n   - InputStream `inStream`: Document source stream to be converted  \n   - OutputStream `outStream`: Document output stream  \n   - boolean `showMessages`: Whether to show intermediate processing messages to Standard Out (stdout)  \n   - boolean `closeStreamsWhenComplete`: Whether to close input and output streams when complete  \n4. Call the \"convert()\" method and wait.  \n\n\n### Caveats and technical details:  \nThis tool relies on Apache POI, xdocreport, docx4j and odfdom libraries. They are not 100% reliable and the output format may not always be what you desire.\n\n\n#### DOC:\nGenerally ok but takes some time to convert.. I notice that after conversion, the paragraph spacing tends to increase affecting your page layout. Conversion is done using docx4j to convert DOC to DOCX then to PDF.(Cannot use xdocreport once the DOCX data is obtained as the intermediate data structure is docx4j specific.)\n\n#### DOCX:\nVery good results. Fast conversion too.  Conversion is done using xdocreport library as it seems faster and more accurate than docx4j.\n\n#### PPT and PPTX:\nResulting file is a PDF comprising of a PNG embedded in each page. Should be good enough for printing. This is the limitation of the Apache POI and docx4j libraries.\n\n#### ODT:\nQuality and speed as good as DOCX. Conversion is done using odfdom of the Apache ODF Toolkit.\n\n### Main Libraries  \nApache POI:  https://poi.apache.org/  \nxdocreport: http://code.google.com/p/xdocreport/  \ndocx4j: http://www.docx4java.org/  \nodfdom: https://incubator.apache.org/odftoolkit/odfdom/  \nand others...  \n\n## Compiling the code\n\n### I just want the jar\n\n```bash\n# If you don't already have Maven in your Mac\nbrew install maven\nmvn clean package\n```\n\nThe output jar file can be found in the `target` folder.\n\n### Development\nI'm using Eclipse Mars IDE Java EE with the M2Eclipse plugin. Simply create a workspace and import my project into it. Let Maven do its work in downloading all the necessary dependencies. Once everything is downloaded, you should be able to run the MainClass.\n\nMore details can be found in the [Wiki section](https://github.com/yeokm1/docs-to-pdf-converter/wiki/Setting-up-your-IDE-to-compile-the-project).\n\nThe MIT License (MIT)\nCopyright (c) 2013-2014 Yeo Kheng Meng\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeokm1%2Fdocs-to-pdf-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeokm1%2Fdocs-to-pdf-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeokm1%2Fdocs-to-pdf-converter/lists"}