# 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_childrentmp_name "tmp-{{SALT}}" String Change temporary folder name, {SALT} will replaced with current unix timestamp
A.2. Children Pdf_combined Name :path_childrenpdf_combined_name "0-result-{{SALT}}" String Change result folder name, {SALT} will replaced with current unix timestamp
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_tablelefttop_text "<<--FILENAME-->>" String Set text in field left-top
B.4. Table Left Bottom Text :footer_tableleftbottom_text "" String String
B.5. Table Center Top Text :footer_tablecentertop_text "" String String
B.6. Table Center Bottom Text :footer_tablecenterbottom_text "" String String
B.7. Table Right Top Text :footer_tablerighttop_text "<<--TIMESTAMP-->>" String String
B.8. Table Right Bottom Text :footer_tablerightbottom_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.


Support my Work

Donate by https://www.paypal.com