itext-jruby 0.0.3 → 0.0.4
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/README.rdoc +8 -7
- data/VERSION +1 -1
- data/itext-jruby.gemspec +1 -1
- data/lib/itext/attachments.rb +11 -4
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -5,16 +5,17 @@ IText Pdf generation static java build packed to gem with some additional Ruby m
|
|
5
5
|
== Usage
|
6
6
|
|
7
7
|
=== Instalation
|
8
|
-
require 'itext-jruby'
|
8
|
+
require 'itext-jruby'
|
9
9
|
|
10
10
|
== Example
|
11
|
-
@source_pdf = File.expand_path('pdf_demo.pdf')
|
12
|
-
@sample_image = File.expand_path('ja.jpg')
|
13
|
-
@output_pdf = File.expand_path('out.pdf')
|
14
11
|
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
12
|
+
@source_pdf = File.expand_path('pdf_demo.pdf')
|
13
|
+
@sample_image = File.expand_path('ja.jpg')
|
14
|
+
@output_pdf = File.expand_path('out.pdf')
|
15
|
+
|
16
|
+
@pdf_document = Itext.new(path: @path)
|
17
|
+
@pdf_document.add_attachment @pathb
|
18
|
+
@pdf_document.save(@out)
|
18
19
|
|
19
20
|
Find more examples in test directory.
|
20
21
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/itext-jruby.gemspec
CHANGED
data/lib/itext/attachments.rb
CHANGED
@@ -48,11 +48,18 @@ module Itext::Attachments
|
|
48
48
|
def process_attachments
|
49
49
|
@writer = @stamper.getWriter.to_java(Java::ComLowagieTextPdf::PdfWriter)
|
50
50
|
|
51
|
-
@attachments.each do |
|
52
|
-
|
51
|
+
@attachments.each do |attachment|
|
52
|
+
if attachment.is_a?(Hash)
|
53
|
+
attachment_path = attachment[:path]
|
54
|
+
attachment_name = attachment[:file_name]
|
55
|
+
elsif attachment.is_a?(String)
|
56
|
+
attachment_path = attachment
|
57
|
+
attachment_name = Pathname.new(attachment_path).basename
|
58
|
+
end
|
59
|
+
|
53
60
|
attachment_spec = Java::ComLowagieTextPdf::PdfFileSpecification.fileEmbedded @writer,
|
54
|
-
attachment_path.to_java_string,
|
55
|
-
attachment_name,
|
61
|
+
attachment_path.to_s.to_java_string,
|
62
|
+
attachment_name.to_s.to_java_string,
|
56
63
|
nil
|
57
64
|
attachment_spec.addDescription attachment_name, false.to_java(:boolean)
|
58
65
|
@stamper.addFileAttachment attachment_name, attachment_spec
|