rails-latex 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +26 -1
- data/lib/latex_to_pdf.rb +1 -1
- data/test/test_latex_to_pdf.rb +1 -1
- data/test/tmp/out.pdf +0 -0
- data/test/tmp/tmp/rails-latex/input.log +13 -13
- metadata +4 -16
data/README.rdoc
CHANGED
@@ -49,6 +49,27 @@ a archive script should be written to occasionally clean up the tmp/rails-latex
|
|
49
49
|
|
50
50
|
See the rails application under examples/rails-latex-demo/ for a working example.
|
51
51
|
|
52
|
+
=== Generating a String
|
53
|
+
|
54
|
+
If you need to generate the LaTeX document as a string you can use the +render_to_string+ method. You will probably need
|
55
|
+
to pass the <tt>:layout => true</tt> option to invoke the PDF generator. Here is an example to generate an email attachment:
|
56
|
+
|
57
|
+
In the controller you will have something along the lines of:
|
58
|
+
|
59
|
+
def send_email_method
|
60
|
+
output = render_to_string(:template => "/your_model/your_view.pdf.erb", :layout => true)
|
61
|
+
MyMailer.email_sender(current_user, output).deliver
|
62
|
+
end
|
63
|
+
|
64
|
+
The thing to note is the :layout => true which is needed so that the pdf template can grab the application erbtex layout.
|
65
|
+
Then in your mailer:
|
66
|
+
|
67
|
+
def email_sender(user, pdf_attachment)
|
68
|
+
@user = user
|
69
|
+
attachments["attachment_name.pdf"] = {:mime_type => 'application/pdf', :content => pdf_attachment}
|
70
|
+
mail( .... )
|
71
|
+
end
|
72
|
+
|
52
73
|
== Requirements
|
53
74
|
|
54
75
|
* ruby 1.8 or 1.9
|
@@ -63,4 +84,8 @@ See the rails application under examples/rails-latex-demo/ for a working example
|
|
63
84
|
Developing rails-latex requires jeweler
|
64
85
|
|
65
86
|
* rake test
|
66
|
-
* rake build
|
87
|
+
* rake build
|
88
|
+
|
89
|
+
== Contributions
|
90
|
+
|
91
|
+
* Tommaso Patrizi
|
data/lib/latex_to_pdf.rb
CHANGED
data/test/test_latex_to_pdf.rb
CHANGED
@@ -6,7 +6,7 @@ Rails=OpenStruct.new(:root => TMP_DIR=File.expand_path("../tmp",__FILE__))
|
|
6
6
|
|
7
7
|
class TestLatexToPdf < Test::Unit::TestCase
|
8
8
|
def test_escape
|
9
|
-
assert_equal "dsf \\textless{} \\textgreater{} \\& ! @ \\# \\$ \\% \\textasciicircum{} \\textasciitilde{} \\
|
9
|
+
assert_equal "dsf \\textless{} \\textgreater{} \\& ! @ \\# \\$ \\% \\textasciicircum{} \\textasciitilde{} \\textbackslash{} fds", LatexToPdf.escape_latex('dsf < > & ! @ # $ % ^ ~ \\ fds')
|
10
10
|
LatexToPdf.instance_eval{@latex_escaper=nil}
|
11
11
|
require 'redcloth'
|
12
12
|
assert_equal "dsf \\textless{} \\textgreater{} \\& ! @ \\# \\$ \\% \\^{} \\~{} \\textbackslash{} fds", LatexToPdf.escape_latex('dsf < > & ! @ # $ % ^ ~ \\ fds')
|
data/test/tmp/out.pdf
CHANGED
Binary file
|
@@ -1,12 +1,12 @@
|
|
1
|
-
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2010.10.5)
|
1
|
+
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2010.10.5) 23 MAR 2011 13:56
|
2
2
|
entering extended mode
|
3
3
|
restricted \write18 enabled.
|
4
4
|
%&-line parsing enabled.
|
5
|
-
**/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/
|
6
|
-
|
5
|
+
**/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/2800--83821154488894677
|
6
|
+
2/input.tex
|
7
7
|
|
8
|
-
(/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/
|
9
|
-
|
8
|
+
(/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/2800--838211544888946772
|
9
|
+
/input.tex
|
10
10
|
LaTeX2e <2009/09/24>
|
11
11
|
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
|
12
12
|
yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov
|
@@ -51,20 +51,20 @@ LaTeX Font Info: ... okay on input line 3.
|
|
51
51
|
[1
|
52
52
|
|
53
53
|
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
|
54
|
-
(/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/
|
55
|
-
|
54
|
+
(/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/2800--838211544888946772
|
55
|
+
/input.aux) )
|
56
56
|
Here is how much of TeX's memory you used:
|
57
57
|
199 strings out of 493848
|
58
|
-
|
58
|
+
2640 string characters out of 1152823
|
59
59
|
47808 words of memory out of 3000000
|
60
60
|
3563 multiletter control sequences out of 15000+50000
|
61
61
|
3640 words of font info for 14 fonts, out of 3000000 for 9000
|
62
62
|
714 hyphenation exceptions out of 8191
|
63
|
-
23i,4n,17p,
|
64
|
-
</usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.
|
65
|
-
|
66
|
-
Output written on /home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/
|
67
|
-
|
63
|
+
23i,4n,17p,215b,107s stack positions out of 5000i,500n,10000p,200000b,50000s
|
64
|
+
</usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb
|
65
|
+
>
|
66
|
+
Output written on /home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/2800--8
|
67
|
+
38211544888946772/input.pdf (1 page, 11949 bytes).
|
68
68
|
PDF statistics:
|
69
69
|
10 PDF objects out of 1000 (max. 8388607)
|
70
70
|
0 named destinations out of 1000 (max. 500000)
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-latex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 1.0.2
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.3
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Geoff Jacobsen
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-03-23 00:00:00 +13:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 3
|
30
|
-
- 0
|
31
|
-
- 0
|
32
24
|
version: 3.0.0
|
33
25
|
type: :runtime
|
34
26
|
version_requirements: *id001
|
@@ -83,21 +75,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
75
|
requirements:
|
84
76
|
- - ">="
|
85
77
|
- !ruby/object:Gem::Version
|
86
|
-
segments:
|
87
|
-
- 0
|
88
78
|
version: "0"
|
89
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
80
|
none: false
|
91
81
|
requirements:
|
92
82
|
- - ">="
|
93
83
|
- !ruby/object:Gem::Version
|
94
|
-
segments:
|
95
|
-
- 0
|
96
84
|
version: "0"
|
97
85
|
requirements: []
|
98
86
|
|
99
87
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.5.2
|
101
89
|
signing_key:
|
102
90
|
specification_version: 3
|
103
91
|
summary: A LaTeX to pdf rails 3 renderer.
|