{"id":40705060,"url":"https://github.com/hkdb/cpdf","last_synced_at":"2026-01-21T12:10:21.244Z","repository":{"id":48180070,"uuid":"132928805","full_name":"hkdb/cpdf","owner":"hkdb","description":"A script to simplify compressing PDF file size with GhostScript","archived":false,"fork":false,"pushed_at":"2024-06-24T11:51:14.000Z","size":26,"stargazers_count":75,"open_issues_count":2,"forks_count":23,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-24T13:14:06.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/hkdb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-05-10T16:46:53.000Z","updated_at":"2024-06-24T11:46:26.000Z","dependencies_parsed_at":"2022-09-26T19:11:50.348Z","dependency_job_id":null,"html_url":"https://github.com/hkdb/cpdf","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/hkdb/cpdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdb%2Fcpdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdb%2Fcpdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdb%2Fcpdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdb%2Fcpdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hkdb","download_url":"https://codeload.github.com/hkdb/cpdf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdb%2Fcpdf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28632782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-01-21T12:10:20.663Z","updated_at":"2026-01-21T12:10:21.227Z","avatar_url":"https://github.com/hkdb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cPDF\n**maintained by:** hkdb \\\u003c\u003chkdb@3df.io\u003e\\\u003e\u003cbr /\u003e\n\n## Description\n\nA Python script that simplifies compressing pdf files with gs.\n\n\n## Usage Example\n\nCheck file size of test.pdf:\n\n```\nhkdb@machine:~/test$ ll\ntotal 31M\ndrwxrwxr-x  2 hkdb hkdb 4.0K May  1 14:59 .\ndrwxr-xr-x 94 hkdb hkdb 4.0K Apr 30 21:45 ..\n-rw-rw-r--  1 hkdb hkdb  31M Apr 29 23:32 test.pdf\n```\n\nHelp:\n\n```\nhkdb@machine:~/test$ cpdf help\n\nThis is a script to compress a pdf file with the convention of: cpdf [type: screen, ebook, printer, prepress, or default] [input file name] [output file name] . To learn more about the different types, use the \"types\" flag (ie. cpdf types)\n\n```\n\nList the preset types of compression settings:\n\n```\nhkdb@machine:~/test$ cpdf types\n\nscreen - selects low-resolution output similar to the Acrobat Distiller \"Screen Optimized\" setting.\nebook - selects medium-resolution output similar to the Acrobat Distiller \"eBook\" setting.\nprinter - selects output similar to the Acrobat Distiller \"Print Optimized\" setting.\nprepress - selects output similar to Acrobat Distiller \"Prepress Optimized\" setting.\ndefault - selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.\n\n```\n\nCompress:\n\n```\nhkdb@machine:~/test$ cpdf ebook test.pdf compressed.pdf\nhkdb@machine:~/test$ ll\ntotal 35M\ndrwxrwxr-x  2 hkdb hkdb 4.0K May  1 15:00 .\ndrwxr-xr-x 94 hkdb hkdb 4.0K Apr 30 21:45 ..\n-rw-rw-r--  1 hkdb hkdb 4.0M May  1 15:02 compressed.pdf\n-rw-rw-r--  1 hkdb hkdb  31M Apr 29 23:32 test.pdf\nhkdb@machine:~/test$\n```\nNotice that compressed.pdf is 4M; the results from compressing a 31M pdf? I then opened up compressed.pdf and it still looked great!\n\nYou can also specify input and output files with full path:\n\n```\nhkdb@machine:~/test$ cpdf ebook /home/hkdb/test.pdf /home/hkdb/Downloads/test-compressed.pdf\n```\n\nVersion Checker:\n\n```\nhkdb@machine:~/test$ cpdf version\n\ncPDF v2.0\n\nhkdb@machine:~/test$\n```\n\nAs of v1.1, color coding certain output text has been added to improve readability:\n\n![colorcode](https://osi.3df.io/wp-content/uploads/2018/05/coloroutput.png \"Color Coding\")\n\n\n## Under the Hood\n\nIt essentially takes your arguments and turns it into the following Ghostscript command:\n\n```\ngs -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -dPDFSETTINGS=/ebook\n-dNOPAUSE -dQUIET -dBATCH -sOutputFile=[compressed.pdf]\n\"[input.pdf]\"\n```\n\n\n## Error Handling\n\nCurrently, if any of the below conditions are met, the script will print an error/warning message and exit. This is designed to prevent any dangerous execution of Ghostscript and to remind users in case they forget to input the command with the right convention. For the ones that are questionable, it will warn the user and provide a chance to cancel or confirm.\n\nConvention:\n\n- Less than 3 arguments given\n- Invalid compression type argument\n\nGhostscript:\n\n- Input File Does Not End with .pdf\n- Input File and Output File are the same\n- Input File Name Contains Unsupported Characters(| ; ` \u003e \u003c } { # *)\n- Output File Name Contains Unsupported Characters(| ; ` \u003e \u003c } { # *)\n\nQuestionable Conditions that the application will verify with User via A Dialog Message:\n\n- Output File does not End with .pdf, Verify with User That's Really What They Want\n- Output File Name Matches a File in the Output Directory\n\n\n## Installation\n\nLinux / Mac / FreeBSD:\n\n```bash\ncurl -sL https://github.com/hkdb/cpdf/releases/latest/download/install.sh | bash\n```\nYou will still have to manually ensure `~/.local/bin` is in $PATH\n\nWindows:\n\n```powershell\nInvoke-WebRequest -Uri \"https://github.com/hkdb/cpdf/releases/latest/download/install.bat\" -OutFile \"install.bat\"; .\\install.bat\n```\n\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md)\n\n\n## Disclaimer\n\nThis application is maintained by volunteers and in no way do the maintainers make any guarantees. Please use at your own risk!\n\n\n## Recognition\n\nMany thanks to Dr. Haggen So for sharing the following link that inspired me to write this script:\n\nhttps://www.tjansson.dk/2012/04/compressing-pdfs-using-ghostscript-under-linux/\n\nThis is an Open Source utility sponsored by 3DF Limited's Open Source Initiative:\n\nhttps://osi.3df.io\nhttps://www.3df.com.hk\n\n\n## Want a graphical alternative instead?\n\nCheck out [Densify](https://github.com/hkdb/densify), a GTK+ GUI Application written in Python that simplifies compressing PDF files with Ghostscript\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkdb%2Fcpdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkdb%2Fcpdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkdb%2Fcpdf/lists"}