No release in over 3 years
Low commit activity in last 3 years
Add a footer to each document and create a single .pdf file all in one command.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.0.21
~> 1.5.0
~> 2.4.0
 Project Readme
Documents with Footer to .pdf for Ruby

Add a footer to each document and create a single .pdf file all in one command.


Examples

Options: HEADLINE, TIMESTAMP, PAGE_CURRENT

{ 
    footer__table__left__top__text: '<<--ENUMERATOR_INTEGER-->>. <<--HEADLINE-->>',
    footer__table__left__bottom__text: '<<--TIMESTAMP-->>',
    footer__table__center__top__text: '',
    footer__table__center__bottom__text: '',
    footer__table__right__top__text: '<<--PAGE_CURRENT-->>',
    footer__table__right__bottom__text: '',
}

Output



Options: HEADLINE, SUBHEADING, text, PAGE_CURRENT, PAGE_TOTAL, timestamp_strf

{ 
    footer__table__left__top__text: '<<--ENUMERATOR_ROMAN-->>. <<--HEADLINE-->>',
    footer__table__left__bottom__text: '<<--SUBHEADING-->>',
    footer__table__center__top__text: 'Application',
    footer__table__center__bottom__text: 'John Doe',
    footer__table__right__top__text: '<<--TIMESTAMP-->>',
    footer__table__right__bottom__text: '<<--PAGE_CURRENT-->> of <<--PAGE_TOTAL-->>',
    selectors__timestamp__strf: '%A, %e %B %Y'
}

Output


Options: TIMESTAMP, ENUMERATOR_CHAR, HEADLINE, PAGE_CURRENT

{ 
    footer__table__left__top__text: '<<--TIMESTAMP-->>',
    footer__table__left__bottom__text: '',
    footer__table__center__top__text: '<<--ENUMERATOR_CHAR-->> <<--HEADLINE-->>',
    footer__table__center__bottom__text: '',
    footer__table__right__top__text: '<<--PAGE_CURRENT-->>',
    footer__table__right__bottom__text: '',
}



Table of Contents
  1. Quickstart
  2. Setup
  3. Methods
  4. Options
  5. Selectors
  6. Contributing
  7. Limitations
  8. Credits
  9. License
  10. Code of Conduct
  11. Support my Work

Quickstart
require 'documents_with_footer_to_pdf'


your_folder = './1-test/'

DocumentsWithFooterToPdf.generate( 
    your_folder, 
    :short, 
    {}
) 

Setup

Add this line to your application's Gemfile:

gem 'documents_with_footer_to_pdf'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install documents_with_footer_to_pdf

On Rubygems:


Methods

.get_options()

require 'documents_with_footer_to_pdf'

hash = DocumentsWithFooterToPdf.get_options() 
# => { path: 

.generate()

require 'documents_with_footer_to_pdf'

hash = DocumentsWithFooterToPdf.generate( 
    folder, 
    console_mode,  
    options 
)

Input

Type Required Description Example Description
headline String Yes "./test/" Define path to folder
console mode Symbol Yes :hash Set test console output mode. Use :silent, :short, or :detail
options 'Hash' No {} Change defaut options, please refer: Options for more info

Return
Boolean


Options

Path

Nr Name Key Default Type Description
A.1. Children Tmp Name :path__children__tmp__name "tmp-{{SALT}}" String Change temporary folder name, {{SALT}} will replaced with current unix timestamp
A.2. Children Pdf_combined Name :path__children__pdf_combined__name "0-result-{{SALT}}" String Change result folder name, {{SALT}} will replaced with current unix timestamp

Footer

Nr Name Key Default Type Description
B.1. Position Top :footer__position__top [0, 20] Array Set footer position top.
B.2. Position Bottom :footer__position__bottom [0, 10] Array Set footer position bottom.
B.3. Table Left Top Text :footer__table__left__top__text "<<--FILENAME-->>" String Set text in field left-top
B.4. Table Left Bottom Text :footer__table__left__bottom__text "" String String
B.5. Table Center Top Text :footer__table__center__top__text "" String String
B.6. Table Center Bottom Text :footer__table__center__bottom__text "" String String
B.7. Table Right Top Text :footer__table__right__top__text "<<--TIMESTAMP-->>" String String
B.8. Table Right Bottom Text :footer__table__right__bottom__text "<<--PAGE_CURRENT-->> from <<--PAGE_TOTAL-->>" String String

