drnic-princely 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/init.rb +1 -1
- data/lib/princely.rb +18 -1
- data/lib/princely/pdf_helper.rb +5 -1
- data/princely.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require "
|
1
|
+
require File.dirname(__FILE__) + "/lib/princely/rails"
|
data/lib/princely.rb
CHANGED
@@ -56,7 +56,7 @@ class Princely
|
|
56
56
|
# Returns PDF as a stream, so we can use send_data to shoot
|
57
57
|
# it down the pipe using Rails.
|
58
58
|
#
|
59
|
-
def pdf_from_string(string)
|
59
|
+
def pdf_from_string(string, output_file = '-')
|
60
60
|
path = self.exe_path()
|
61
61
|
# Don't spew errors to the standard out...and set up to take IO
|
62
62
|
# as input and output
|
@@ -75,4 +75,21 @@ class Princely
|
|
75
75
|
pdf.close_read
|
76
76
|
return result
|
77
77
|
end
|
78
|
+
|
79
|
+
def pdf_from_string_to_file(string, output_file)
|
80
|
+
path = self.exe_path()
|
81
|
+
# Don't spew errors to the standard out...and set up to take IO
|
82
|
+
# as input and output
|
83
|
+
path << " --silent - -o #{output_file}"
|
84
|
+
|
85
|
+
# Show the command used...
|
86
|
+
logger.info "\n\nPRINCE XML PDF COMMAND"
|
87
|
+
logger.info path
|
88
|
+
logger.info ''
|
89
|
+
|
90
|
+
# Actually call the prince command, and pass the entire data stream back.
|
91
|
+
pdf = IO.popen(path, "w+")
|
92
|
+
pdf.puts(string)
|
93
|
+
pdf.close
|
94
|
+
end
|
78
95
|
end
|
data/lib/princely/pdf_helper.rb
CHANGED
@@ -37,7 +37,11 @@ module PdfHelper
|
|
37
37
|
html_string.gsub!( /src=["'](\S+\?\d*)["']/i ) { |m| 'src="' + $1.split('?').first + '"' }
|
38
38
|
|
39
39
|
# Send the generated PDF file from our html string.
|
40
|
-
|
40
|
+
if filename = options[:filename] || options[:file]
|
41
|
+
prince.pdf_from_string_to_file(html_string, filename)
|
42
|
+
else
|
43
|
+
prince.pdf_from_string(html_string)
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
def make_and_send_pdf(pdf_name, options = {})
|
data/princely.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{princely}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Bleigh", "Seth from Subimage Interactive"]
|