The project is in a healthy, maintained state
Convert to pdf, compress pdf, join pdf using Ghostscript
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Pludoni::Pdfutils

Gem Version

Installation

Add this line to your application's Gemfile:

gem 'pludoni-pdfutils'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pludoni-pdfutils

requires ghostscript installed.

Conversion of document formats (docx etc.) requires soffice installed

Usage

All method take either ActiveStorage::Blob or File/Tempfile as argument and return a Tempfile/File

# compresses the given file if larger than given max_size
# @returns [Pludoni::Pdfutils::FileWrapper]
Pludoni::Pdfutils.compress_if_large(file, max_size: 5.megabytes)

# converts all images to pdf (keep pdf) and joins them if there are more than max_files
# @param blobs [Array<ActiveStorage::Blob>]
# @param max_files [Integer] keep max_files - 1 files, and join the rest
# @param max_size [Integer] in bytes Convert individual file if larger than max_size
# @returns [Array<Pludoni::Pdfutils::FileWrapper>]
Pludoni::Pdfutils.convert_all_to_pdf_and_join_max_size(blobs, max_files: 3, max_size: 5.megabytes)

Individual classes:

# jpg
tempfile = Pludoni::Pdfutils::ConvertImageToPdf.new(image_file).run
# docx etc.
tempfile = Pludoni::Pdfutils::ConvertDocumentToPdf.new(image_file).run


tempfile = Pludoni::Pdfutils::Joiner.new(job_application.uploads.map(&:blob)).run

# compresses with Ghostscript + /ebook Profile
tempfile = Pludoni::Pdfutils::Compressor.new(pdf_file).run

License

The gem is available as open source under the terms of the MIT License.