Selectors

Nr Name Key Default Type Description
C.1. Timestamp Gsub :selectors__timestamp__gsub "<<--TIMESTAMP-->>" String Change marker for timestamp.
C.2. Timestamp Strf :selectors__timestamp__strf "%d.%m.%Y" String Change format of date and time
C.3. Page_current Gsub :selectors__page_current__gsub "<<--PAGE_CURRENT-->>" String Change marker for current page.
C.4. Page_total Gsub :selectors__page_total__gsub "<<--PAGE_TOTAL-->>" String Change marker for total page size
C.5. Enumerator_original Gsub :selectors__enumerator_original__gsub "<<--ENUMERATOR_ORIGINAL-->>" String Change marker for original enumeration
C.6. Enumerator_integer Gsub :selectors__enumerator_integer__gsub "<<--ENUMERATOR_INTEGER-->>" String Change marker for integer enumeration
C.7. Enumerator_char Gsub :selectors__enumerator_char__gsub "<<--ENUMERATOR_CHAR-->>" String Change marker for char enumeration
C.8. Enumerator_roman Gsub :selectors__enumerator_roman__gsub "<<--ENUMERATOR_ROMAN-->>" String Change marker for roman letters enumeration
C.9. Filename Gsub :selectors__filename__gsub "<<--FILENAME-->>" String Change marker for filename
C.10. Path Gsub :selectors__path__gsub "<<--PATH-->>" String Change marker for full path
C.11. Heading Gsub :selectors__heading__gsub "<<--HEADLINE-->>" String Change marker for headline
C.12. Subheading Gsub :selectors__subheading__gsub "<<--SUBHEADING-->>" String Change marker for sub headline

More Information on strf format: https://apidock.com/ruby/DateTime/strftime

Params

Nr Name Key Default Type Description
D.1. Footer Font_size :params__footer__font_size 9 Integer Set footer font size
D.2. Document Width :params__document__width 500 Integer Set document width
D.3. Image Density :params__image__density 300 Integer Set image density
D.4. Search Subfolders :params__search__subfolders false Boolean Set if subfolders should be included in search
D.5. Search Suffixs :params__search__suffixs ["jpg", "png", "pdf"] Array Types of suffixes which are included (Supported jpg, png, pdf)
D.6. Console Length :params__console__length 50 Integer Change length of console output

Selectors
Selector Example Description
"<<--TIMESTAMP-->>" 24.05.2021 Show current Timestamp, to change for format use option: :selectors__timestamp__strf
"<<--PAGE_CURRENT-->>" 1 Show current Page
"<<--PAGE_TOTAL-->>" 3 Show total Page size
"<<--ENUMERATOR_ORIGINAL-->>" "C" Show original Enumerator
"<<--ENUMERATOR_INTEGER-->>" 3 Show Enumerator as Integer
"<<--ENUMERATOR_CHAR-->>" "C" Show Enumerator as Char
"<<--ENUMERATOR_ROMAN-->>" "III" Show Enumerator in Roman Letters
"<<--FILENAME-->>" "C--HEADING--Subheadline.png" Show filename
"<<--PATH-->>" "../C--HEADING--Subheadline" Show file path
"<<--HEADLINE-->>" "HEADING" Show Headline
"<<--SUBHEADING-->>" "Subheading" Show Subheading

Filename Selectors

Use double hyphens '--' as limiter

Struct: #{SINGLE DIGIT/CHAR}--#{HEADLINE}--#{SUBHEADING}.suffix

Example Filename: C--HEADING--Subheadline.png


Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/a6b8/documents-with-footer-to-pdf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.


Limitations
  • Made for local usage
  • Some pdf fonts are not supported.

Credits

This gem depend on following gems:


License

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


Code of Conduct

Everyone interacting in the documents-with-footer-to-pdf project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.


Star us

Please ⭐️ star this Project, every ⭐️ star makes us very happy!