Class: PdfParadise::ConvertTextToPdf
- Inherits:
-
Object
- Object
- PdfParadise::ConvertTextToPdf
- Includes:
- Colours
- Defined in:
- lib/pdf_paradise/convert_text_to_pdf.rb
Overview
require ‘convert_text_to_pdf’; ConvertTextToPdf.new
Constant Summary collapse
- FONT_FAMILY =
#
FONT_FAMILY
#
'Courier'
Instance Method Summary collapse
-
#_(i) ⇒ Object
# === _ ========================================================================= #.
-
#convert_this_text_file(i = @input) ⇒ Object
# === convert_this_text_file.
-
#initialize(i = nil, run_already = true) ⇒ ConvertTextToPdf
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#set_input(i = '') ⇒ Object
# === set_input ========================================================================= #.
Constructor Details
#initialize(i = nil, run_already = true) ⇒ ConvertTextToPdf
#
initialize
#
28 29 30 31 32 33 34 35 |
# File 'lib/pdf_paradise/convert_text_to_pdf.rb', line 28 def initialize( i = nil, run_already = true ) set_input(i) reset run if run_already end |
Instance Method Details
#_(i) ⇒ Object
#
_
#
78 79 80 81 |
# File 'lib/pdf_paradise/convert_text_to_pdf.rb', line 78 def _(i) e i system i end |
#convert_this_text_file(i = @input) ⇒ Object
#
convert_this_text_file
Use enscript to created a .ps file, and then ps2pdf (or ps2pdfwr) to convert to .pdf
The following script creates a .pdf file with 10 pt left and right margins, and uses a courier font that is 7.3 pts wide and 10 pts high, so a 132 col printout fits on an 8 1/2 X 11 page. Use enscript to setup your page, fonts, etc.
#
65 66 67 68 69 70 71 72 73 |
# File 'lib/pdf_paradise/convert_text_to_pdf.rb', line 65 def convert_this_text_file(i = @input) if File.exist? i _ 'enscript -B --margins=10:10: -o outputfile.ps -f '+ @font_family+'@7.3/10 '+i _ 'ps2pdfwr outputfile.ps x.pdf' else e 'Sorry, there is no file at '+i+'.' end end |
#reset ⇒ Object
#
reset
#
40 41 42 |
# File 'lib/pdf_paradise/convert_text_to_pdf.rb', line 40 def reset # reset tag @font_family = FONT_FAMILY end |
#run ⇒ Object
#
run
#
86 87 88 |
# File 'lib/pdf_paradise/convert_text_to_pdf.rb', line 86 def run # (run tag) convert_this_text_file end |
#set_input(i = '') ⇒ Object
#
set_input
#
47 48 49 50 51 |
# File 'lib/pdf_paradise/convert_text_to_pdf.rb', line 47 def set_input(i = '') i = i.first if i.is_a? Array i = i.to_s.dup @input = i end |